Skip to content

Commit

Permalink
[episodes] auto progress selection
Browse files Browse the repository at this point in the history
  • Loading branch information
NextFire committed Jan 30, 2024
1 parent 426c86f commit de5299c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 9 additions & 5 deletions sachi/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import asyncio
from dataclasses import asdict, dataclass
from pathlib import Path
from typing import Callable, Self, assert_never, cast
from typing import Any, Callable, Self, assert_never, cast

import jinja2
from guessit import guessit
from pymediainfo import MediaInfo
from rich.text import Text

from sachi.config import BaseConfig, read_config
from sachi.context import FileBotContext
Expand All @@ -25,7 +26,7 @@ class SachiMatch:

class SachiFile:
def __init__(
self, path: Path, base_dir: Path, set_rename_cell: Callable[[str | None], None]
self, path: Path, base_dir: Path, set_rename_cell: Callable[[Any], None]
):
self.path = path
self.base_dir = base_dir
Expand All @@ -48,9 +49,12 @@ def match(self, value: SachiMatch | None):
self._match = value

self.set_rename_cell(
f"{value.parent.title} ({value.parent.year}) "
f"- {value.episode.season:02}x{value.episode.episode:02} "
f"- {value.episode.name}"
Text(
f"{value.parent.title} ({value.parent.year}) "
f"- {value.episode.season:02}x{value.episode.episode:02} "
f"- {value.episode.name}",
style="italic",
)
if value
else None
)
Expand Down
6 changes: 5 additions & 1 deletion sachi/screens/episodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def compose(self) -> ComposeResult:
((f"{s.service} ({s.media_type})", s) for s in SOURCE_CLASSES),
prompt="Source",
)
yield SelectionList[int]()
yield SelectionList[int](id="episodes-list")
yield Footer()

# Methods
Expand Down Expand Up @@ -103,6 +103,10 @@ async def search(self, event: Input.Submitted):
for i, ep in enumerate(self.sachi_episodes)
)

@on(SelectionList.SelectedChanged, "#episodes-list")
def on_episode_selected(self, event: SelectionList.SelectedChanged):
event.control.action_cursor_down()

# Key bindings

def action_append_selection(self):
Expand Down

0 comments on commit de5299c

Please sign in to comment.