feat: rewrite episode info script in python

This commit is contained in:
Benexl
2025-11-18 13:59:40 +03:00
parent a7b0f21deb
commit 6e287d320d
2 changed files with 50 additions and 10 deletions

View File

@@ -0,0 +1,44 @@
import sys
from rich.console import Console
from rich.table import Table
from rich.rule import Rule
from rich.markdown import Markdown
console = Console(force_terminal=True, color_system="truecolor")
HEADER_COLOR = sys.argv[1]
SEPARATOR_COLOR = sys.argv[2]
def rule(title: str | None = None):
console.print(Rule(style=f"rgb({SEPARATOR_COLOR})"))
console.print("{TITLE}", justify="center")
left = [
("Duration", "Status"),
("Total Episodes", "Next Episode"),
("Progress", "List Status"),
("Start Date", "End Date"),
]
right = [
("{DURATION}", "{STATUS}"),
("{EPISODES}", "{NEXT_EPISODE}"),
("{USER_PROGRESS}", "{USER_STATUS}"),
("{START_DATE}", "{END_DATE}"),
]
for L_grp, R_grp in zip(left, right):
table = Table.grid(expand=True)
table.add_column(justify="left", no_wrap=True)
table.add_column(justify="right", overflow="fold")
for L, R in zip(L_grp, R_grp):
table.add_row(f"[bold rgb({HEADER_COLOR})]{L} [/]", f"{R}")
rule()
console.print(table)
rule()

View File

@@ -354,18 +354,14 @@ def get_episode_preview(
# Format the template with the dynamic values # Format the template with the dynamic values
replacements = { replacements = {
"PREVIEW_MODE": config.general.preview, "PREVIEW_MODE": config.general.preview,
"IMAGE_CACHE_PATH": str(IMAGES_CACHE_DIR), "IMAGE_CACHE_DIR": str(IMAGES_CACHE_DIR),
"INFO_CACHE_PATH": str(INFO_CACHE_DIR), "INFO_CACHE_DIR": str(INFO_CACHE_DIR),
"PATH_SEP": path_sep,
"IMAGE_RENDERER": config.general.image_renderer, "IMAGE_RENDERER": config.general.image_renderer,
# Color codes # Color codes
"C_TITLE": ansi.get_true_fg(HEADER_COLOR, bold=True), "HEADER_COLOR": ",".join(HEADER_COLOR),
"C_KEY": ansi.get_true_fg(HEADER_COLOR, bold=True), "SEPARATOR_COLOR": ",".join(SEPARATOR_COLOR),
"C_VALUE": ansi.get_true_fg(HEADER_COLOR, bold=True), "PREFIX": f"episode-{media_item.title.english}",
"C_RULE": ansi.get_true_fg(SEPARATOR_COLOR, bold=True), "SCALE_UP": str(config.general.preview_scale_up),
"RESET": ansi.RESET,
"PREFIX": f"{media_item.title.english}_Episode_",
"SCALE_UP": " --scale-up" if config.general.preview_scale_up else "",
} }
for key, value in replacements.items(): for key, value in replacements.items():