-
-
Notifications
You must be signed in to change notification settings - Fork 10
feat: add option to rename, enable disable catalogs #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d73d27d
75a856d
2931074
2953eac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| __version__ = "1.0.0-rc.4" | ||
| __version__ = "1.0.0-rc.5" |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||
| from app.core.settings import UserSettings | ||||||
| from app.core.settings import CatalogConfig, UserSettings | ||||||
| from app.services.row_generator import RowGeneratorService | ||||||
| from app.services.scoring import ScoringService | ||||||
| from app.services.stremio_service import StremioService | ||||||
|
|
@@ -26,7 +26,7 @@ def normalize_type(type_): | |||||
| def build_catalog_entry(self, item, label, config_id): | ||||||
| item_id = item.get("_id", "") | ||||||
| # Use watchly.{config_id}.{item_id} format for better organization | ||||||
| if config_id == "watchly.item": | ||||||
| if config_id in ["watchly.item", "watchly.loved", "watchly.watched"]: | ||||||
| # New Item-based catalog format | ||||||
| catalog_id = f"{config_id}.{item_id}" | ||||||
| elif item_id.startswith("tt") and config_id in ["watchly.loved", "watchly.watched"]: | ||||||
|
|
@@ -103,35 +103,38 @@ async def get_dynamic_catalogs( | |||||
| """ | ||||||
| Generate all dynamic catalog rows. | ||||||
| """ | ||||||
| lang = user_settings.language if user_settings else "en-US" | ||||||
|
|
||||||
| include_item_based_rows = bool( | ||||||
| next((c for c in user_settings.catalogs if c.id == "watchly.item" and c.enabled), True) | ||||||
| ) | ||||||
| include_theme_based_rows = bool( | ||||||
| next((c for c in user_settings.catalogs if c.id == "watchly.theme" and c.enabled), True) | ||||||
| ) | ||||||
| catalogs = [] | ||||||
| lang = user_settings.language if user_settings else "en-US" | ||||||
|
|
||||||
| if include_theme_based_rows: | ||||||
| # Theme Based | ||||||
| theme_config = next((c for c in user_settings.catalogs if c.id == "watchly.theme"), None) | ||||||
| if not theme_config or theme_config.enabled: | ||||||
| catalogs.extend(await self.get_theme_based_catalogs(library_items, user_settings)) | ||||||
|
|
||||||
| # 3. Add Item-Based Rows | ||||||
| if include_item_based_rows: | ||||||
| # For Movies | ||||||
| await self._add_item_based_rows(catalogs, library_items, "movie", lang) | ||||||
| # For Series | ||||||
| await self._add_item_based_rows(catalogs, library_items, "series", lang) | ||||||
| # Item Based (Loved/Watched) | ||||||
| loved_config = next((c for c in user_settings.catalogs if c.id == "watchly.loved"), None) | ||||||
| watched_config = next((c for c in user_settings.catalogs if c.id == "watchly.watched"), None) | ||||||
|
|
||||||
| # Fallback for old settings (watchly.item) | ||||||
| if not loved_config and not watched_config: | ||||||
| old_config = next((c for c in user_settings.catalogs if c.id == "watchly.item"), None) | ||||||
| if old_config and old_config.enabled: | ||||||
| # Create temporary configs | ||||||
| loved_config = CatalogConfig(id="watchly.loved", name=None, enabled=True) | ||||||
| watched_config = CatalogConfig(id="watchly.watched", name=None, enabled=True) | ||||||
|
|
||||||
| # Movies | ||||||
| await self._add_item_based_rows(catalogs, library_items, "movie", lang, loved_config, watched_config) | ||||||
| # Series | ||||||
| await self._add_item_based_rows(catalogs, library_items, "series", lang, loved_config, watched_config) | ||||||
|
|
||||||
| return catalogs | ||||||
|
|
||||||
| async def _add_item_based_rows(self, catalogs: list, library_items: dict, content_type: str, language: str): | ||||||
| async def _add_item_based_rows( | ||||||
| self, catalogs: list, library_items: dict, content_type: str, language: str, loved_config, watched_config | ||||||
| ): | ||||||
| """Helper to add 'Because you watched' and 'More like' rows.""" | ||||||
|
|
||||||
| # Translate labels | ||||||
| label_more_like = await translation_service.translate("More like", language) | ||||||
| label_bc_watched = await translation_service.translate("Because you watched", language) | ||||||
|
|
||||||
| # Helper to parse date | ||||||
| def get_date(item): | ||||||
| import datetime | ||||||
|
|
@@ -154,24 +157,35 @@ def get_date(item): | |||||
| return datetime.datetime.min.replace(tzinfo=datetime.UTC) | ||||||
|
|
||||||
| # 1. More Like <Loved Item> | ||||||
| loved = [i for i in library_items.get("loved", []) if i.get("type") == content_type] | ||||||
| loved.sort(key=get_date, reverse=True) | ||||||
| last_loved = None # Initialize for the watched check | ||||||
| if loved_config and loved_config.enabled: | ||||||
| loved = [i for i in library_items.get("loved", []) if i.get("type") == content_type] | ||||||
| loved.sort(key=get_date, reverse=True) | ||||||
|
|
||||||
| last_loved = loved[0] if loved else None | ||||||
| if last_loved: | ||||||
| label = loved_config.name | ||||||
| if not label or label == "More like what you loved": # Default | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default catalog name "More like what you loved" is hardcoded here and in other files (e.g.,
Suggested change
|
||||||
| label = await translation_service.translate("More like what you loved", language) | ||||||
|
|
||||||
| last_loved = loved[0] if loved else None | ||||||
| if last_loved: | ||||||
| catalogs.append(self.build_catalog_entry(last_loved, label_more_like, "watchly.item")) | ||||||
| catalogs.append(self.build_catalog_entry(last_loved, label, "watchly.loved")) | ||||||
|
|
||||||
| # 2. Because you watched <Watched Item> | ||||||
| watched = [i for i in library_items.get("watched", []) if i.get("type") == content_type] | ||||||
| watched.sort(key=get_date, reverse=True) | ||||||
|
|
||||||
| last_watched = None | ||||||
| for item in watched: | ||||||
| # Avoid duplicate row if it's the same item as 'More like' | ||||||
| if last_loved and item.get("_id") == last_loved.get("_id"): | ||||||
| continue | ||||||
| last_watched = item | ||||||
| break | ||||||
|
|
||||||
| if last_watched: | ||||||
| catalogs.append(self.build_catalog_entry(last_watched, label_bc_watched, "watchly.item")) | ||||||
| if watched_config and watched_config.enabled: | ||||||
| watched = [i for i in library_items.get("watched", []) if i.get("type") == content_type] | ||||||
| watched.sort(key=get_date, reverse=True) | ||||||
|
|
||||||
| last_watched = None | ||||||
| for item in watched: | ||||||
| # Avoid duplicate row if it's the same item as 'More like' | ||||||
| if last_loved and item.get("_id") == last_loved.get("_id"): | ||||||
| continue | ||||||
| last_watched = item | ||||||
| break | ||||||
|
|
||||||
| if last_watched: | ||||||
| label = watched_config.name | ||||||
| if not label or label == "Because you watched": | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the 'loved' catalog, the default name "Because you watched" is hardcoded. This should also be defined as a constant in a central location to avoid inconsistencies and make future updates easier.
Suggested change
|
||||||
| label = await translation_service.translate("Because you watched", language) | ||||||
|
|
||||||
| catalogs.append(self.build_catalog_entry(last_watched, label, "watchly.watched")) | ||||||
Uh oh!
There was an error while loading. Please reload this page.