Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions javsp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -489,7 +488,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}")

Expand Down
4 changes: 2 additions & 2 deletions javsp/datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 1 addition & 4 deletions javsp/prompt.py
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 7 additions & 2 deletions javsp/web/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand All @@ -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[
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down