@@ -175,6 +175,19 @@ def __sign(cls, url: str, ts: str, method='GET') -> str:
175175 ).decode ()
176176
177177 @cached (cache = TTLCache (maxsize = settings .CACHE_CONF ["douban" ], ttl = settings .CACHE_CONF ["meta" ]))
178+ def __invoke_recommend (self , url : str , ** kwargs ) -> dict :
179+ """
180+ 推荐/发现类API
181+ """
182+ return self .__invoke (url , ** kwargs )
183+
184+ @cached (cache = TTLCache (maxsize = settings .CACHE_CONF ["douban" ], ttl = settings .CACHE_CONF ["meta" ]))
185+ def __invoke_search (self , url : str , ** kwargs ) -> dict :
186+ """
187+ 搜索类API
188+ """
189+ return self .__invoke (url , ** kwargs )
190+
178191 def __invoke (self , url : str , ** kwargs ) -> dict :
179192 """
180193 GET请求
@@ -244,189 +257,189 @@ def search(self, keyword: str, start: int = 0, count: int = 20,
244257 """
245258 关键字搜索
246259 """
247- return self .__invoke (self ._urls ["search" ], q = keyword ,
248- start = start , count = count , _ts = ts )
260+ return self .__invoke_search (self ._urls ["search" ], q = keyword ,
261+ start = start , count = count , _ts = ts )
249262
250263 def movie_search (self , keyword : str , start : int = 0 , count : int = 20 ,
251264 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
252265 """
253266 电影搜索
254267 """
255- return self .__invoke (self ._urls ["movie_search" ], q = keyword ,
256- start = start , count = count , _ts = ts )
268+ return self .__invoke_search (self ._urls ["movie_search" ], q = keyword ,
269+ start = start , count = count , _ts = ts )
257270
258271 def tv_search (self , keyword : str , start : int = 0 , count : int = 20 ,
259272 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
260273 """
261274 电视搜索
262275 """
263- return self .__invoke (self ._urls ["tv_search" ], q = keyword ,
264- start = start , count = count , _ts = ts )
276+ return self .__invoke_search (self ._urls ["tv_search" ], q = keyword ,
277+ start = start , count = count , _ts = ts )
265278
266279 def book_search (self , keyword : str , start : int = 0 , count : int = 20 ,
267280 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
268281 """
269282 书籍搜索
270283 """
271- return self .__invoke (self ._urls ["book_search" ], q = keyword ,
272- start = start , count = count , _ts = ts )
284+ return self .__invoke_search (self ._urls ["book_search" ], q = keyword ,
285+ start = start , count = count , _ts = ts )
273286
274287 def group_search (self , keyword : str , start : int = 0 , count : int = 20 ,
275288 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
276289 """
277290 小组搜索
278291 """
279- return self .__invoke (self ._urls ["group_search" ], q = keyword ,
280- start = start , count = count , _ts = ts )
292+ return self .__invoke_search (self ._urls ["group_search" ], q = keyword ,
293+ start = start , count = count , _ts = ts )
281294
282295 def person_search (self , keyword : str , start : int = 0 , count : int = 20 ,
283296 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
284297 """
285298 人物搜索
286299 """
287- return self .__invoke (self ._urls ["search_subject" ], type = "person" , q = keyword ,
288- start = start , count = count , _ts = ts )
300+ return self .__invoke_search (self ._urls ["search_subject" ], type = "person" , q = keyword ,
301+ start = start , count = count , _ts = ts )
289302
290303 def movie_showing (self , start : int = 0 , count : int = 20 ,
291304 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
292305 """
293306 正在热映
294307 """
295- return self .__invoke (self ._urls ["movie_showing" ],
296- start = start , count = count , _ts = ts )
308+ return self .__invoke_recommend (self ._urls ["movie_showing" ],
309+ start = start , count = count , _ts = ts )
297310
298311 def movie_soon (self , start : int = 0 , count : int = 20 ,
299312 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
300313 """
301314 即将上映
302315 """
303- return self .__invoke (self ._urls ["movie_soon" ],
304- start = start , count = count , _ts = ts )
316+ return self .__invoke_recommend (self ._urls ["movie_soon" ],
317+ start = start , count = count , _ts = ts )
305318
306319 def movie_hot_gaia (self , start : int = 0 , count : int = 20 ,
307320 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
308321 """
309322 热门电影
310323 """
311- return self .__invoke (self ._urls ["movie_hot_gaia" ],
312- start = start , count = count , _ts = ts )
324+ return self .__invoke_recommend (self ._urls ["movie_hot_gaia" ],
325+ start = start , count = count , _ts = ts )
313326
314327 def tv_hot (self , start : int = 0 , count : int = 20 ,
315328 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
316329 """
317330 热门剧集
318331 """
319- return self .__invoke (self ._urls ["tv_hot" ],
320- start = start , count = count , _ts = ts )
332+ return self .__invoke_recommend (self ._urls ["tv_hot" ],
333+ start = start , count = count , _ts = ts )
321334
322335 def tv_animation (self , start : int = 0 , count : int = 20 ,
323336 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
324337 """
325338 动画
326339 """
327- return self .__invoke (self ._urls ["tv_animation" ],
328- start = start , count = count , _ts = ts )
340+ return self .__invoke_recommend (self ._urls ["tv_animation" ],
341+ start = start , count = count , _ts = ts )
329342
330343 def tv_variety_show (self , start : int = 0 , count : int = 20 ,
331344 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
332345 """
333346 综艺
334347 """
335- return self .__invoke (self ._urls ["tv_variety_show" ],
336- start = start , count = count , _ts = ts )
348+ return self .__invoke_recommend (self ._urls ["tv_variety_show" ],
349+ start = start , count = count , _ts = ts )
337350
338351 def tv_rank_list (self , start : int = 0 , count : int = 20 ,
339352 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
340353 """
341354 电视剧排行榜
342355 """
343- return self .__invoke (self ._urls ["tv_rank_list" ],
344- start = start , count = count , _ts = ts )
356+ return self .__invoke_recommend (self ._urls ["tv_rank_list" ],
357+ start = start , count = count , _ts = ts )
345358
346359 def show_hot (self , start : int = 0 , count : int = 20 ,
347360 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
348361 """
349362 综艺热门
350363 """
351- return self .__invoke (self ._urls ["show_hot" ],
352- start = start , count = count , _ts = ts )
364+ return self .__invoke_recommend (self ._urls ["show_hot" ],
365+ start = start , count = count , _ts = ts )
353366
354367 def movie_detail (self , subject_id : str ):
355368 """
356369 电影详情
357370 """
358- return self .__invoke (self ._urls ["movie_detail" ] + subject_id )
371+ return self .__invoke_search (self ._urls ["movie_detail" ] + subject_id )
359372
360373 def movie_celebrities (self , subject_id : str ):
361374 """
362375 电影演职员
363376 """
364- return self .__invoke (self ._urls ["movie_celebrities" ] % subject_id )
377+ return self .__invoke_search (self ._urls ["movie_celebrities" ] % subject_id )
365378
366379 def tv_detail (self , subject_id : str ):
367380 """
368381 电视剧详情
369382 """
370- return self .__invoke (self ._urls ["tv_detail" ] + subject_id )
383+ return self .__invoke_search (self ._urls ["tv_detail" ] + subject_id )
371384
372385 def tv_celebrities (self , subject_id : str ):
373386 """
374387 电视剧演职员
375388 """
376- return self .__invoke (self ._urls ["tv_celebrities" ] % subject_id )
389+ return self .__invoke_search (self ._urls ["tv_celebrities" ] % subject_id )
377390
378391 def book_detail (self , subject_id : str ):
379392 """
380393 书籍详情
381394 """
382- return self .__invoke (self ._urls ["book_detail" ] + subject_id )
395+ return self .__invoke_search (self ._urls ["book_detail" ] + subject_id )
383396
384397 def movie_top250 (self , start : int = 0 , count : int = 20 ,
385398 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
386399 """
387400 电影TOP250
388401 """
389- return self .__invoke (self ._urls ["movie_top250" ],
390- start = start , count = count , _ts = ts )
402+ return self .__invoke_recommend (self ._urls ["movie_top250" ],
403+ start = start , count = count , _ts = ts )
391404
392405 def movie_recommend (self , tags = '' , sort = 'R' , start : int = 0 , count : int = 20 ,
393406 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
394407 """
395408 电影探索
396409 """
397- return self .__invoke (self ._urls ["movie_recommend" ], tags = tags , sort = sort ,
398- start = start , count = count , _ts = ts )
410+ return self .__invoke_recommend (self ._urls ["movie_recommend" ], tags = tags , sort = sort ,
411+ start = start , count = count , _ts = ts )
399412
400413 def tv_recommend (self , tags = '' , sort = 'R' , start : int = 0 , count : int = 20 ,
401414 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
402415 """
403416 电视剧探索
404417 """
405- return self .__invoke (self ._urls ["tv_recommend" ], tags = tags , sort = sort ,
406- start = start , count = count , _ts = ts )
418+ return self .__invoke_recommend (self ._urls ["tv_recommend" ], tags = tags , sort = sort ,
419+ start = start , count = count , _ts = ts )
407420
408421 def tv_chinese_best_weekly (self , start : int = 0 , count : int = 20 ,
409422 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
410423 """
411424 华语口碑周榜
412425 """
413- return self .__invoke (self ._urls ["tv_chinese_best_weekly" ],
414- start = start , count = count , _ts = ts )
426+ return self .__invoke_recommend (self ._urls ["tv_chinese_best_weekly" ],
427+ start = start , count = count , _ts = ts )
415428
416429 def tv_global_best_weekly (self , start : int = 0 , count : int = 20 ,
417430 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
418431 """
419432 全球口碑周榜
420433 """
421- return self .__invoke (self ._urls ["tv_global_best_weekly" ],
422- start = start , count = count , _ts = ts )
434+ return self .__invoke_recommend (self ._urls ["tv_global_best_weekly" ],
435+ start = start , count = count , _ts = ts )
423436
424437 def doulist_detail (self , subject_id : str ):
425438 """
426439 豆列详情
427440 :param subject_id: 豆列id
428441 """
429- return self .__invoke (self ._urls ["doulist" ] + subject_id )
442+ return self .__invoke_search (self ._urls ["doulist" ] + subject_id )
430443
431444 def doulist_items (self , subject_id : str , start : int = 0 , count : int = 20 ,
432445 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
@@ -437,8 +450,8 @@ def doulist_items(self, subject_id: str, start: int = 0, count: int = 20,
437450 :param count: 数量
438451 :param ts: 时间戳
439452 """
440- return self .__invoke (self ._urls ["doulist_items" ] % subject_id ,
441- start = start , count = count , _ts = ts )
453+ return self .__invoke_search (self ._urls ["doulist_items" ] % subject_id ,
454+ start = start , count = count , _ts = ts )
442455
443456 def movie_recommendations (self , subject_id : str , start : int = 0 , count : int = 20 ,
444457 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
@@ -449,8 +462,8 @@ def movie_recommendations(self, subject_id: str, start: int = 0, count: int = 20
449462 :param count: 数量
450463 :param ts: 时间戳
451464 """
452- return self .__invoke (self ._urls ["movie_recommendations" ] % subject_id ,
453- start = start , count = count , _ts = ts )
465+ return self .__invoke_recommend (self ._urls ["movie_recommendations" ] % subject_id ,
466+ start = start , count = count , _ts = ts )
454467
455468 def tv_recommendations (self , subject_id : str , start : int = 0 , count : int = 20 ,
456469 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
@@ -461,8 +474,8 @@ def tv_recommendations(self, subject_id: str, start: int = 0, count: int = 20,
461474 :param count: 数量
462475 :param ts: 时间戳
463476 """
464- return self .__invoke (self ._urls ["tv_recommendations" ] % subject_id ,
465- start = start , count = count , _ts = ts )
477+ return self .__invoke_recommend (self ._urls ["tv_recommendations" ] % subject_id ,
478+ start = start , count = count , _ts = ts )
466479
467480 def movie_photos (self , subject_id : str , start : int = 0 , count : int = 20 ,
468481 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
@@ -473,8 +486,8 @@ def movie_photos(self, subject_id: str, start: int = 0, count: int = 20,
473486 :param count: 数量
474487 :param ts: 时间戳
475488 """
476- return self .__invoke (self ._urls ["movie_photos" ] % subject_id ,
477- start = start , count = count , _ts = ts )
489+ return self .__invoke_search (self ._urls ["movie_photos" ] % subject_id ,
490+ start = start , count = count , _ts = ts )
478491
479492 def tv_photos (self , subject_id : str , start : int = 0 , count : int = 20 ,
480493 ts = datetime .strftime (datetime .now (), '%Y%m%d' )):
@@ -485,16 +498,16 @@ def tv_photos(self, subject_id: str, start: int = 0, count: int = 20,
485498 :param count: 数量
486499 :param ts: 时间戳
487500 """
488- return self .__invoke (self ._urls ["tv_photos" ] % subject_id ,
489- start = start , count = count , _ts = ts )
501+ return self .__invoke_search (self ._urls ["tv_photos" ] % subject_id ,
502+ start = start , count = count , _ts = ts )
490503
491504 def person_detail (self , subject_id : int ):
492505 """
493506 用户详情
494507 :param subject_id: 人物 id
495508 :return:
496509 """
497- return self .__invoke (self ._urls ["person_detail" ] + str (subject_id ))
510+ return self .__invoke_search (self ._urls ["person_detail" ] + str (subject_id ))
498511
499512 def person_work (self , subject_id : int , start : int = 0 , count : int = 20 , sort_by : str = "time" ,
500513 collection_title : str = "影视" ,
@@ -509,14 +522,16 @@ def person_work(self, subject_id: int, start: int = 0, count: int = 20, sort_by:
509522 :param ts: 时间戳
510523 :return:
511524 """
512- return self .__invoke (self ._urls ["person_work" ] % subject_id , sortby = sort_by , collection_title = collection_title ,
513- start = start , count = count , _ts = ts )
525+ return self .__invoke_search (self ._urls ["person_work" ] % subject_id , sortby = sort_by ,
526+ collection_title = collection_title ,
527+ start = start , count = count , _ts = ts )
514528
515529 def clear_cache (self ):
516530 """
517531 清空LRU缓存
518532 """
519- self .__invoke .cache_clear ()
533+ # 尚未支持缓存清理
534+ pass
520535
521536 def close (self ):
522537 if self ._session :
0 commit comments