diff --git a/app/chain/__init__.py b/app/chain/__init__.py index f0b3df66..7c38a3c6 100644 --- a/app/chain/__init__.py +++ b/app/chain/__init__.py @@ -101,7 +101,7 @@ def is_result_empty(ret): try: module_name = module.get_name() except Exception as err: - logger.error(f"获取模块名称出错:{str(err)}") + logger.debug(f"获取模块名称出错:{str(err)}") module_name = module_id try: func = getattr(module, method) diff --git a/app/chain/tmdb.py b/app/chain/tmdb.py index 13c05b1e..d57c7cf3 100644 --- a/app/chain/tmdb.py +++ b/app/chain/tmdb.py @@ -127,11 +127,11 @@ def get_random_wallpager(self) -> Optional[str]: return None @cached(cache=TTLCache(maxsize=1, ttl=3600)) - def get_trending_wallpapers(self, num: int = 10) -> Optional[List[str]]: + def get_trending_wallpapers(self, num: int = 10) -> List[str]: """ 获取所有流行壁纸 """ infos = self.tmdb_trending() if infos: return [info.backdrop_path for info in infos if info and info.backdrop_path][:num] - return None + return [] diff --git a/app/modules/themoviedb/tmdbapi.py b/app/modules/themoviedb/tmdbapi.py index 1fe129d3..02cf1651 100644 --- a/app/modules/themoviedb/tmdbapi.py +++ b/app/modules/themoviedb/tmdbapi.py @@ -770,7 +770,7 @@ def __get_movie_detail(self, logger.debug(f"{tmdbid} 查询结果:{tmdbinfo.get('title')}") return tmdbinfo or {} except Exception as e: - print(str(e)) + logger.error(str(e)) return None def __get_tv_detail(self, @@ -953,7 +953,7 @@ def __get_tv_detail(self, logger.debug(f"{tmdbid} 查询结果:{tmdbinfo.get('name')}") return tmdbinfo or {} except Exception as e: - print(str(e)) + logger.error(str(e)) return None def get_tv_season_detail(self, tmdbid: int, season: int): @@ -1027,7 +1027,7 @@ def get_tv_season_detail(self, tmdbid: int, season: int): tmdbinfo = self.season.details(tv_id=tmdbid, season_num=season) return tmdbinfo or {} except Exception as e: - print(str(e)) + logger.error(str(e)) return {} def get_tv_episode_detail(self, tmdbid: int, season: int, episode: int) -> dict: @@ -1044,7 +1044,7 @@ def get_tv_episode_detail(self, tmdbid: int, season: int, episode: int) -> dict: tmdbinfo = self.episode.details(tv_id=tmdbid, season_num=season, episode_num=episode) return tmdbinfo or {} except Exception as e: - print(str(e)) + logger.error(str(e)) return {} def discover_movies(self, **kwargs) -> List[dict]: @@ -1064,7 +1064,7 @@ def discover_movies(self, **kwargs) -> List[dict]: info['media_type'] = MediaType.MOVIE return tmdbinfo or [] except Exception as e: - print(str(e)) + logger.error(str(e)) return [] def discover_tvs(self, **kwargs) -> List[dict]: @@ -1084,7 +1084,7 @@ def discover_tvs(self, **kwargs) -> List[dict]: info['media_type'] = MediaType.TV return tmdbinfo or [] except Exception as e: - print(str(e)) + logger.error(str(e)) return [] def discover_trending(self, page: int = 1) -> List[dict]: @@ -1097,7 +1097,7 @@ def discover_trending(self, page: int = 1) -> List[dict]: logger.debug(f"正在获取流行趋势:page={page} ...") return self.trending.all_week(page=page) except Exception as e: - print(str(e)) + logger.error(str(e)) return [] def get_movie_images(self, tmdbid: int) -> dict: @@ -1110,7 +1110,7 @@ def get_movie_images(self, tmdbid: int) -> dict: logger.debug(f"正在获取电影图片:{tmdbid}...") return self.movie.images(movie_id=tmdbid) or {} except Exception as e: - print(str(e)) + logger.error(str(e)) return {} def get_tv_images(self, tmdbid: int) -> dict: @@ -1123,7 +1123,7 @@ def get_tv_images(self, tmdbid: int) -> dict: logger.debug(f"正在获取电视剧图片:{tmdbid}...") return self.tv.images(tv_id=tmdbid) or {} except Exception as e: - print(str(e)) + logger.error(str(e)) return {} def get_movie_similar(self, tmdbid: int) -> List[dict]: @@ -1136,7 +1136,7 @@ def get_movie_similar(self, tmdbid: int) -> List[dict]: logger.debug(f"正在获取相似电影:{tmdbid}...") return self.movie.similar(movie_id=tmdbid) or [] except Exception as e: - print(str(e)) + logger.error(str(e)) return [] def get_tv_similar(self, tmdbid: int) -> List[dict]: @@ -1149,7 +1149,7 @@ def get_tv_similar(self, tmdbid: int) -> List[dict]: logger.debug(f"正在获取相似电视剧:{tmdbid}...") return self.tv.similar(tv_id=tmdbid) or [] except Exception as e: - print(str(e)) + logger.error(str(e)) return [] def get_movie_recommend(self, tmdbid: int) -> List[dict]: @@ -1162,7 +1162,7 @@ def get_movie_recommend(self, tmdbid: int) -> List[dict]: logger.debug(f"正在获取推荐电影:{tmdbid}...") return self.movie.recommendations(movie_id=tmdbid) or [] except Exception as e: - print(str(e)) + logger.error(str(e)) return [] def get_tv_recommend(self, tmdbid: int) -> List[dict]: @@ -1175,7 +1175,7 @@ def get_tv_recommend(self, tmdbid: int) -> List[dict]: logger.debug(f"正在获取推荐电视剧:{tmdbid}...") return self.tv.recommendations(tv_id=tmdbid) or [] except Exception as e: - print(str(e)) + logger.error(str(e)) return [] def get_movie_credits(self, tmdbid: int, page: int = 1, count: int = 24) -> List[dict]: @@ -1192,7 +1192,7 @@ def get_movie_credits(self, tmdbid: int, page: int = 1, count: int = 24) -> List return cast[(page - 1) * count: page * count] return [] except Exception as e: - print(str(e)) + logger.error(str(e)) return [] def get_tv_credits(self, tmdbid: int, page: int = 1, count: int = 24) -> List[dict]: @@ -1209,7 +1209,7 @@ def get_tv_credits(self, tmdbid: int, page: int = 1, count: int = 24) -> List[di return cast[(page - 1) * count: page * count] return [] except Exception as e: - print(str(e)) + logger.error(str(e)) return [] def get_person_detail(self, person_id: int) -> dict: @@ -1242,7 +1242,7 @@ def get_person_detail(self, person_id: int) -> dict: logger.debug(f"正在获取人物详情:{person_id}...") return self.person.details(person_id=person_id) or {} except Exception as e: - print(str(e)) + logger.error(str(e)) return {} def get_person_credits(self, person_id: int, page: int = 1, count: int = 24) -> List[dict]: @@ -1263,7 +1263,7 @@ def get_person_credits(self, person_id: int, page: int = 1, count: int = 24) -> return cast[(page - 1) * count: page * count] return [] except Exception as e: - print(str(e)) + logger.error(str(e)) return [] def clear_cache(self): @@ -1301,7 +1301,7 @@ def get_tv_episode_years(self, tv_id: int) -> dict: episode_years[order] = str(first_date).split("-")[0] return episode_years except Exception as e: - print(str(e)) + logger.error(str(e)) return {} def close(self): diff --git a/app/utils/web.py b/app/utils/web.py index 43340ab2..6145adb7 100644 --- a/app/utils/web.py +++ b/app/utils/web.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Optional, List from cachetools import TTLCache, cached @@ -94,7 +94,7 @@ def get_bing_wallpaper() -> Optional[str]: @staticmethod @cached(cache=TTLCache(maxsize=1, ttl=3600)) - def get_bing_wallpapers(num: int = 7) -> Optional[str]: + def get_bing_wallpapers(num: int = 7) -> List[str]: """ 获取7天的Bing每日壁纸 """ @@ -107,4 +107,4 @@ def get_bing_wallpapers(num: int = 7) -> Optional[str]: return [f"https://cn.bing.com{image.get('url')}" for image in result.get('images') or []] except Exception as err: print(str(err)) - return None + return []