33from app .services .scoring import ScoringService
44from app .services .stremio_service import StremioService
55from app .services .tmdb_service import TMDBService
6+ from app .services .translation import translation_service
67from app .services .user_profile import UserProfileService
78
89
@@ -34,9 +35,6 @@ def build_catalog_entry(self, item, label, config_id):
3435 catalog_id = item_id
3536
3637 name = item .get ("name" )
37- # # Truncate long names for cleaner UI
38- # if len(name) > 25:
39- # name = name[:25] + "..."
4038
4139 return {
4240 "type" : self .normalize_type (item .get ("type" )),
@@ -49,6 +47,8 @@ async def get_theme_based_catalogs(
4947 self , library_items : list [dict ], user_settings : UserSettings | None = None
5048 ) -> list [dict ]:
5149 catalogs = []
50+ lang = user_settings .language if user_settings else "en-US"
51+
5252 # 1. Build User Profile
5353 # Combine loved and watched
5454 all_items = library_items .get ("loved" , []) + library_items .get ("watched" , [])
@@ -82,7 +82,8 @@ async def get_theme_based_catalogs(
8282 movie_rows = await self .row_generator .generate_rows (movie_profile , "movie" )
8383
8484 for row in movie_rows :
85- catalogs .append ({"type" : "movie" , "id" : row .id , "name" : row .title , "extra" : []})
85+ translated_title = await translation_service .translate (row .title , lang )
86+ catalogs .append ({"type" : "movie" , "id" : row .id , "name" : translated_title , "extra" : []})
8687
8788 # Generate for Series
8889 series_profile = await self .user_profile_service .build_user_profile (
@@ -91,7 +92,8 @@ async def get_theme_based_catalogs(
9192 series_rows = await self .row_generator .generate_rows (series_profile , "series" )
9293
9394 for row in series_rows :
94- catalogs .append ({"type" : "series" , "id" : row .id , "name" : row .title , "extra" : []})
95+ translated_title = await translation_service .translate (row .title , lang )
96+ catalogs .append ({"type" : "series" , "id" : row .id , "name" : translated_title , "extra" : []})
9597
9698 return catalogs
9799
@@ -101,6 +103,7 @@ async def get_dynamic_catalogs(
101103 """
102104 Generate all dynamic catalog rows.
103105 """
106+ lang = user_settings .language if user_settings else "en-US"
104107
105108 include_item_based_rows = bool (
106109 next ((c for c in user_settings .catalogs if c .id == "watchly.item" and c .enabled ), True )
@@ -116,15 +119,19 @@ async def get_dynamic_catalogs(
116119 # 3. Add Item-Based Rows
117120 if include_item_based_rows :
118121 # For Movies
119- self ._add_item_based_rows (catalogs , library_items , "movie" )
122+ await self ._add_item_based_rows (catalogs , library_items , "movie" , lang )
120123 # For Series
121- self ._add_item_based_rows (catalogs , library_items , "series" )
124+ await self ._add_item_based_rows (catalogs , library_items , "series" , lang )
122125
123126 return catalogs
124127
125- def _add_item_based_rows (self , catalogs : list , library_items : dict , content_type : str ):
128+ async def _add_item_based_rows (self , catalogs : list , library_items : dict , content_type : str , language : str ):
126129 """Helper to add 'Because you watched' and 'More like' rows."""
127130
131+ # Translate labels
132+ label_more_like = await translation_service .translate ("More like" , language )
133+ label_bc_watched = await translation_service .translate ("Because you watched" , language )
134+
128135 # Helper to parse date
129136 def get_date (item ):
130137 import datetime
@@ -152,13 +159,9 @@ def get_date(item):
152159
153160 last_loved = loved [0 ] if loved else None
154161 if last_loved :
155- catalogs .append (self .build_catalog_entry (last_loved , "More like" , "watchly.item" ))
162+ catalogs .append (self .build_catalog_entry (last_loved , label_more_like , "watchly.item" ))
156163
157164 # 2. Because you watched <Watched Item>
158- # Filter only watched items (exclude loved if possible or treat as separate pool)
159- # Actually, watched_items in StremioService include everything with progress or watched flag
160- # We want 'Because you watched' to reflect recent activity.
161-
162165 watched = [i for i in library_items .get ("watched" , []) if i .get ("type" ) == content_type ]
163166 watched .sort (key = get_date , reverse = True )
164167
@@ -170,8 +173,5 @@ def get_date(item):
170173 last_watched = item
171174 break
172175
173- # If no distinct last watched found (e.g. only watched 1 item and it was loved),
174- # we can skip or pick the next best.
175-
176176 if last_watched :
177- catalogs .append (self .build_catalog_entry (last_watched , "Because you watched" , "watchly.item" ))
177+ catalogs .append (self .build_catalog_entry (last_watched , label_bc_watched , "watchly.item" ))
0 commit comments