mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 16:07:01 +08:00
fix:修复代码兼容性写法
This commit is contained in:
@@ -133,13 +133,10 @@ def find_metainfo(title: str) -> Tuple[str, dict]:
|
|||||||
# 查找媒体类型
|
# 查找媒体类型
|
||||||
mtype = re.findall(r'(?<=type=)\w+', result)
|
mtype = re.findall(r'(?<=type=)\w+', result)
|
||||||
if mtype:
|
if mtype:
|
||||||
match mtype[0]:
|
if mtype[0] == "movies":
|
||||||
case "movie":
|
metainfo['type'] = MediaType.MOVIE
|
||||||
metainfo['type'] = MediaType.MOVIE
|
elif mtype[0] == "tv":
|
||||||
case "tv":
|
metainfo['type'] = MediaType.TV
|
||||||
metainfo['type'] = MediaType.TV
|
|
||||||
case _:
|
|
||||||
pass
|
|
||||||
# 查找季信息
|
# 查找季信息
|
||||||
begin_season = re.findall(r'(?<=s=)\d+', result)
|
begin_season = re.findall(r'(?<=s=)\d+', result)
|
||||||
if begin_season and begin_season[0].isdigit():
|
if begin_season and begin_season[0].isdigit():
|
||||||
|
|||||||
@@ -150,13 +150,12 @@ class Emby:
|
|||||||
if hidden and self._sync_libraries and "all" not in self._sync_libraries \
|
if hidden and self._sync_libraries and "all" not in self._sync_libraries \
|
||||||
and library.get("Id") not in self._sync_libraries:
|
and library.get("Id") not in self._sync_libraries:
|
||||||
continue
|
continue
|
||||||
match library.get("CollectionType"):
|
if library.get("CollectionType") == "movies":
|
||||||
case "movies":
|
library_type = MediaType.MOVIE.value
|
||||||
library_type = MediaType.MOVIE.value
|
elif library.get("CollectionType") == "tvshows":
|
||||||
case "tvshows":
|
library_type = MediaType.TV.value
|
||||||
library_type = MediaType.TV.value
|
else:
|
||||||
case _:
|
library_type = MediaType.UNKNOWN.value
|
||||||
library_type = MediaType.UNKNOWN.value
|
|
||||||
image = self.__get_local_image_by_id(library.get("Id"))
|
image = self.__get_local_image_by_id(library.get("Id"))
|
||||||
libraries.append(
|
libraries.append(
|
||||||
schemas.MediaServerLibrary(
|
schemas.MediaServerLibrary(
|
||||||
@@ -419,7 +418,7 @@ class Emby:
|
|||||||
return None, {}
|
return None, {}
|
||||||
# 查集的信息
|
# 查集的信息
|
||||||
if not season:
|
if not season:
|
||||||
season = ""
|
season = None
|
||||||
try:
|
try:
|
||||||
url = f"{self._host}emby/Shows/{item_id}/Episodes"
|
url = f"{self._host}emby/Shows/{item_id}/Episodes"
|
||||||
params = {
|
params = {
|
||||||
|
|||||||
@@ -1067,38 +1067,37 @@ class FileManagerModule(_ModuleBase):
|
|||||||
if not overflag:
|
if not overflag:
|
||||||
# 目标文件已存在
|
# 目标文件已存在
|
||||||
logger.info(f"目的文件系统中已经存在同名文件 {target_file},当前整理覆盖模式设置为 {overwrite_mode}")
|
logger.info(f"目的文件系统中已经存在同名文件 {target_file},当前整理覆盖模式设置为 {overwrite_mode}")
|
||||||
match overwrite_mode:
|
if overwrite_mode == 'always':
|
||||||
case 'always':
|
# 总是覆盖同名文件
|
||||||
# 总是覆盖同名文件
|
overflag = True
|
||||||
|
elif overwrite_mode == 'size':
|
||||||
|
# 存在时大覆盖小
|
||||||
|
if target_item.size < fileitem.size:
|
||||||
|
logger.info(f"目标文件文件大小更小,将覆盖:{new_file}")
|
||||||
overflag = True
|
overflag = True
|
||||||
case 'size':
|
else:
|
||||||
# 存在时大覆盖小
|
|
||||||
if target_item.size < fileitem.size:
|
|
||||||
logger.info(f"目标文件文件大小更小,将覆盖:{new_file}")
|
|
||||||
overflag = True
|
|
||||||
else:
|
|
||||||
return TransferInfo(success=False,
|
|
||||||
message=f"媒体库存在同名文件,且质量更好",
|
|
||||||
fileitem=fileitem,
|
|
||||||
target_item=target_item,
|
|
||||||
target_diritem=target_diritem,
|
|
||||||
fail_list=[fileitem.path],
|
|
||||||
transfer_type=transfer_type,
|
|
||||||
need_notify=need_notify)
|
|
||||||
case 'never':
|
|
||||||
# 存在不覆盖
|
|
||||||
return TransferInfo(success=False,
|
return TransferInfo(success=False,
|
||||||
message=f"媒体库存在同名文件,当前覆盖模式为不覆盖",
|
message=f"媒体库存在同名文件,且质量更好",
|
||||||
fileitem=fileitem,
|
fileitem=fileitem,
|
||||||
target_item=target_item,
|
target_item=target_item,
|
||||||
target_diritem=target_diritem,
|
target_diritem=target_diritem,
|
||||||
fail_list=[fileitem.path],
|
fail_list=[fileitem.path],
|
||||||
transfer_type=transfer_type,
|
transfer_type=transfer_type,
|
||||||
need_notify=need_notify)
|
need_notify=need_notify)
|
||||||
case 'latest':
|
elif overwrite_mode == 'never':
|
||||||
# 仅保留最新版本
|
# 存在不覆盖
|
||||||
logger.info(f"当前整理覆盖模式设置为仅保留最新版本,将覆盖:{new_file}")
|
return TransferInfo(success=False,
|
||||||
overflag = True
|
message=f"媒体库存在同名文件,当前覆盖模式为不覆盖",
|
||||||
|
fileitem=fileitem,
|
||||||
|
target_item=target_item,
|
||||||
|
target_diritem=target_diritem,
|
||||||
|
fail_list=[fileitem.path],
|
||||||
|
transfer_type=transfer_type,
|
||||||
|
need_notify=need_notify)
|
||||||
|
elif overwrite_mode == 'latest':
|
||||||
|
# 仅保留最新版本
|
||||||
|
logger.info(f"当前整理覆盖模式设置为仅保留最新版本,将覆盖:{new_file}")
|
||||||
|
overflag = True
|
||||||
else:
|
else:
|
||||||
if overwrite_mode == 'latest':
|
if overwrite_mode == 'latest':
|
||||||
# 文件不存在,但仅保留最新版本
|
# 文件不存在,但仅保留最新版本
|
||||||
|
|||||||
@@ -147,19 +147,18 @@ class Jellyfin:
|
|||||||
if hidden and self._sync_libraries and "all" not in self._sync_libraries \
|
if hidden and self._sync_libraries and "all" not in self._sync_libraries \
|
||||||
and library.get("Id") not in self._sync_libraries:
|
and library.get("Id") not in self._sync_libraries:
|
||||||
continue
|
continue
|
||||||
match library.get("CollectionType"):
|
if library.get("CollectionType") == "movies":
|
||||||
case "movies":
|
library_type = MediaType.MOVIE.value
|
||||||
library_type = MediaType.MOVIE.value
|
link = f"{self._playhost or self._host}web/index.html#!" \
|
||||||
link = f"{self._playhost or self._host}web/index.html#!" \
|
f"/movies.html?topParentId={library.get('Id')}"
|
||||||
f"/movies.html?topParentId={library.get('Id')}"
|
elif library.get("CollectionType") == "tvshows":
|
||||||
case "tvshows":
|
library_type = MediaType.TV.value
|
||||||
library_type = MediaType.TV.value
|
link = f"{self._playhost or self._host}web/index.html#!" \
|
||||||
link = f"{self._playhost or self._host}web/index.html#!" \
|
f"/tv.html?topParentId={library.get('Id')}"
|
||||||
f"/tv.html?topParentId={library.get('Id')}"
|
else:
|
||||||
case _:
|
library_type = MediaType.UNKNOWN.value
|
||||||
library_type = MediaType.UNKNOWN.value
|
link = f"{self._playhost or self._host}web/index.html#!" \
|
||||||
link = f"{self._playhost or self._host}web/index.html#!" \
|
f"/library.html?topParentId={library.get('Id')}"
|
||||||
f"/library.html?topParentId={library.get('Id')}"
|
|
||||||
image = self.__get_local_image_by_id(library.get("Id"))
|
image = self.__get_local_image_by_id(library.get("Id"))
|
||||||
libraries.append(
|
libraries.append(
|
||||||
schemas.MediaServerLibrary(
|
schemas.MediaServerLibrary(
|
||||||
@@ -410,7 +409,7 @@ class Jellyfin:
|
|||||||
if str(tmdb_id) != str(item_info.tmdbid):
|
if str(tmdb_id) != str(item_info.tmdbid):
|
||||||
return None, {}
|
return None, {}
|
||||||
if not season:
|
if not season:
|
||||||
season = ""
|
season = None
|
||||||
url = f"{self._host}Shows/{item_id}/Episodes"
|
url = f"{self._host}Shows/{item_id}/Episodes"
|
||||||
params = {
|
params = {
|
||||||
"season": season,
|
"season": season,
|
||||||
|
|||||||
@@ -138,15 +138,14 @@ class Plex:
|
|||||||
if hidden and self._sync_libraries and "all" not in self._sync_libraries \
|
if hidden and self._sync_libraries and "all" not in self._sync_libraries \
|
||||||
and str(library.key) not in self._sync_libraries:
|
and str(library.key) not in self._sync_libraries:
|
||||||
continue
|
continue
|
||||||
match library.type:
|
if library.type == "movie":
|
||||||
case "movie":
|
library_type = MediaType.MOVIE.value
|
||||||
library_type = MediaType.MOVIE.value
|
image_list = self.__get_library_images(library.key, 1)
|
||||||
image_list = self.__get_library_images(library.key, 1)
|
elif library.type == "show":
|
||||||
case "show":
|
library_type = MediaType.TV.value
|
||||||
library_type = MediaType.TV.value
|
image_list = self.__get_library_images(library.key, 2)
|
||||||
image_list = self.__get_library_images(library.key, 2)
|
else:
|
||||||
case _:
|
continue
|
||||||
continue
|
|
||||||
libraries.append(
|
libraries.append(
|
||||||
schemas.MediaServerLibrary(
|
schemas.MediaServerLibrary(
|
||||||
id=library.key,
|
id=library.key,
|
||||||
|
|||||||
Reference in New Issue
Block a user