From 4b74cf49e63681c0802628a21321a0b4c3d78b2a Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 14 May 2024 08:43:58 +0800 Subject: [PATCH] fix --- package.json | 3 ++- plugins/doubanrank/__init__.py | 12 ++++++++++-- plugins/iyuuautoseed/__init__.py | 12 ++++++------ plugins/tmdbwallpaper/__init__.py | 8 ++++---- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index c777572..2516d98 100644 --- a/package.json +++ b/package.json @@ -93,11 +93,12 @@ "name": "豆瓣榜单订阅", "description": "监控豆瓣热门榜单,自动添加订阅。", "labels": "订阅", - "version": "1.9", + "version": "1.9.1", "icon": "movie.jpg", "author": "jxxghp", "level": 2, "history": { + "v1.9.1": "优化媒体类型的判断处理", "v1.9": "增强API安全性", "v1.8": "订阅历史记录支持手动删除,需要主程序升级至v1.8.4+版本" } diff --git a/plugins/doubanrank/__init__.py b/plugins/doubanrank/__init__.py index 47a6c03..08af328 100644 --- a/plugins/doubanrank/__init__.py +++ b/plugins/doubanrank/__init__.py @@ -17,6 +17,7 @@ from app.core.context import MediaInfo from app.core.metainfo import MetaInfo from app.log import logger from app.plugins import _PluginBase +from app.schemas import MediaType from app.utils.dom import DomUtils from app.utils.http import RequestUtils @@ -29,7 +30,7 @@ class DoubanRank(_PluginBase): # 插件图标 plugin_icon = "movie.jpg" # 插件版本 - plugin_version = "1.9" + plugin_version = "1.9.1" # 插件作者 plugin_author = "jxxghp" # 作者主页 @@ -551,10 +552,15 @@ class DoubanRank(_PluginBase): if self._event.is_set(): logger.info(f"订阅服务停止") return - + mtype = None title = rss_info.get('title') douban_id = rss_info.get('doubanid') year = rss_info.get('year') + type_str = rss_info.get('type') + if type_str == "movie": + mtype = MediaType.MOVIE + elif type_str: + mtype = MediaType.TV unique_flag = f"doubanrank: {title} (DB:{douban_id})" # 检查是否已处理过 if unique_flag in [h.get("unique") for h in history]: @@ -562,6 +568,8 @@ class DoubanRank(_PluginBase): # 元数据 meta = MetaInfo(title) meta.year = year + if mtype: + meta.type = mtype # 识别媒体信息 if douban_id: # 识别豆瓣信息 diff --git a/plugins/iyuuautoseed/__init__.py b/plugins/iyuuautoseed/__init__.py index 54fb90d..b943c41 100644 --- a/plugins/iyuuautoseed/__init__.py +++ b/plugins/iyuuautoseed/__init__.py @@ -945,7 +945,7 @@ class IYUUAutoSeed(_PluginBase): if not apikey: logger.error("m-team站点的apikey未配置") return None - with RequestUtils( + res = RequestUtils( headers={ 'Content-Type': 'application/json', 'User-Agent': f'{site.get("ua")}', @@ -954,11 +954,11 @@ class IYUUAutoSeed(_PluginBase): } ).post_res(f"{site.get('url')}api/torrent/genDlToken", params={ 'id': tid - }) as res: - if not res: - logger.warn(f"m-team 获取种子下载链接失败:{tid}") - return None - return res.json().get("data") + }) + if not res: + logger.warn(f"m-team 获取种子下载链接失败:{tid}") + return None + return res.json().get("data") def __is_special_site(url: str): """ diff --git a/plugins/tmdbwallpaper/__init__.py b/plugins/tmdbwallpaper/__init__.py index 28dc6eb..273ae23 100644 --- a/plugins/tmdbwallpaper/__init__.py +++ b/plugins/tmdbwallpaper/__init__.py @@ -233,10 +233,10 @@ class TmdbWallpaper(_PluginBase): try: savepath = Path(self._savepath) logger.info(f"下载壁纸:{url}") - with RequestUtils().get_res(url) as r: - if r and r.status_code == 200: - with open(savepath / filename, "wb") as f: - f.write(r.content) + r = RequestUtils().get_res(url) + if r and r.status_code == 200: + with open(savepath / filename, "wb") as f: + f.write(r.content) except Exception as e: logger.error(f"下载壁纸失败:{str(e)}") else: