From db72fd2ef50c5f39123dd5add54e84e3ffff2e99 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 21 Aug 2025 09:07:28 +0800 Subject: [PATCH] fix --- app/api/endpoints/torrent.py | 4 ++-- app/chain/transfer.py | 14 +++++++------- app/core/context.py | 4 ++-- app/helper/plugin.py | 23 +++++++++++++---------- app/modules/emby/__init__.py | 10 ++++------ app/modules/emby/emby.py | 2 +- app/modules/themoviedb/category.py | 2 +- app/modules/themoviedb/tmdbapi.py | 4 ++-- 8 files changed, 32 insertions(+), 31 deletions(-) diff --git a/app/api/endpoints/torrent.py b/app/api/endpoints/torrent.py index 84945ada..78d9fa45 100644 --- a/app/api/endpoints/torrent.py +++ b/app/api/endpoints/torrent.py @@ -135,8 +135,8 @@ def refresh_cache(_: User = Depends(get_current_active_superuser)): @router.post("/cache/reidentify/{domain}/{torrent_hash}", summary="重新识别种子", response_model=schemas.Response) async def reidentify_cache(domain: str, torrent_hash: str, - tmdbid: Optional[int] = None, doubanid: Optional[str] = None, - _: User = Depends(get_current_active_superuser_async)): + tmdbid: Optional[int] = None, doubanid: Optional[str] = None, + _: User = Depends(get_current_active_superuser_async)): """ 重新识别指定的种子 :param domain: 站点域名 diff --git a/app/chain/transfer.py b/app/chain/transfer.py index 80753879..280a575a 100755 --- a/app/chain/transfer.py +++ b/app/chain/transfer.py @@ -501,7 +501,8 @@ class TransferChain(ChainBase, metaclass=Singleton): # 获取整理屏蔽词 transfer_exclude_words = SystemConfigOper().get(SystemConfigKey.TransferExcludeWords) for t in tasks: - if t.download_hash and self._can_delete_torrent(t.download_hash, t.downloader, transfer_exclude_words): + if t.download_hash and self._can_delete_torrent(t.download_hash, t.downloader, + transfer_exclude_words): if self.remove_torrents(t.download_hash, downloader=t.downloader): logger.info(f"移动模式删除种子成功:{t.download_hash}") if t.fileitem: @@ -1435,7 +1436,6 @@ class TransferChain(ChainBase, metaclass=Singleton): return True return False - def _can_delete_torrent(self, download_hash: str, downloader: str, transfer_exclude_words) -> bool: """ 检查是否可以删除种子文件 @@ -1468,11 +1468,11 @@ class TransferChain(ChainBase, metaclass=Singleton): file_path = save_path / file.name # 如果存在未被屏蔽的媒体文件,则不删除种子 if ( - file_path.suffix in self.all_exts - and not self._is_blocked_by_exclude_words( - str(file_path), transfer_exclude_words - ) - and file_path.exists() + file_path.suffix in self.all_exts + and not self._is_blocked_by_exclude_words( + str(file_path), transfer_exclude_words + ) + and file_path.exists() ): return False diff --git a/app/core/context.py b/app/core/context.py index 9beaff55..c0b1c84c 100644 --- a/app/core/context.py +++ b/app/core/context.py @@ -483,7 +483,7 @@ class MediaInfo: continue if current_value is None: setattr(self, key, value) - elif type(current_value) == type(value): + elif type(current_value) is type(value): setattr(self, key, value) def set_douban_info(self, info: dict): @@ -624,7 +624,7 @@ class MediaInfo: continue if current_value is None: setattr(self, key, value) - elif type(current_value) == type(value): + elif type(current_value) is type(value): setattr(self, key, value) def set_bangumi_info(self, info: dict): diff --git a/app/helper/plugin.py b/app/helper/plugin.py index 6f9455f1..baae7e5e 100644 --- a/app/helper/plugin.py +++ b/app/helper/plugin.py @@ -1,13 +1,13 @@ import importlib +import io import json import shutil import site import sys import traceback +import zipfile from pathlib import Path from typing import Dict, List, Optional, Tuple, Set, Callable, Awaitable -import zipfile -import io import aiofiles import aioshutil @@ -248,6 +248,7 @@ class PluginHelper(metaclass=WeakSingleton): return False, f"未在插件清单中找到 {pid} 的版本号,无法进行 Release 安装" # 拼接 release_tag release_tag = f"{pid}_v{plugin_version}" + # 使用 release 进行安装 def prepare_release() -> Tuple[bool, str]: return self.__install_from_release( @@ -533,12 +534,12 @@ class PluginHelper(metaclass=WeakSingleton): return None def __get_plugin_meta(self, pid: str, repo_url: str, - package_version: Optional[str]) -> dict: + package_version: Optional[str]) -> dict: try: plugins = ( - self.get_plugins(repo_url) if not package_version - else self.get_plugins(repo_url, package_version) - ) or {} + self.get_plugins(repo_url) if not package_version + else self.get_plugins(repo_url, package_version) + ) or {} meta = plugins.get(pid) return meta if isinstance(meta, dict) else {} except Exception as e: @@ -1393,6 +1394,7 @@ class PluginHelper(metaclass=WeakSingleton): return False, f"未在插件清单中找到 {pid} 的版本号,无法进行 Release 安装" # 拼接 release_tag release_tag = f"{pid}_v{plugin_version}" + # 使用 release 进行安装 async def prepare_release() -> Tuple[bool, str]: return await self.__async_install_from_release( @@ -1411,9 +1413,9 @@ class PluginHelper(metaclass=WeakSingleton): package_version: Optional[str]) -> dict: try: plugins = ( - await self.async_get_plugins(repo_url) if not package_version - else await self.async_get_plugins(repo_url, package_version) - ) or {} + await self.async_get_plugins(repo_url) if not package_version + else await self.async_get_plugins(repo_url, package_version) + ) or {} meta = plugins.get(pid) return meta if isinstance(meta, dict) else {} except Exception as e: @@ -1528,7 +1530,8 @@ class PluginHelper(metaclass=WeakSingleton): logger.error(f"解析 Release 信息失败:{e}") return False, f"解析 Release 信息失败:{e}" - res = await self.__async_request_with_fallback(download_url, headers=settings.REPO_GITHUB_HEADERS(repo=user_repo)) + res = await self.__async_request_with_fallback(download_url, + headers=settings.REPO_GITHUB_HEADERS(repo=user_repo)) if res is None or res.status_code != 200: return False, f"下载资产失败:{res.status_code if res else '连接失败'}" diff --git a/app/modules/emby/__init__.py b/app/modules/emby/__init__.py index 4884afca..47b44608 100644 --- a/app/modules/emby/__init__.py +++ b/app/modules/emby/__init__.py @@ -282,9 +282,8 @@ class EmbyModule(_ModuleBase, _MediaServerBase[Emby]): episodes=episodes ) for season, episodes in seasoninfo.items()] - def mediaserver_playing(self, server: str, - count: Optional[int] = 20, username: Optional[str] = None) -> List[ - schemas.MediaServerPlayItem]: + def mediaserver_playing(self, server: str, count: Optional[int] = 20, + username: Optional[str] = None) -> List[schemas.MediaServerPlayItem]: """ 获取媒体服务器正在播放信息 """ @@ -302,9 +301,8 @@ class EmbyModule(_ModuleBase, _MediaServerBase[Emby]): return None return server_obj.get_play_url(item_id) - def mediaserver_latest(self, server: Optional[str] = None, - count: Optional[int] = 20, username: Optional[str] = None) -> List[ - schemas.MediaServerPlayItem]: + def mediaserver_latest(self, server: Optional[str] = None, count: Optional[int] = 20, + username: Optional[str] = None) -> List[schemas.MediaServerPlayItem]: """ 获取媒体服务器最新入库条目 """ diff --git a/app/modules/emby/emby.py b/app/modules/emby/emby.py index c84d4984..a15e425d 100644 --- a/app/modules/emby/emby.py +++ b/app/modules/emby/emby.py @@ -167,7 +167,7 @@ class Emby: image=image, link=f'{self._playhost or self._host}web/index.html' f'#!/videos?serverId={self.serverid}&parentId={library.get("Id")}', - server_type= "emby" + server_type="emby" ) ) return libraries diff --git a/app/modules/themoviedb/category.py b/app/modules/themoviedb/category.py index a1066e4b..7c8aa35f 100644 --- a/app/modules/themoviedb/category.py +++ b/app/modules/themoviedb/category.py @@ -127,7 +127,7 @@ class CategoryHelper(metaclass=WeakSingleton): continue elif attr == "production_countries": # 制片国家 - info_values = [str(val.get("iso_3166_1")).upper() for val in info_value] # type: ignore + info_values = [str(val.get("iso_3166_1")).upper() for val in info_value] # type: ignore else: if isinstance(info_value, list): info_values = [str(val).upper() for val in info_value] diff --git a/app/modules/themoviedb/tmdbapi.py b/app/modules/themoviedb/tmdbapi.py index 66d23011..9830edca 100644 --- a/app/modules/themoviedb/tmdbapi.py +++ b/app/modules/themoviedb/tmdbapi.py @@ -402,7 +402,8 @@ class TmdbApi: if match: try: return int(match.group(1)) - except Exception: + except Exception as err: + logger.debug(f"解析TMDBID失败:{str(err)} - {traceback.format_exc()}") return None return None @@ -832,7 +833,6 @@ class TmdbApi: return None # dict[地区:分级] ratings = {} - results = [] if results := (tmdb_info.get("release_dates") or {}).get("results"): """ [