From 3a1c3b3d1bf20c7dd36847419b99556f93ea33df Mon Sep 17 00:00:00 2001 From: jtyoui Date: Fri, 21 Feb 2025 20:15:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=20=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8extrafanart=E6=89=8D=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javsp/__main__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/javsp/__main__.py b/javsp/__main__.py index 4bf5b01e4..32be412c5 100644 --- a/javsp/__main__.py +++ b/javsp/__main__.py @@ -489,7 +489,9 @@ def check_step(result, msg='步骤错误'): inner_bar.set_description('下载剧照') if movie.info.preview_pics: extrafanartdir = movie.save_dir + '/extrafanart' - os.mkdir(extrafanartdir) + # [修复bug] 不存在才创建 + if not os.path.exists(extrafanartdir): + os.mkdir(extrafanartdir) for (id, pic_url) in enumerate(movie.info.preview_pics): inner_bar.set_description(f"Downloading extrafanart {id} from url: {pic_url}") From 4a89249a50f459b674484e15d7cc41dc86f730f0 Mon Sep 17 00:00:00 2001 From: jtyoui Date: Sat, 15 Mar 2025 14:56:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javsp/__main__.py | 3 +-- javsp/datatype.py | 4 ++-- javsp/prompt.py | 5 +---- javsp/web/translate.py | 9 +++++++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/javsp/__main__.py b/javsp/__main__.py index 32be412c5..1f149050b 100644 --- a/javsp/__main__.py +++ b/javsp/__main__.py @@ -427,8 +427,7 @@ def check_step(result, msg='步骤错误'): """检查一个整理步骤的结果,并负责更新tqdm的进度""" if result: inner_bar.update() - else: - raise Exception(msg + '\n') + outer_bar = tqdm(all_movies, desc='整理影片', ascii=True, leave=False) total_step = 6 diff --git a/javsp/datatype.py b/javsp/datatype.py index 4bfdd7171..aa9fa67d7 100644 --- a/javsp/datatype.py +++ b/javsp/datatype.py @@ -142,12 +142,12 @@ def __init__(self, dvdid=None, /, *, cid=None) -> None: @cached_property def hard_sub(self) -> bool: """影片文件带有内嵌字幕""" - return 'C' in self.attr_str + return 'C' in self.attr_str.upper() @cached_property def uncensored(self) -> bool: """影片文件是无码流出/无码破解版本(很多种子并不严格区分这两种,故这里也不进一步细分)""" - return 'U' in self.attr_str + return 'U' in self.attr_str.upper() @cached_property def attr_str(self) -> str: diff --git a/javsp/prompt.py b/javsp/prompt.py index dedb829d2..26b16f930 100644 --- a/javsp/prompt.py +++ b/javsp/prompt.py @@ -1,7 +1,4 @@ from javsp.config import Cfg def prompt(message: str, what: str) -> str: if Cfg().other.interactive: - return input(message) - else: - print(f"缺少{what}") - exit(1) + return input(message) \ No newline at end of file diff --git a/javsp/web/translate.py b/javsp/web/translate.py index 79d458a1a..68c2c8901 100644 --- a/javsp/web/translate.py +++ b/javsp/web/translate.py @@ -24,11 +24,12 @@ def translate_movie_info(info: MovieInfo): """根据配置翻译影片信息""" # 翻译标题 - if info.title and Cfg().translator.fields.title and info.ori_title is None: + if info.title and Cfg().translator.fields.title: result = translate(info.title, Cfg().translator.engine, info.actress) if 'trans' in result: info.ori_title = info.title info.title = result['trans'] + print("翻译标题",info.ori_title,info.title) # 如果有的话,附加断句信息 if 'orig_break' in result: setattr(info, 'ori_title_break', result['orig_break']) @@ -44,9 +45,12 @@ def translate_movie_info(info: MovieInfo): # 只有翻译过plot的影片才可能需要ori_plot属性,因此在运行时动态添加,而不添加到类型定义里 setattr(info, 'ori_plot', info.plot) info.plot = result['trans'] + print("翻译简介", info.plot) else: logger.error('翻译简介时出错: ' + result['error']) return False + + return True def translate(texts, engine: Union[ @@ -179,7 +183,7 @@ def google_trans(texts, to='zh_CN'): # API: https://www.jianshu.com/p/ce35d89c25c3 # client参数的选择: https://github.com/lmk123/crx-selection-translate/issues/223#issue-184432017 global _google_trans_wait - url = f"https://translate.google.com.hk/translate_a/single?client=gtx&dt=t&dj=1&ie=UTF-8&sl=auto&tl={to}&q={texts}" + url = f"https://translate.google.com.hk/translate_a/single?client=gtx&dt=t&dj=1&ie=UTF-8&sl=ja&tl=zh_CN&q={texts}" proxies = read_proxy() r = requests.get(url, proxies=proxies) while r.status_code == 429: @@ -191,6 +195,7 @@ def google_trans(texts, to='zh_CN'): if r.status_code == 200: result = r.json() else: + print(r.reason) result = {'error_code': r.status_code, 'error_msg': r.reason} time.sleep(4) # Google翻译的API有QPS限制,因此需要等待一段时间 return result