Merge pull request #5535 from Seed680/v2

This commit is contained in:
jxxghp
2026-03-03 20:00:31 +08:00
committed by GitHub
5 changed files with 200 additions and 74 deletions

View File

@@ -17,6 +17,7 @@ class MetaAnime(MetaBase):
"""
_anime_no_words = ['CHS&CHT', 'MP4', 'GB MP4', 'WEB-DL']
_name_nostring_re = r"S\d{2}\s*-\s*S\d{2}|S\d{2}|\s+S\d{1,2}|EP?\d{2,4}\s*-\s*EP?\d{2,4}|EP?\d{2,4}|\s+EP?\d{1,4}|\s+GB"
_fps_re = r"(\d{2,3})(?=FPS)"
def __init__(self, title: str, subtitle: str = None, isfile: bool = False):
super().__init__(title, subtitle, isfile)
@@ -173,6 +174,8 @@ class MetaAnime(MetaBase):
self.audio_encode = anitopy_info.get("audio_term")
if isinstance(self.audio_encode, list):
self.audio_encode = self.audio_encode[0]
# 帧率信息
self.__init_anime_fps(anitopy_info, original_title)
# 解析副标题,只要季和集
self.init_subtitle(self.org_string)
if not self._subtitle_flag and self.subtitle:
@@ -182,6 +185,20 @@ class MetaAnime(MetaBase):
except Exception as e:
logger.error(f"解析动漫信息失败:{str(e)} - {traceback.format_exc()}")
def __init_anime_fps(self, anitopy_info: dict, original_title: str):
"""
从原始标题中提取帧率信息与MetaVideo保持完全一致的实现
"""
re_res = re.search(rf"({self._fps_re})", original_title, re.IGNORECASE)
if re_res:
fps_value = None
if re_res.group(1): # FPS格式
fps_value = re_res.group(1)
if fps_value and fps_value.isdigit():
# 只存储纯数值
self.fps = int(fps_value)
@staticmethod
def __prepare_title(title: str):
"""

View File

@@ -66,6 +66,9 @@ class MetaBase(object):
# 附加信息
tmdbid: int = None
doubanid: str = None
# 帧率信息(纯数值)
fps: Optional[int] = None
# 副标题解析
_subtitle_flag = False
@@ -448,6 +451,13 @@ class MetaBase(object):
"""
return self.audio_encode or ""
@property
def frame_rate(self) -> int:
"""
返回帧率信息
"""
return self.fps or None
def is_in_season(self, season: Union[list, int, str]) -> bool:
"""
是否包含季
@@ -581,6 +591,9 @@ class MetaBase(object):
# 音频编码
if not self.audio_encode:
self.audio_encode = meta.audio_encode
# 帧率信息
if not self.fps:
self.fps = meta.fps
# Part
if not self.part:
self.part = meta.part

View File

@@ -53,7 +53,7 @@ class MetaVideo(MetaBase):
_resources_pix_re2 = r"(^[248]+K)"
_video_encode_re = r"^(H26[45])$|^(x26[45])$|^AVC$|^HEVC$|^VC\d?$|^MPEG\d?$|^Xvid$|^DivX$|^AV1$|^HDR\d*$|^AVS(\+|[23])$"
_audio_encode_re = r"^DTS\d?$|^DTSHD$|^DTSHDMA$|^Atmos$|^TrueHD\d?$|^AC3$|^\dAudios?$|^DDP\d?$|^DD\+\d?$|^DD\d?$|^LPCM\d?$|^AAC\d?$|^FLAC\d?$|^HD\d?$|^MA\d?$|^HR\d?$|^Opus\d?$|^Vorbis\d?$|^AV[3S]A$"
_fps_re = r"(\d{2,3})(?=FPS)"
def __init__(self, title: str, subtitle: str = None, isfile: bool = False):
"""
初始化
@@ -129,6 +129,9 @@ class MetaVideo(MetaBase):
# 音频编码
if self._continue_flag:
self.__init_audio_encode(token)
# 帧率
if self._continue_flag:
self.__init_fps(token)
# 取下一个,直到没有为卡
token = tokens.get_next()
self._continue_flag = True
@@ -716,3 +719,25 @@ class MetaVideo(MetaBase):
else:
self.audio_encode = "%s %s" % (self.audio_encode, token)
self._last_token = token
def __init_fps(self, token: str):
"""
识别帧率
"""
if not self.name:
return
re_res = re.search(rf"({self._fps_re})", token, re.IGNORECASE)
if re_res:
self._continue_flag = False
self._stop_name_flag = True
self._last_token_type = "fps"
# 提取帧率数值
fps_value = None
if re_res.group(1): # FPS格式
fps_value = re_res.group(1)
if fps_value and fps_value.isdigit():
# 只存储纯数值
self.fps = int(fps_value)
self._last_token = f"{self.fps}FPS"