From 79411a735086e57eaef7f279b2133a1f24494b5b Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sun, 23 Mar 2025 09:00:24 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=85=BC=E5=AE=B9=E6=80=A7=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/metainfo.py | 11 +++---- app/modules/emby/emby.py | 15 +++++---- app/modules/filemanager/__init__.py | 47 ++++++++++++++--------------- app/modules/jellyfin/jellyfin.py | 27 ++++++++--------- app/modules/plex/plex.py | 17 +++++------ 5 files changed, 55 insertions(+), 62 deletions(-) diff --git a/app/core/metainfo.py b/app/core/metainfo.py index e4bb66dc..fc8c9c99 100644 --- a/app/core/metainfo.py +++ b/app/core/metainfo.py @@ -133,13 +133,10 @@ def find_metainfo(title: str) -> Tuple[str, dict]: # 查找媒体类型 mtype = re.findall(r'(?<=type=)\w+', result) if mtype: - match mtype[0]: - case "movie": - metainfo['type'] = MediaType.MOVIE - case "tv": - metainfo['type'] = MediaType.TV - case _: - pass + if mtype[0] == "movies": + metainfo['type'] = MediaType.MOVIE + elif mtype[0] == "tv": + metainfo['type'] = MediaType.TV # 查找季信息 begin_season = re.findall(r'(?<=s=)\d+', result) if begin_season and begin_season[0].isdigit(): diff --git a/app/modules/emby/emby.py b/app/modules/emby/emby.py index ad6f3152..4b1e836d 100644 --- a/app/modules/emby/emby.py +++ b/app/modules/emby/emby.py @@ -150,13 +150,12 @@ class Emby: if hidden and self._sync_libraries and "all" not in self._sync_libraries \ and library.get("Id") not in self._sync_libraries: continue - match library.get("CollectionType"): - case "movies": - library_type = MediaType.MOVIE.value - case "tvshows": - library_type = MediaType.TV.value - case _: - library_type = MediaType.UNKNOWN.value + if library.get("CollectionType") == "movies": + library_type = MediaType.MOVIE.value + elif library.get("CollectionType") == "tvshows": + library_type = MediaType.TV.value + else: + library_type = MediaType.UNKNOWN.value image = self.__get_local_image_by_id(library.get("Id")) libraries.append( schemas.MediaServerLibrary( @@ -419,7 +418,7 @@ class Emby: return None, {} # 查集的信息 if not season: - season = "" + season = None try: url = f"{self._host}emby/Shows/{item_id}/Episodes" params = { diff --git a/app/modules/filemanager/__init__.py b/app/modules/filemanager/__init__.py index fb309c96..34409f5e 100644 --- a/app/modules/filemanager/__init__.py +++ b/app/modules/filemanager/__init__.py @@ -1067,38 +1067,37 @@ class FileManagerModule(_ModuleBase): if not overflag: # 目标文件已存在 logger.info(f"目的文件系统中已经存在同名文件 {target_file},当前整理覆盖模式设置为 {overwrite_mode}") - match overwrite_mode: - case 'always': - # 总是覆盖同名文件 + if overwrite_mode == 'always': + # 总是覆盖同名文件 + overflag = True + elif overwrite_mode == 'size': + # 存在时大覆盖小 + if target_item.size < fileitem.size: + logger.info(f"目标文件文件大小更小,将覆盖:{new_file}") overflag = True - case 'size': - # 存在时大覆盖小 - 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': - # 存在不覆盖 + else: return TransferInfo(success=False, - message=f"媒体库存在同名文件,当前覆盖模式为不覆盖", + 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 'latest': - # 仅保留最新版本 - logger.info(f"当前整理覆盖模式设置为仅保留最新版本,将覆盖:{new_file}") - overflag = True + elif overwrite_mode == 'never': + # 存在不覆盖 + 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) + elif overwrite_mode == 'latest': + # 仅保留最新版本 + logger.info(f"当前整理覆盖模式设置为仅保留最新版本,将覆盖:{new_file}") + overflag = True else: if overwrite_mode == 'latest': # 文件不存在,但仅保留最新版本 diff --git a/app/modules/jellyfin/jellyfin.py b/app/modules/jellyfin/jellyfin.py index 3dc68494..4d66cbe6 100644 --- a/app/modules/jellyfin/jellyfin.py +++ b/app/modules/jellyfin/jellyfin.py @@ -147,19 +147,18 @@ class Jellyfin: if hidden and self._sync_libraries and "all" not in self._sync_libraries \ and library.get("Id") not in self._sync_libraries: continue - match library.get("CollectionType"): - case "movies": - library_type = MediaType.MOVIE.value - link = f"{self._playhost or self._host}web/index.html#!" \ - f"/movies.html?topParentId={library.get('Id')}" - case "tvshows": - library_type = MediaType.TV.value - link = f"{self._playhost or self._host}web/index.html#!" \ - f"/tv.html?topParentId={library.get('Id')}" - case _: - library_type = MediaType.UNKNOWN.value - link = f"{self._playhost or self._host}web/index.html#!" \ - f"/library.html?topParentId={library.get('Id')}" + if library.get("CollectionType") == "movies": + library_type = MediaType.MOVIE.value + link = f"{self._playhost or self._host}web/index.html#!" \ + f"/movies.html?topParentId={library.get('Id')}" + elif library.get("CollectionType") == "tvshows": + library_type = MediaType.TV.value + link = f"{self._playhost or self._host}web/index.html#!" \ + f"/tv.html?topParentId={library.get('Id')}" + else: + library_type = MediaType.UNKNOWN.value + link = f"{self._playhost or self._host}web/index.html#!" \ + f"/library.html?topParentId={library.get('Id')}" image = self.__get_local_image_by_id(library.get("Id")) libraries.append( schemas.MediaServerLibrary( @@ -410,7 +409,7 @@ class Jellyfin: if str(tmdb_id) != str(item_info.tmdbid): return None, {} if not season: - season = "" + season = None url = f"{self._host}Shows/{item_id}/Episodes" params = { "season": season, diff --git a/app/modules/plex/plex.py b/app/modules/plex/plex.py index 6009d0cf..86b50085 100644 --- a/app/modules/plex/plex.py +++ b/app/modules/plex/plex.py @@ -138,15 +138,14 @@ class Plex: if hidden and self._sync_libraries and "all" not in self._sync_libraries \ and str(library.key) not in self._sync_libraries: continue - match library.type: - case "movie": - library_type = MediaType.MOVIE.value - image_list = self.__get_library_images(library.key, 1) - case "show": - library_type = MediaType.TV.value - image_list = self.__get_library_images(library.key, 2) - case _: - continue + if library.type == "movie": + library_type = MediaType.MOVIE.value + image_list = self.__get_library_images(library.key, 1) + elif library.type == "show": + library_type = MediaType.TV.value + image_list = self.__get_library_images(library.key, 2) + else: + continue libraries.append( schemas.MediaServerLibrary( id=library.key,