From cde4db1a5603147e35cf553a941b185e2a0ded10 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 6 Dec 2024 15:55:56 +0800 Subject: [PATCH] v2.1.2 --- app/api/endpoints/system.py | 4 +++- app/chain/media.py | 4 ++-- app/chain/transfer.py | 15 ++++++++------- app/db/models/downloadhistory.py | 4 +++- app/db/models/siteuserdata.py | 2 +- app/helper/directory.py | 1 - app/modules/indexer/spider/yema.py | 2 +- version.py | 4 ++-- 8 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/api/endpoints/system.py b/app/api/endpoints/system.py index a7e1ddb3..0254fa0a 100644 --- a/app/api/endpoints/system.py +++ b/app/api/endpoints/system.py @@ -387,7 +387,9 @@ def ruletest(title: str, return schemas.Response(success=False, message=f"过滤规则组 {rulegroup_name} 不存在!") # 根据标题查询媒体信息 - media_info =SearchChain().recognize_media(MetaInfo(title=title, subtitle=subtitle)) + media_info = SearchChain().recognize_media(MetaInfo(title=title, subtitle=subtitle)) + if not media_info: + return schemas.Response(success=False, message="未识别到媒体信息!") # 过滤 result = SearchChain().filter_torrents(rule_groups=[rulegroup.name], diff --git a/app/chain/media.py b/app/chain/media.py index 49305367..e61f84c1 100644 --- a/app/chain/media.py +++ b/app/chain/media.py @@ -564,7 +564,7 @@ class MediaChain(ChainBase, metaclass=Singleton): logger.info(f"当前刮削季为:{season_meta.begin_season},跳过文件:{image_path}") continue if not overwrite and self.storagechain.get_file_item(storage=fileitem.storage, - path=image_path): + path=image_path): logger.info(f"已存在图片文件:{image_path}") continue # 下载图片 @@ -574,7 +574,7 @@ class MediaChain(ChainBase, metaclass=Singleton): if not parent: parent = self.storagechain.get_parent_item(fileitem) __save_file(_fileitem=parent, _path=image_path, _content=content) - + # 判断当前目录是不是剧集根目录 if not season_meta.season: # 是否已存在 diff --git a/app/chain/transfer.py b/app/chain/transfer.py index fe8d5b4e..9fde40a0 100644 --- a/app/chain/transfer.py +++ b/app/chain/transfer.py @@ -392,23 +392,24 @@ class TransferChain(ChainBase): download_hash = download_file.download_hash # 查询整理目标目录 + dir_info = None if not target_directory: if src_match: # 按源目录匹配,以便找到更合适的目录配置 dir_info = self.directoryhelper.get_dir(media=file_mediainfo, - storage=file_item.storage, - src_path=file_path, - target_storage=target_storage) + storage=file_item.storage, + src_path=file_path, + target_storage=target_storage) elif target_path: # 指定目标路径,`手动整理`场景下使用,忽略源目录匹配,使用指定目录匹配 dir_info = self.directoryhelper.get_dir(media=file_mediainfo, - dest_path=target_path, - target_storage=target_storage) + dest_path=target_path, + target_storage=target_storage) else: # 未指定目标路径,根据媒体信息获取目标目录 dir_info = self.directoryhelper.get_dir(file_mediainfo, - storage=file_item.storage, - target_storage=target_storage) + storage=file_item.storage, + target_storage=target_storage) # 执行整理 transferinfo: TransferInfo = self.transfer(fileitem=file_item, diff --git a/app/db/models/downloadhistory.py b/app/db/models/downloadhistory.py index e97d16dd..cc58dfc7 100644 --- a/app/db/models/downloadhistory.py +++ b/app/db/models/downloadhistory.py @@ -53,7 +53,9 @@ class DownloadHistory(Base): @staticmethod @db_query def get_by_hash(db: Session, download_hash: str): - return db.query(DownloadHistory).filter(DownloadHistory.download_hash == download_hash).last() + return db.query(DownloadHistory).filter(DownloadHistory.download_hash == download_hash).order_by( + DownloadHistory.date.desc() + ).first() @staticmethod @db_query diff --git a/app/db/models/siteuserdata.py b/app/db/models/siteuserdata.py index 67595835..ac6b2c80 100644 --- a/app/db/models/siteuserdata.py +++ b/app/db/models/siteuserdata.py @@ -81,7 +81,7 @@ class SiteUserData(Base): func.max(SiteUserData.updated_day).label('latest_update_day') ) .group_by(SiteUserData.domain) - .filter(SiteUserData.err_msg == None) + .filter(SiteUserData.err_msg is None) .subquery() ) diff --git a/app/helper/directory.py b/app/helper/directory.py index 04946c5e..22c8afd3 100644 --- a/app/helper/directory.py +++ b/app/helper/directory.py @@ -59,7 +59,6 @@ class DirectoryHelper: :param include_unsorted: 包含不整理目录 :param storage: 源存储类型 :param target_storage: 目标存储类型 - :param fileitem: 文件项,使用文件路径匹配 :param src_path: 源目录,有值时直接匹配 :param dest_path: 目标目录,有值时直接匹配 """ diff --git a/app/modules/indexer/spider/yema.py b/app/modules/indexer/spider/yema.py index c33c06e2..8454425e 100644 --- a/app/modules/indexer/spider/yema.py +++ b/app/modules/indexer/spider/yema.py @@ -97,7 +97,7 @@ class YemaSpider: results = res.json().get('data', []) or [] for result in results: category_value = result.get('categoryId') - if category_value in self._tv_category : + if category_value in self._tv_category: category = MediaType.TV.value elif category_value in self._movie_category: category = MediaType.MOVIE.value diff --git a/version.py b/version.py index b40a3018..10ba1d92 100644 --- a/version.py +++ b/version.py @@ -1,2 +1,2 @@ -APP_VERSION = 'v2.1.1' -FRONTEND_VERSION = 'v2.1.1' +APP_VERSION = 'v2.1.2' +FRONTEND_VERSION = 'v2.1.2'