fix 文件多层路径识别

This commit is contained in:
jxxghp 2024-04-12 12:04:42 +08:00
parent f17890b6ce
commit 4e22293cda
4 changed files with 24 additions and 8 deletions

View File

@ -550,13 +550,13 @@ class MetaBase(object):
self.year = meta.year
# 季
if (self.type == MediaType.TV
and not self.season):
and not self.begin_season):
self.begin_season = meta.begin_season
self.end_season = meta.end_season
self.total_season = meta.total_season
# 开始集
if (self.type == MediaType.TV
and not self.episode):
and not self.begin_episode):
self.begin_episode = meta.begin_episode
self.end_episode = meta.end_episode
self.total_episode = meta.total_episode

View File

@ -61,7 +61,7 @@ def MetaInfoPath(path: Path) -> MetaBase:
:param path: 路径
"""
# 文件元数据,不包含后缀
file_meta = MetaInfo(title=path.stem)
file_meta = MetaInfo(title=path.name)
# 上级目录元数据
dir_meta = MetaInfo(title=path.parent.name)
# 合并元数据

View File

@ -1022,4 +1022,19 @@ meta_cases = [{
"video_codec": "H265",
"audio_codec": "DDP 2.0"
}
}, {
"path": "/volume1/电视剧/西部世界 第二季 (2016)/5.mkv",
"target": {
"type": "电视剧",
"cn_name": "西部世界",
"en_name": "",
"year": "2016",
"part": "",
"season": "S02",
"episode": "E05",
"restype": "",
"pix": "",
"video_codec": "",
"audio_codec": ""
}
}]

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from pathlib import Path
from unittest import TestCase
from app.core.metainfo import MetaInfo
from app.core.metainfo import MetaInfo, MetaInfoPath
from tests.cases.meta import meta_cases
@ -15,8 +15,9 @@ class MetaInfoTest(TestCase):
def test_metainfo(self):
for info in meta_cases:
if not info.get("title"):
continue
if info.get("path"):
meta_info = MetaInfoPath(path=Path(info.get("path")))
else:
meta_info = MetaInfo(title=info.get("title"), subtitle=info.get("subtitle"))
target = {
"type": meta_info.type.value,