@@ -146,7 +146,7 @@ async def _fetch_recommendations_from_top_items(
146146 List of candidate items
147147 """
148148 # Get top items (loved first, then liked, then added, then top watched)
149- top_items = self .smart_sampler .sample_items (library_items , content_type , max_items = 10 )
149+ top_items = self .smart_sampler .sample_items (library_items , content_type , max_items = 15 )
150150
151151 candidates = []
152152 tasks = []
@@ -204,29 +204,35 @@ async def _fetch_discover_with_profile(
204204 # Discover with genres
205205 if top_genres :
206206 genre_ids = [g [0 ] for g in top_genres ]
207- tasks .append (
208- self .tmdb_service .get_discover (
209- mtype ,
210- with_genres = "|" .join (str (g ) for g in genre_ids ),
211- page = 1 ,
212- sort_by = "popularity.desc" ,
213- vote_count_gte = TOP_PICKS_MIN_VOTE_COUNT ,
214- vote_average_gte = TOP_PICKS_MIN_RATING ,
215- )
207+ tasks .extend (
208+ [
209+ self .tmdb_service .get_discover (
210+ mtype ,
211+ with_genres = "|" .join (str (g ) for g in genre_ids ),
212+ page = page ,
213+ sort_by = "popularity.asc" ,
214+ vote_count_gte = TOP_PICKS_MIN_VOTE_COUNT ,
215+ vote_average_gte = TOP_PICKS_MIN_RATING ,
216+ )
217+ for page in [1 , 2 ]
218+ ]
216219 )
217220
218221 # Discover with keywords
219222 if top_keywords :
220223 keyword_ids = [k [0 ] for k in top_keywords ]
221- tasks .append (
222- self .tmdb_service .get_discover (
223- mtype ,
224- with_keywords = "|" .join (str (k ) for k in keyword_ids ),
225- page = 1 ,
226- sort_by = "popularity.desc" ,
227- vote_count_gte = TOP_PICKS_MIN_VOTE_COUNT ,
228- vote_average_gte = TOP_PICKS_MIN_RATING ,
229- )
224+ tasks .extend (
225+ [
226+ self .tmdb_service .get_discover (
227+ mtype ,
228+ with_keywords = "|" .join (str (k ) for k in keyword_ids ),
229+ page = page ,
230+ sort_by = "popularity.asc" ,
231+ vote_count_gte = TOP_PICKS_MIN_VOTE_COUNT ,
232+ vote_average_gte = TOP_PICKS_MIN_RATING ,
233+ )
234+ for page in range (1 , 4 ) # 3 pages
235+ ]
230236 )
231237
232238 # Discover with directors
@@ -237,7 +243,7 @@ async def _fetch_discover_with_profile(
237243 mtype ,
238244 with_crew = str (director_id ),
239245 page = 1 ,
240- sort_by = "popularity.desc " ,
246+ sort_by = "popularity.asc " ,
241247 vote_count_gte = TOP_PICKS_MIN_VOTE_COUNT ,
242248 vote_average_gte = TOP_PICKS_MIN_RATING ,
243249 )
@@ -251,7 +257,7 @@ async def _fetch_discover_with_profile(
251257 mtype ,
252258 with_cast = str (cast_id ),
253259 page = 1 ,
254- sort_by = "popularity.desc " ,
260+ sort_by = "popularity.asc " ,
255261 vote_count_gte = TOP_PICKS_MIN_VOTE_COUNT ,
256262 vote_average_gte = TOP_PICKS_MIN_RATING ,
257263 )
@@ -268,7 +274,7 @@ async def _fetch_discover_with_profile(
268274 mtype ,
269275 ** {f"{ prefix } .gte" : f"{ year_start } -01-01" , f"{ prefix } .lte" : f"{ year_start + 9 } -12-31" },
270276 page = 1 ,
271- sort_by = "popularity.desc " ,
277+ sort_by = "popularity.asc " ,
272278 vote_count_gte = TOP_PICKS_MIN_VOTE_COUNT ,
273279 vote_average_gte = TOP_PICKS_MIN_RATING ,
274280 )
@@ -282,7 +288,7 @@ async def _fetch_discover_with_profile(
282288 mtype ,
283289 with_origin_country = "|" .join (country_codes ),
284290 page = 1 ,
285- sort_by = "popularity.desc " ,
291+ sort_by = "popularity.asc " ,
286292 vote_count_gte = TOP_PICKS_MIN_VOTE_COUNT ,
287293 vote_average_gte = TOP_PICKS_MIN_RATING ,
288294 )
@@ -319,11 +325,11 @@ async def _fetch_trending_and_popular(self, content_type: str, mtype: str) -> li
319325 logger .debug (f"Failed to fetch trending: { e } " )
320326
321327 # Fetch popular (top rated, 1 page)
322- try :
323- popular = await self .tmdb_service .get_top_rated (mtype , page = 1 )
324- candidates .extend (popular .get ("results" , []))
325- except Exception as e :
326- logger .debug (f"Failed to fetch popular: { e } " )
328+ # try:
329+ # popular = await self.tmdb_service.get_top_rated(mtype, page=1)
330+ # candidates.extend(popular.get("results", []))
331+ # except Exception as e:
332+ # logger.debug(f"Failed to fetch popular: {e}")
327333
328334 return candidates
329335
0 commit comments