From a902b79684f89544c07c582c3bd30bdc79561cdc Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 12 Oct 2023 17:07:26 +0800 Subject: [PATCH 01/12] fix #800 --- app/modules/filter/__init__.py | 7 ++++++- app/plugins/chinesesubfinder/__init__.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/modules/filter/__init__.py b/app/modules/filter/__init__.py index 0626a60f..8dffe8ea 100644 --- a/app/modules/filter/__init__.py +++ b/app/modules/filter/__init__.py @@ -103,7 +103,12 @@ class FilterModule(_ModuleBase): "CNVOI": { "include": [r'[国國][语語]配音|[国國]配|[国國][语語]'], "exclude": [] - } + }, + # 60FPS + "60FPS": { + "include": [r'60fps'], + "exclude": [] + }, } def init_module(self) -> None: diff --git a/app/plugins/chinesesubfinder/__init__.py b/app/plugins/chinesesubfinder/__init__.py index d55e3ddf..f6bf3c73 100644 --- a/app/plugins/chinesesubfinder/__init__.py +++ b/app/plugins/chinesesubfinder/__init__.py @@ -251,6 +251,6 @@ class ChineseSubFinder(_PluginBase): else: logger.info("ChineseSubFinder任务添加成功:%s" % job_id) else: - logger.error("%s 目录缺失nfo元数据" % file_path) + logger.warn(f"ChineseSubFinder调用出错:{res.status_code} - {res.reason}") except Exception as e: logger.error("连接ChineseSubFinder出错:" + str(e)) From 5f44f07515cc5c50711fded460b71937114c35b1 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 12 Oct 2023 17:51:20 +0800 Subject: [PATCH 02/12] fixme --- app/chain/__init__.py | 8 +- app/modules/douban/__init__.py | 15 ++- app/modules/douban/apiv2.py | 175 ++++++++++++++++++++++++----- app/plugins/personmeta/__init__.py | 1 + 4 files changed, 160 insertions(+), 39 deletions(-) diff --git a/app/chain/__init__.py b/app/chain/__init__.py index 7c3c9f3f..fafba887 100644 --- a/app/chain/__init__.py +++ b/app/chain/__init__.py @@ -115,16 +115,18 @@ class ChainBase(metaclass=ABCMeta): """ return self.run_module("recognize_media", meta=meta, mtype=mtype, tmdbid=tmdbid) - def match_doubaninfo(self, name: str, mtype: str = None, - year: str = None, season: int = None) -> Optional[dict]: + def match_doubaninfo(self, name: str, imdbid: str = None, + mtype: str = None, year: str = None, season: int = None) -> Optional[dict]: """ 搜索和匹配豆瓣信息 :param name: 标题 + :param imdbid: imdbid :param mtype: 类型 :param year: 年份 :param season: 季 """ - return self.run_module("match_doubaninfo", name=name, mtype=mtype, year=year, season=season) + return self.run_module("match_doubaninfo", name=name, imdbid=imdbid, + mtype=mtype, year=year, season=season) def obtain_images(self, mediainfo: MediaInfo) -> Optional[MediaInfo]: """ diff --git a/app/modules/douban/__init__.py b/app/modules/douban/__init__.py index eb95bddc..1411e191 100644 --- a/app/modules/douban/__init__.py +++ b/app/modules/douban/__init__.py @@ -1,4 +1,3 @@ -from datetime import datetime from pathlib import Path from typing import List, Optional, Tuple, Union @@ -406,17 +405,23 @@ class DoubanModule(_ModuleBase): return ret_medias @retry(Exception, 5, 3, 3, logger=logger) - def match_doubaninfo(self, name: str, mtype: str = None, - year: str = None, season: int = None) -> dict: + def match_doubaninfo(self, name: str, imdbid: str = None, + mtype: str = None, year: str = None, season: int = None) -> dict: """ 搜索和匹配豆瓣信息 :param name: 名称 + :param imdbid: IMDB ID :param mtype: 类型 电影/电视剧 :param year: 年份 :param season: 季号 """ - result = self.doubanapi.search(f"{name} {year or ''}".strip(), - ts=datetime.strftime(datetime.now(), '%Y%m%d%H%M%S')) + if imdbid: + # 优先使用IMDBID查询 + result = self.doubanapi.imdbid(imdbid) + if result: + return result + # 搜索 + result = self.doubanapi.search(f"{name} {year or ''}".strip()) if not result: logger.warn(f"未找到 {name} 的豆瓣信息") return {} diff --git a/app/modules/douban/apiv2.py b/app/modules/douban/apiv2.py index 920fd8b2..bebf43eb 100644 --- a/app/modules/douban/apiv2.py +++ b/app/modules/douban/apiv2.py @@ -18,28 +18,29 @@ class DoubanApi(metaclass=Singleton): _urls = { # 搜索类 # sort=U:近期热门 T:标记最多 S:评分最高 R:最新上映 - # q=search_word&start=0&count=20&sort=U + # q=search_word&start: int = 0&count: int = 20&sort=U # 聚合搜索 "search": "/search/weixin", "search_agg": "/search", + "imdbid": "/movie/imdb/%s", # 电影探索 # sort=U:综合排序 T:近期热度 S:高分优先 R:首播时间 - # tags='日本,动画,2022'&start=0&count=20&sort=U + # tags='日本,动画,2022'&start: int = 0&count: int = 20&sort=U "movie_recommend": "/movie/recommend", # 电视剧探索 "tv_recommend": "/tv/recommend", # 搜索 "movie_tag": "/movie/tag", "tv_tag": "/tv/tag", - # q=search_word&start=0&count=20 + # q=search_word&start: int = 0&count: int = 20 "movie_search": "/search/movie", "tv_search": "/search/movie", "book_search": "/search/book", "group_search": "/search/group", # 各类主题合集 - # start=0&count=20 + # start: int = 0&count: int = 20 # 正在上映 "movie_showing": "/subject_collection/movie_showing/items", # 热门电影 @@ -145,7 +146,9 @@ class DoubanApi(metaclass=Singleton): "api-client/1 com.douban.frodo/7.3.0(207) Android/22 product/MI 9 vendor/Xiaomi model/MI 9 brand/Android rom/miui6 network/wifi platform/mobile nd/1"] _api_secret_key = "bf7dddc7c9cfe6f7" _api_key = "0dad551ec0f84ed02907ff5c42e8ec70" + _api_key2 = "0ab215a8b1977939201640fa14c66bab" _base_url = "https://frodo.douban.com/api/v2" + _api_url = "https://api.douban.com/v2" _session = None def __init__(self): @@ -153,6 +156,9 @@ class DoubanApi(metaclass=Singleton): @classmethod def __sign(cls, url: str, ts: int, method='GET') -> str: + """ + 签名 + """ url_path = parse.urlparse(url).path raw_sign = '&'.join([method.upper(), parse.quote(url_path, safe=''), str(ts)]) return base64.b64encode( @@ -164,7 +170,10 @@ class DoubanApi(metaclass=Singleton): ).decode() @lru_cache(maxsize=settings.CACHE_CONF.get('douban')) - def __invoke(self, url, **kwargs): + def __invoke(self, url: str, **kwargs) -> dict: + """ + GET请求 + """ req_url = self._base_url + url params = {'apiKey': self._api_key} @@ -189,119 +198,223 @@ class DoubanApi(metaclass=Singleton): return resp.json() return resp.json() if resp else {} - def search(self, keyword, start=0, count=20, - ts=datetime.strftime(datetime.now(), '%Y%m%d')): + @lru_cache(maxsize=settings.CACHE_CONF.get('douban')) + def __post(self, url: str, **kwargs) -> dict: + """ + POST请求 + esponse = requests.post( + url="https://api.douban.com/v2/movie/imdb/tt29139455", + headers={ + "Content-Type": "application/x-www-form-urlencoded; charset=utf-8", + "Cookie": "bid=J9zb1zA5sJc", + }, + data={ + "apikey": "0ab215a8b1977939201640fa14c66bab", + }, + ) + """ + req_url = self._api_url + url + params = {'apiKey': self._api_key2} + if kwargs: + params.update(kwargs) + if '_ts' in params: + params.pop('_ts') + resp = RequestUtils( + session=self._session + ).post_res(url=req_url, data=params) + if resp.status_code == 400 and "rate_limit" in resp.text: + return resp.json() + return resp.json() if resp else {} + + def search(self, keyword: str, start: int = 0, count: int = 20, + ts=datetime.strftime(datetime.now(), '%Y%m%d')) -> dict: + """ + 关键字搜索 + """ return self.__invoke(self._urls["search"], q=keyword, start=start, count=count, _ts=ts) - def movie_search(self, keyword, start=0, count=20, + def imdbid(self, imdbid: str, + ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + IMDBID搜索 + """ + return self.__post(self._urls["imdbid"] % imdbid, _ts=ts) + + def movie_search(self, keyword: str, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 电影搜索 + """ return self.__invoke(self._urls["movie_search"], q=keyword, start=start, count=count, _ts=ts) - def tv_search(self, keyword, start=0, count=20, + def tv_search(self, keyword: str, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 电视搜索 + """ return self.__invoke(self._urls["tv_search"], q=keyword, start=start, count=count, _ts=ts) - def book_search(self, keyword, start=0, count=20, + def book_search(self, keyword: str, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 书籍搜索 + """ return self.__invoke(self._urls["book_search"], q=keyword, start=start, count=count, _ts=ts) - def group_search(self, keyword, start=0, count=20, + def group_search(self, keyword: str, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 小组搜索 + """ return self.__invoke(self._urls["group_search"], q=keyword, start=start, count=count, _ts=ts) - def movie_showing(self, start=0, count=20, + def movie_showing(self, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 正在热映 + """ return self.__invoke(self._urls["movie_showing"], start=start, count=count, _ts=ts) - def movie_soon(self, start=0, count=20, + def movie_soon(self, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 即将上映 + """ return self.__invoke(self._urls["movie_soon"], start=start, count=count, _ts=ts) - def movie_hot_gaia(self, start=0, count=20, + def movie_hot_gaia(self, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 热门电影 + """ return self.__invoke(self._urls["movie_hot_gaia"], start=start, count=count, _ts=ts) - def tv_hot(self, start=0, count=20, + def tv_hot(self, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 热门剧集 + """ return self.__invoke(self._urls["tv_hot"], start=start, count=count, _ts=ts) - def tv_animation(self, start=0, count=20, + def tv_animation(self, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 动画 + """ return self.__invoke(self._urls["tv_animation"], start=start, count=count, _ts=ts) - def tv_variety_show(self, start=0, count=20, + def tv_variety_show(self, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 综艺 + """ return self.__invoke(self._urls["tv_variety_show"], start=start, count=count, _ts=ts) - def tv_rank_list(self, start=0, count=20, + def tv_rank_list(self, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 电视剧排行榜 + """ return self.__invoke(self._urls["tv_rank_list"], start=start, count=count, _ts=ts) - def show_hot(self, start=0, count=20, + def show_hot(self, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 综艺热门 + """ return self.__invoke(self._urls["show_hot"], start=start, count=count, _ts=ts) - def movie_detail(self, subject_id): + def movie_detail(self, subject_id: str): + """ + 电影详情 + """ return self.__invoke(self._urls["movie_detail"] + subject_id) - def movie_celebrities(self, subject_id): + def movie_celebrities(self, subject_id: str): + """ + 电影演职员 + """ return self.__invoke(self._urls["movie_celebrities"] % subject_id) - def tv_detail(self, subject_id): + def tv_detail(self, subject_id: str): + """ + 电视剧详情 + """ return self.__invoke(self._urls["tv_detail"] + subject_id) - def tv_celebrities(self, subject_id): + def tv_celebrities(self, subject_id: str): + """ + 电视剧演职员 + """ return self.__invoke(self._urls["tv_celebrities"] % subject_id) - def book_detail(self, subject_id): + def book_detail(self, subject_id: str): + """ + 书籍详情 + """ return self.__invoke(self._urls["book_detail"] + subject_id) - def movie_top250(self, start=0, count=20, + def movie_top250(self, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 电影TOP250 + """ return self.__invoke(self._urls["movie_top250"], start=start, count=count, _ts=ts) - def movie_recommend(self, tags='', sort='R', start=0, count=20, + def movie_recommend(self, tags='', sort='R', start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 电影探索 + """ return self.__invoke(self._urls["movie_recommend"], tags=tags, sort=sort, start=start, count=count, _ts=ts) - def tv_recommend(self, tags='', sort='R', start=0, count=20, + def tv_recommend(self, tags='', sort='R', start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 电视剧探索 + """ return self.__invoke(self._urls["tv_recommend"], tags=tags, sort=sort, start=start, count=count, _ts=ts) - def tv_chinese_best_weekly(self, start=0, count=20, + def tv_chinese_best_weekly(self, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 华语口碑周榜 + """ return self.__invoke(self._urls["tv_chinese_best_weekly"], start=start, count=count, _ts=ts) - def tv_global_best_weekly(self, start=0, count=20, + def tv_global_best_weekly(self, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): + """ + 全球口碑周榜 + """ return self.__invoke(self._urls["tv_global_best_weekly"], start=start, count=count, _ts=ts) - def doulist_detail(self, subject_id): + def doulist_detail(self, subject_id: str): """ 豆列详情 :param subject_id: 豆列id """ return self.__invoke(self._urls["doulist"] + subject_id) - def doulist_items(self, subject_id, start=0, count=20, + def doulist_items(self, subject_id: str, start: int = 0, count: int = 20, ts=datetime.strftime(datetime.now(), '%Y%m%d')): """ 豆列列表 diff --git a/app/plugins/personmeta/__init__.py b/app/plugins/personmeta/__init__.py index 3be06683..debff1ff 100644 --- a/app/plugins/personmeta/__init__.py +++ b/app/plugins/personmeta/__init__.py @@ -587,6 +587,7 @@ class PersonMeta(_PluginBase): time.sleep(sleep_time) # 匹配豆瓣信息 doubaninfo = self.chain.match_doubaninfo(name=mediainfo.title, + imdbid=mediainfo.imdb_id, mtype=mediainfo.type.value, year=mediainfo.year, season=season) From 884a0feb6240240fbda10fdb707e68f275f61498 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 12 Oct 2023 17:56:15 +0800 Subject: [PATCH 03/12] fix bug --- app/modules/douban/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/modules/douban/__init__.py b/app/modules/douban/__init__.py index 1411e191..f66d05f4 100644 --- a/app/modules/douban/__init__.py +++ b/app/modules/douban/__init__.py @@ -478,6 +478,7 @@ class DoubanModule(_ModuleBase): return # 根据名称查询豆瓣数据 doubaninfo = self.match_doubaninfo(name=mediainfo.title, + imdbid=mediainfo.imdb_id, mtype=mediainfo.type.value, year=mediainfo.year, season=meta.begin_season) @@ -500,6 +501,7 @@ class DoubanModule(_ModuleBase): continue # 根据名称查询豆瓣数据 doubaninfo = self.match_doubaninfo(name=mediainfo.title, + imdbid=mediainfo.imdb_id, mtype=mediainfo.type.value, year=mediainfo.year, season=meta.begin_season) From 1ecbc2f0be631e210cdf3254bb503194722ed1f0 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 12 Oct 2023 18:08:09 +0800 Subject: [PATCH 04/12] fix bug --- app/modules/douban/__init__.py | 2 ++ app/modules/douban/apiv2.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/modules/douban/__init__.py b/app/modules/douban/__init__.py index f66d05f4..2c206ec1 100644 --- a/app/modules/douban/__init__.py +++ b/app/modules/douban/__init__.py @@ -417,10 +417,12 @@ class DoubanModule(_ModuleBase): """ if imdbid: # 优先使用IMDBID查询 + logger.info(f"开始使用IMDBID {imdbid} 查询豆瓣信息 ...") result = self.doubanapi.imdbid(imdbid) if result: return result # 搜索 + logger.info(f"开始使用名称 {name} 查询豆瓣信息 ...") result = self.doubanapi.search(f"{name} {year or ''}".strip()) if not result: logger.warn(f"未找到 {name} 的豆瓣信息") diff --git a/app/modules/douban/apiv2.py b/app/modules/douban/apiv2.py index bebf43eb..3998ac1d 100644 --- a/app/modules/douban/apiv2.py +++ b/app/modules/douban/apiv2.py @@ -214,13 +214,14 @@ class DoubanApi(metaclass=Singleton): ) """ req_url = self._api_url + url - params = {'apiKey': self._api_key2} + params = {'apikey': self._api_key2} if kwargs: params.update(kwargs) if '_ts' in params: params.pop('_ts') resp = RequestUtils( - session=self._session + ua=settings.USER_AGENT, + session=self._session, ).post_res(url=req_url, data=params) if resp.status_code == 400 and "rate_limit" in resp.text: return resp.json() From 30c9c66087503b65979de2126b8f1dddcf00c196 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 12 Oct 2023 19:59:47 +0800 Subject: [PATCH 05/12] =?UTF-8?q?fix=20=E8=B1=86=E7=93=A3=E6=9D=A5?= =?UTF-8?q?=E6=BA=90=E8=AE=A2=E9=98=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/subscribe.py | 41 +++++++++++++++++++----------- app/core/meta/words.py | 3 +-- app/modules/themoviedb/__init__.py | 2 ++ 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/app/chain/subscribe.py b/app/chain/subscribe.py index 66c743fc..1811a8f0 100644 --- a/app/chain/subscribe.py +++ b/app/chain/subscribe.py @@ -6,6 +6,7 @@ from typing import Dict, List, Optional, Union, Tuple from sqlalchemy.orm import Session from app.chain import ChainBase +from app.chain.douban import DoubanChain from app.chain.download import DownloadChain from app.chain.search import SearchChain from app.chain.torrents import TorrentsChain @@ -50,18 +51,28 @@ class SubscribeChain(ChainBase): 识别媒体信息并添加订阅 """ logger.info(f'开始添加订阅,标题:{title} ...') - # 识别元数据 - metainfo = MetaInfo(title) - if year: - metainfo.year = year - if mtype: - metainfo.type = mtype - if season: - metainfo.type = MediaType.TV - metainfo.begin_season = season - # 识别媒体信息 - mediainfo: MediaInfo = self.recognize_media(meta=metainfo, mtype=mtype, tmdbid=tmdbid) - if not mediainfo: + metainfo = None + mediainfo = None + if not tmdbid and doubanid: + # 将豆瓣信息转换为TMDB信息 + context = DoubanChain().recognize_by_doubanid(doubanid) + if context: + metainfo = context.meta_info + mediainfo = context.media_info + else: + # 识别元数据 + metainfo = MetaInfo(title) + if year: + metainfo.year = year + if mtype: + metainfo.type = mtype + if season: + metainfo.type = MediaType.TV + metainfo.begin_season = season + # 识别媒体信息 + mediainfo = self.recognize_media(meta=metainfo, mtype=mtype, tmdbid=tmdbid) + # 识别失败 + if not mediainfo or not metainfo or not mediainfo.tmdb_id: logger.warn(f'未识别到媒体信息,标题:{title},tmdbid:{tmdbid}') return None, "未识别到媒体信息" # 更新媒体图片 @@ -74,8 +85,8 @@ class SubscribeChain(ChainBase): if not kwargs.get('total_episode'): if not mediainfo.seasons: # 补充媒体信息 - mediainfo: MediaInfo = self.recognize_media(mtype=mediainfo.type, - tmdbid=mediainfo.tmdb_id) + mediainfo = self.recognize_media(mtype=mediainfo.type, + tmdbid=mediainfo.tmdb_id) if not mediainfo: logger.error(f"媒体信息识别失败!") return None, "媒体信息识别失败" @@ -85,7 +96,7 @@ class SubscribeChain(ChainBase): total_episode = len(mediainfo.seasons.get(season) or []) if not total_episode: logger.error(f'未获取到总集数,标题:{title},tmdbid:{tmdbid}') - return None, "未获取到总集数" + return None, f"未获取到第 {season} 季的总集数" kwargs.update({ 'total_episode': total_episode }) diff --git a/app/core/meta/words.py b/app/core/meta/words.py index 3bc7ece4..c58266a0 100644 --- a/app/core/meta/words.py +++ b/app/core/meta/words.py @@ -61,8 +61,7 @@ class WordsMatcher(metaclass=Singleton): if state: appley_words.append(word) - else: - logger.debug(f"自定义识别词替换失败:{message}") + except Exception as err: print(str(err)) diff --git a/app/modules/themoviedb/__init__.py b/app/modules/themoviedb/__init__.py index 6bbeb896..87f7a7f4 100644 --- a/app/modules/themoviedb/__init__.py +++ b/app/modules/themoviedb/__init__.py @@ -283,6 +283,8 @@ class TheMovieDbModule(_ModuleBase): :param mediainfo: 识别的媒体信息 :return: 更新后的媒体信息 """ + if not mediainfo.tmdb_id: + return mediainfo if mediainfo.logo_path \ and mediainfo.poster_path \ and mediainfo.backdrop_path: From cefbd70469e177b6301d8dfaaf55aae789b18c41 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 12 Oct 2023 20:06:58 +0800 Subject: [PATCH 06/12] fix #807 --- app/modules/filetransfer/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/modules/filetransfer/__init__.py b/app/modules/filetransfer/__init__.py index 564e03b7..4927212c 100644 --- a/app/modules/filetransfer/__init__.py +++ b/app/modules/filetransfer/__init__.py @@ -382,13 +382,14 @@ class FileTransferModule(_ModuleBase): path=in_path, message=f"{in_path} 路径不存在") - if not target_dir.exists(): - return TransferInfo(success=False, - path=in_path, - message=f"{target_dir} 目标路径不存在") - - # 媒体库目的目录 - target_dir = self.__get_dest_dir(mediainfo=mediainfo, target_dir=target_dir) + if transfer_type not in ['rclone_copy', 'rclone_move']: + # 检查目标路径 + if not target_dir.exists(): + return TransferInfo(success=False, + path=in_path, + message=f"{target_dir} 目标路径不存在") + # 媒体库目的目录 + target_dir = self.__get_dest_dir(mediainfo=mediainfo, target_dir=target_dir) # 重命名格式 rename_format = settings.TV_RENAME_FORMAT \ From 5f96a562d4e9456951e0dac6f5456123f286ff25 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 12 Oct 2023 20:11:22 +0800 Subject: [PATCH 07/12] v1.3.2 --- version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.py b/version.py index a5f830ef..bb79480c 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -APP_VERSION = 'v1.3.1' +APP_VERSION = 'v1.3.2' From 6be074e647cddd29091c1e90e40a57bce389c73c Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 12 Oct 2023 20:31:59 +0800 Subject: [PATCH 08/12] fix doubaninfo --- app/modules/douban/__init__.py | 12 ++++++++++++ app/plugins/personmeta/__init__.py | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/modules/douban/__init__.py b/app/modules/douban/__init__.py index 2c206ec1..3ea37602 100644 --- a/app/modules/douban/__init__.py +++ b/app/modules/douban/__init__.py @@ -1,3 +1,4 @@ +import re from pathlib import Path from typing import List, Optional, Tuple, Union @@ -487,6 +488,12 @@ class DoubanModule(_ModuleBase): if not doubaninfo: logger.warn(f"未找到 {mediainfo.title} 的豆瓣信息") return + # 查询豆瓣详情 + doubanid = doubaninfo.get("id") + if not str(doubanid).isdigit(): + doubanid = re.search(r"\d+", doubanid).group(0) + doubaninfo = self.douban_info(doubanid) + # 刮削路径 scrape_path = path / path.name self.scraper.gen_scraper_files(meta=meta, mediainfo=MediaInfo(douban_info=doubaninfo), @@ -510,6 +517,11 @@ class DoubanModule(_ModuleBase): if not doubaninfo: logger.warn(f"未找到 {mediainfo.title} 的豆瓣信息") break + # 查询豆瓣详情 + doubanid = doubaninfo.get("id") + if not str(doubanid).isdigit(): + doubanid = re.search(r"\d+", doubanid).group(0) + doubaninfo = self.douban_info(doubanid) # 刮削 self.scraper.gen_scraper_files(meta=meta, mediainfo=MediaInfo(douban_info=doubaninfo), diff --git a/app/plugins/personmeta/__init__.py b/app/plugins/personmeta/__init__.py index debff1ff..a6349fdd 100644 --- a/app/plugins/personmeta/__init__.py +++ b/app/plugins/personmeta/__init__.py @@ -593,7 +593,11 @@ class PersonMeta(_PluginBase): season=season) # 豆瓣演员 if doubaninfo: - doubanitem = self.chain.douban_info(doubaninfo.get("id")) or {} + doubanid = doubaninfo.get("id") + if not str(doubanid).isdigit(): + # 从https://api.douban.com/movie/35561680中提取出字 + doubanid = re.search(r"\d+", doubanid).group(0) + doubanitem = self.chain.douban_info(doubanid) or {} return (doubanitem.get("actors") or []) + (doubanitem.get("directors") or []) else: logger.warn(f"未找到豆瓣信息:{mediainfo.title_year}") From bfbd93b912a1779307526ed0699270032835cefd Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 12 Oct 2023 20:35:44 +0800 Subject: [PATCH 09/12] fix --- app/utils/system.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/utils/system.py b/app/utils/system.py index f6d6c957..6da65e31 100644 --- a/app/utils/system.py +++ b/app/utils/system.py @@ -99,6 +99,8 @@ class SystemUtils: try: # link到当前目录并改名 tmp_path = src.parent / (dest.name + ".mp") + if tmp_path.exists(): + tmp_path.unlink() tmp_path.hardlink_to(src) # 移动到目标目录 shutil.move(tmp_path, dest) From f20c81efaede009c563d804274ff2eaf9bccd0e1 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 12 Oct 2023 20:47:23 +0800 Subject: [PATCH 10/12] fix rclone --- app/modules/filetransfer/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/modules/filetransfer/__init__.py b/app/modules/filetransfer/__init__.py index 4927212c..6b2c4ae8 100644 --- a/app/modules/filetransfer/__init__.py +++ b/app/modules/filetransfer/__init__.py @@ -402,6 +402,8 @@ class FileTransferModule(_ModuleBase): bluray_flag = SystemUtils.is_bluray_dir(in_path) if bluray_flag: logger.info(f"{in_path} 是蓝光原盘文件夹") + # 原文件大小 + file_size = in_path.stat().st_size # 目的路径 new_path = self.get_rename_path( path=target_dir, @@ -426,7 +428,7 @@ class FileTransferModule(_ModuleBase): return TransferInfo(success=True, path=in_path, target_path=new_path, - total_size=new_path.stat().st_size, + total_size=file_size, is_bluray=bluray_flag) else: # 转移单个文件 @@ -467,7 +469,8 @@ class FileTransferModule(_ModuleBase): if new_file.stat().st_size < in_path.stat().st_size: logger.info(f"目标文件已存在,但文件大小更小,将覆盖:{new_file}") overflag = True - + # 原文件大小 + file_size = in_path.stat().st_size # 转移文件 retcode = self.__transfer_file(file_item=in_path, new_file=new_file, @@ -486,7 +489,7 @@ class FileTransferModule(_ModuleBase): path=in_path, target_path=new_file, file_count=1, - total_size=new_file.stat().st_size, + total_size=file_size, is_bluray=False, file_list=[str(in_path)], file_list_new=[str(new_file)]) From b5cba64227a3475b99ce8c38badc7d1d4d536bfc Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 12 Oct 2023 21:30:35 +0800 Subject: [PATCH 11/12] fix --- app/modules/douban/__init__.py | 14 ++++++-------- app/plugins/personmeta/__init__.py | 6 +----- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/modules/douban/__init__.py b/app/modules/douban/__init__.py index 3ea37602..33162f28 100644 --- a/app/modules/douban/__init__.py +++ b/app/modules/douban/__init__.py @@ -421,6 +421,10 @@ class DoubanModule(_ModuleBase): logger.info(f"开始使用IMDBID {imdbid} 查询豆瓣信息 ...") result = self.doubanapi.imdbid(imdbid) if result: + doubanid = result.get("id") + if doubanid and not str(doubanid).isdigit(): + doubanid = re.search(r"\d+", doubanid).group(0) + result["id"] = doubanid return result # 搜索 logger.info(f"开始使用名称 {name} 查询豆瓣信息 ...") @@ -489,10 +493,7 @@ class DoubanModule(_ModuleBase): logger.warn(f"未找到 {mediainfo.title} 的豆瓣信息") return # 查询豆瓣详情 - doubanid = doubaninfo.get("id") - if not str(doubanid).isdigit(): - doubanid = re.search(r"\d+", doubanid).group(0) - doubaninfo = self.douban_info(doubanid) + doubaninfo = self.douban_info(doubaninfo.get("id")) # 刮削路径 scrape_path = path / path.name self.scraper.gen_scraper_files(meta=meta, @@ -518,10 +519,7 @@ class DoubanModule(_ModuleBase): logger.warn(f"未找到 {mediainfo.title} 的豆瓣信息") break # 查询豆瓣详情 - doubanid = doubaninfo.get("id") - if not str(doubanid).isdigit(): - doubanid = re.search(r"\d+", doubanid).group(0) - doubaninfo = self.douban_info(doubanid) + doubaninfo = self.douban_info(doubaninfo.get("id")) # 刮削 self.scraper.gen_scraper_files(meta=meta, mediainfo=MediaInfo(douban_info=doubaninfo), diff --git a/app/plugins/personmeta/__init__.py b/app/plugins/personmeta/__init__.py index a6349fdd..debff1ff 100644 --- a/app/plugins/personmeta/__init__.py +++ b/app/plugins/personmeta/__init__.py @@ -593,11 +593,7 @@ class PersonMeta(_PluginBase): season=season) # 豆瓣演员 if doubaninfo: - doubanid = doubaninfo.get("id") - if not str(doubanid).isdigit(): - # 从https://api.douban.com/movie/35561680中提取出字 - doubanid = re.search(r"\d+", doubanid).group(0) - doubanitem = self.chain.douban_info(doubanid) or {} + doubanitem = self.chain.douban_info(doubaninfo.get("id")) or {} return (doubanitem.get("actors") or []) + (doubanitem.get("directors") or []) else: logger.warn(f"未找到豆瓣信息:{mediainfo.title_year}") From 7e51d70cd6b22894254fc5d2ff6ae83a588da944 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 12 Oct 2023 22:46:42 +0800 Subject: [PATCH 12/12] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E9=A1=B5=E9=9D=A2=E8=BF=87=E6=BB=A4=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.py b/version.py index bb79480c..94762020 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -APP_VERSION = 'v1.3.2' +APP_VERSION = 'v1.3.2-1'