Add planning to shows and movies in one merged grid
This commit is contained in:
1 parent
cd9a8a186a
commit
d473aebb79
9 files changed
+56
-41
No files matched your search
@@ -6,7 +6,8 @@ MEDIA_KINDS = {
|
||||
"show": {"key": "shows", "label": "TV show", "omdb_type": "series"},
|
||||
"movie": {"key": "movies", "label": "movie", "omdb_type": "movie"},
|
||||
}
|
||||
STATUSES = ["watched", "watching"]
|
||||
STATUSES = ["watched", "watching", "planning"]
|
||||
STATUS_ORDER = {"watching": 0, "watched": 1, "planning": 2}
|
||||
|
||||
|
||||
def check_rating(rating: int | None) -> int | None:
|
||||
@@ -33,7 +34,7 @@ def status_of(item: dict) -> str:
|
||||
def list_items(kind: str) -> list[dict]:
|
||||
_, items = load_items(kind)
|
||||
rating = lambda item: item["rating"] if item.get("rating") is not None else -1
|
||||
return sorted(items, key=lambda item: (status_of(item) != "watching", -rating(item)))
|
||||
return sorted(items, key=lambda item: (STATUS_ORDER[status_of(item)], -rating(item)))
|
||||
|
||||
|
||||
def collection_names(kind: str) -> list[str]:
|
||||
|
||||
@@ -8,7 +8,7 @@ import media
|
||||
from tui.content_pane import ContentPane
|
||||
from tui.dialogs import ConfirmDialog, FormDialog, FormField
|
||||
|
||||
STATUS_STYLES = {"watching": "blue", "watched": "green"}
|
||||
STATUS_STYLES = {"watching": "blue", "watched": "green", "planning": "magenta"}
|
||||
|
||||
|
||||
def rating_text(item: dict) -> str:
|
||||
@@ -19,7 +19,7 @@ class MediaPane(ContentPane):
|
||||
BINDINGS = [
|
||||
Binding("a", "add", "Add"),
|
||||
Binding("e", "rate", "Rate"),
|
||||
Binding("s", "status", "Watching"),
|
||||
Binding("s", "status", "Status"),
|
||||
Binding("g", "collection", "Group"),
|
||||
Binding("d", "delete", "Delete"),
|
||||
Binding("r", "reload", "Reload"),
|
||||
@@ -113,8 +113,14 @@ class MediaPane(ContentPane):
|
||||
if not item:
|
||||
return
|
||||
identifier = imdb.imdb_id(item["url"])
|
||||
next_status = "watched" if media.status_of(item) == "watching" else "watching"
|
||||
self.run_now(lambda: media.set_status(self.kind, identifier, next_status), f"{item['name']} is now {next_status}", identifier)
|
||||
fields = [FormField("status", f"Status for {item['name']}", kind="select", options=media.STATUSES, value=media.status_of(item))]
|
||||
|
||||
def changed(values: dict | None):
|
||||
if values:
|
||||
status = values["status"]
|
||||
self.run_now(lambda: media.set_status(self.kind, identifier, status), f"{item['name']} is now {status}", identifier)
|
||||
|
||||
self.app.push_screen(FormDialog("Change status", fields, "Save"), changed)
|
||||
|
||||
def action_collection(self):
|
||||
item = self.selected_item()
|
||||
|
||||
Reference in new issue
Block a user