fix bugs
This commit is contained in:
@ -6,7 +6,7 @@ from ruamel.yaml import CommentedMap
|
||||
|
||||
from app.core.context import MediaInfo, TorrentInfo, Context
|
||||
from app.core.meta import MetaBase
|
||||
from app.utils.types import TorrentStatus
|
||||
from app.utils.types import TorrentStatus, MediaType
|
||||
|
||||
|
||||
class _ModuleBase(metaclass=ABCMeta):
|
||||
@ -41,10 +41,12 @@ class _ModuleBase(metaclass=ABCMeta):
|
||||
pass
|
||||
|
||||
def recognize_media(self, meta: MetaBase,
|
||||
tmdbid: str = None) -> Optional[MediaInfo]:
|
||||
mtype: MediaType = None,
|
||||
tmdbid: int = None) -> Optional[MediaInfo]:
|
||||
"""
|
||||
识别媒体信息
|
||||
:param meta: 识别的元数据
|
||||
:param mtype: 媒体类型,与tmdbid配套
|
||||
:param tmdbid: tmdbid
|
||||
:return: 识别的媒体信息,包括剧集信息
|
||||
"""
|
||||
|
@ -232,7 +232,7 @@ class Emby(metaclass=Singleton):
|
||||
def get_tv_episodes(self,
|
||||
title: str = None,
|
||||
year: str = None,
|
||||
tmdb_id: str = None,
|
||||
tmdb_id: int = None,
|
||||
season: int = None) -> Optional[Dict[int, list]]:
|
||||
"""
|
||||
根据标题和年份和季,返回Emby中的剧集列表
|
||||
|
@ -207,7 +207,7 @@ class Jellyfin(metaclass=Singleton):
|
||||
def get_tv_episodes(self,
|
||||
title: str = None,
|
||||
year: str = None,
|
||||
tmdb_id: str = None,
|
||||
tmdb_id: int = None,
|
||||
season: int = None) -> Optional[Dict[str, list]]:
|
||||
"""
|
||||
根据标题和年份和季,返回Jellyfin中的剧集列表
|
||||
|
@ -133,12 +133,13 @@ class Telegram(metaclass=Singleton):
|
||||
index, caption = 1, "*%s*" % title
|
||||
for context in torrents:
|
||||
torrent = context.torrent_info
|
||||
site_name = torrent.site_name
|
||||
link = torrent.page_url
|
||||
title = torrent.title
|
||||
free = torrent.get_volume_factor_string()
|
||||
seeder = f"{torrent.seeders}↑"
|
||||
description = torrent.description
|
||||
caption = f"{caption}\n{index}. [{title}]({link}) {free} {seeder}\n{description}"
|
||||
caption = f"{caption}\n{index}. 【{site_name}】[{title}]({link}) {free} {seeder}\n_{description}_"
|
||||
index += 1
|
||||
|
||||
if userid:
|
||||
|
@ -42,21 +42,23 @@ class TheMovieDb(_ModuleBase):
|
||||
pass
|
||||
|
||||
def recognize_media(self, meta: MetaBase,
|
||||
tmdbid: str = None) -> Optional[MediaInfo]:
|
||||
mtype: MediaType = None,
|
||||
tmdbid: int = None) -> Optional[MediaInfo]:
|
||||
"""
|
||||
识别媒体信息
|
||||
:param meta: 识别的元数据
|
||||
:param mtype: 识别的媒体类型,与tmdbid配套
|
||||
:param tmdbid: tmdbid
|
||||
:return: 识别的媒体信息,包括剧集信息
|
||||
"""
|
||||
if not meta:
|
||||
return None
|
||||
cache_info = self.cache.get(meta)
|
||||
if not cache_info:
|
||||
if not cache_info or cache_info.get('id') == 0:
|
||||
# 缓存没有或者强制不使用缓存
|
||||
if tmdbid:
|
||||
# 直接查询详情
|
||||
info = self.tmdb.get_info(mtype=meta.type, tmdbid=tmdbid)
|
||||
info = self.tmdb.get_info(mtype=mtype, tmdbid=tmdbid)
|
||||
else:
|
||||
if meta.type != MediaType.TV and not meta.year:
|
||||
info = self.tmdb.search_multi(meta.get_name())
|
||||
|
@ -1,3 +1,4 @@
|
||||
import traceback
|
||||
from functools import lru_cache
|
||||
from typing import Optional, Tuple, List
|
||||
|
||||
@ -114,7 +115,7 @@ class TmdbHelper:
|
||||
return True
|
||||
return False
|
||||
|
||||
def __get_names(self, mtype: MediaType, tmdb_id: str) -> Tuple[Optional[dict], List[str]]:
|
||||
def __get_names(self, mtype: MediaType, tmdb_id: int) -> Tuple[Optional[dict], List[str]]:
|
||||
"""
|
||||
搜索tmdb中所有的标题和译名,用于名称匹配
|
||||
:param mtype: 类型:电影、电视剧、动漫
|
||||
@ -230,7 +231,8 @@ class TmdbHelper:
|
||||
logger.error(f"连接TMDB出错:{err}")
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.error(f"连接TMDB出错:{str(e)}")
|
||||
logger.error(f"连接TMDB出错:{e}")
|
||||
print(traceback.print_exc())
|
||||
return None
|
||||
logger.debug(f"API返回:{str(self.search.total_results)}")
|
||||
if len(movies) == 0:
|
||||
@ -289,7 +291,8 @@ class TmdbHelper:
|
||||
logger.error(f"连接TMDB出错:{err}")
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.error(f"连接TMDB出错:{str(e)}")
|
||||
logger.error(f"连接TMDB出错:{e}")
|
||||
print(traceback.print_exc())
|
||||
return None
|
||||
logger.debug(f"API返回:{str(self.search.total_results)}")
|
||||
if len(tvs) == 0:
|
||||
@ -346,13 +349,14 @@ class TmdbHelper:
|
||||
return False
|
||||
try:
|
||||
seasons = self.__get_tv_seasons(tv_info)
|
||||
for season, season_info in seasons.values():
|
||||
for season, season_info in seasons.items():
|
||||
if season_info.get("air_date"):
|
||||
if season.get("air_date")[0:4] == str(_season_year) \
|
||||
and season == int(season_number):
|
||||
return True
|
||||
except Exception as e1:
|
||||
logger.error(f"连接TMDB出错:{e1}")
|
||||
print(traceback.print_exc())
|
||||
return False
|
||||
return False
|
||||
|
||||
@ -363,6 +367,7 @@ class TmdbHelper:
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.error(f"连接TMDB出错:{e}")
|
||||
print(traceback.print_exc())
|
||||
return None
|
||||
|
||||
if len(tvs) == 0:
|
||||
@ -433,7 +438,8 @@ class TmdbHelper:
|
||||
logger.error(f"连接TMDB出错:{err}")
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.error(f"连接TMDB出错:{str(e)}")
|
||||
logger.error(f"连接TMDB出错:{e}")
|
||||
print(traceback.print_exc())
|
||||
return None
|
||||
logger.debug(f"API返回:{str(self.search.total_results)}")
|
||||
if len(multis) == 0:
|
||||
@ -529,7 +535,7 @@ class TmdbHelper:
|
||||
|
||||
def get_info(self,
|
||||
mtype: MediaType,
|
||||
tmdbid: str) -> dict:
|
||||
tmdbid: int) -> dict:
|
||||
"""
|
||||
给定TMDB号,查询一条媒体信息
|
||||
:param mtype: 类型:电影、电视剧、动漫,为空时都查(此时用不上年份)
|
||||
@ -602,7 +608,7 @@ class TmdbHelper:
|
||||
tmdb_info['name'] = cn_title
|
||||
|
||||
def __get_movie_detail(self,
|
||||
tmdbid: str,
|
||||
tmdbid: int,
|
||||
append_to_response: str = "images,"
|
||||
"credits,"
|
||||
"alternative_titles,"
|
||||
@ -714,7 +720,7 @@ class TmdbHelper:
|
||||
return None
|
||||
|
||||
def __get_tv_detail(self,
|
||||
tmdbid: str,
|
||||
tmdbid: int,
|
||||
append_to_response: str = "images,"
|
||||
"credits,"
|
||||
"alternative_titles,"
|
||||
@ -896,7 +902,7 @@ class TmdbHelper:
|
||||
print(str(e))
|
||||
return None
|
||||
|
||||
def get_tv_season_detail(self, tmdbid, season: int):
|
||||
def get_tv_season_detail(self, tmdbid: int, season: int):
|
||||
"""
|
||||
获取电视剧季的详情
|
||||
:param tmdbid: TMDB ID
|
||||
@ -970,7 +976,7 @@ class TmdbHelper:
|
||||
print(str(e))
|
||||
return {}
|
||||
|
||||
def get_tv_episode_detail(self, tmdbid: str, season: int, episode: int):
|
||||
def get_tv_episode_detail(self, tmdbid: int, season: int, episode: int):
|
||||
"""
|
||||
获取电视剧集的详情
|
||||
:param tmdbid: TMDB ID
|
||||
|
@ -75,12 +75,12 @@ class TmdbCache(metaclass=Singleton):
|
||||
with lock:
|
||||
return self._meta_data.pop(key, None)
|
||||
|
||||
def delete_by_tmdbid(self, tmdbid: str) -> None:
|
||||
def delete_by_tmdbid(self, tmdbid: int) -> None:
|
||||
"""
|
||||
清空对应TMDBID的所有缓存记录,以强制更新TMDB中最新的数据
|
||||
"""
|
||||
for key in list(self._meta_data):
|
||||
if str(self._meta_data.get(key, {}).get("id")) == str(tmdbid):
|
||||
if self._meta_data.get(key, {}).get("id") == tmdbid:
|
||||
with lock:
|
||||
self._meta_data.pop(key)
|
||||
|
||||
@ -89,7 +89,7 @@ class TmdbCache(metaclass=Singleton):
|
||||
清除未识别的缓存记录,以便重新搜索TMDB
|
||||
"""
|
||||
for key in list(self._meta_data):
|
||||
if str(self._meta_data.get(key, {}).get("id")) == '0':
|
||||
if self._meta_data.get(key, {}).get("id") == 0:
|
||||
with lock:
|
||||
self._meta_data.pop(key)
|
||||
|
||||
|
Reference in New Issue
Block a user