Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Oct 12, 2024
1 parent 0d13985 commit 4e3a76f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/chain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions app/chain/tmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
36 changes: 18 additions & 18 deletions app/modules/themoviedb/tmdbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand All @@ -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]:
Expand All @@ -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]:
Expand All @@ -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]:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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]:
Expand All @@ -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]:
Expand All @@ -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]:
Expand All @@ -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]:
Expand All @@ -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]:
Expand All @@ -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]:
Expand All @@ -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:
Expand Down Expand Up @@ -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]:
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions app/utils/web.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import Optional, List

from cachetools import TTLCache, cached

Expand Down Expand Up @@ -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每日壁纸
"""
Expand All @@ -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 []

0 comments on commit 4e3a76f

Please sign in to comment.