Skip to content

Commit

Permalink
add options to let user decide whether they need extrafanarts
Browse files Browse the repository at this point in the history
  • Loading branch information
glyh committed Apr 17, 2024
1 parent 82fa4cc commit 22aac1d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
53 changes: 30 additions & 23 deletions JavSP.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,13 @@ def check_step(result, msg='步骤错误'):
raise Exception(msg + '\n')

outer_bar = tqdm(all_movies, desc='整理影片', ascii=True, leave=False)
total_step = 8 if cfg.Translate.engine else 7

total_step = 7
if cfg.Translate.engine:
total_step += 1
if cfg.Picture.use_extra_fanarts:
total_step += 1

return_movies = []
for movie in outer_bar:
try:
Expand Down Expand Up @@ -533,29 +539,30 @@ def check_step(result, msg='步骤错误'):
if len(movie.files) > 1 and 'universal' not in cfg.NamingRule.media_servers:
postStep_MultiMoviePoster(movie)

inner_bar.set_description('下载剧照')
if movie.info.preview_pics:
extrafanartdir = movie.save_dir + '/extrafanart'
os.mkdir(extrafanartdir)
movie.info.preview_pics = sorted(movie.info.preview_pics)
print(movie.info.preview_pics)
for (id, pic_url) in enumerate(movie.info.preview_pics):
inner_bar.set_description(f"下载剧照{id}")

fanart_destination = f"{extrafanartdir}/{id}.png"
try:
info = download(pic_url, fanart_destination)
if valid_pic(fanart_destination):
filesize = get_fmt_size(pic_path)
width, height = get_pic_size(pic_path)
elapsed = time.strftime("%M:%S", time.gmtime(info['elapsed']))
speed = get_fmt_size(info['rate']) + '/s'
logger.info(f"已下载剧照{id}: {width}x{height}, {filesize} [{elapsed}, {speed}]")
else:
if cfg.Picture.use_extra_fanarts == 'yes':
inner_bar.set_description('下载剧照')
if movie.info.preview_pics:
extrafanartdir = movie.save_dir + '/extrafanart'
os.mkdir(extrafanartdir)
movie.info.preview_pics = sorted(movie.info.preview_pics)
print(movie.info.preview_pics)
for (id, pic_url) in enumerate(movie.info.preview_pics):
inner_bar.set_description(f"下载剧照{id}")

fanart_destination = f"{extrafanartdir}/{id}.png"
try:
info = download(pic_url, fanart_destination)
if valid_pic(fanart_destination):
filesize = get_fmt_size(pic_path)
width, height = get_pic_size(pic_path)
elapsed = time.strftime("%M:%S", time.gmtime(info['elapsed']))
speed = get_fmt_size(info['rate']) + '/s'
logger.info(f"已下载剧照{id}: {width}x{height}, {filesize} [{elapsed}, {speed}]")
else:
check_step(False, f"下载剧照{id}: {pic_url}失败")
except:
check_step(False, f"下载剧照{id}: {pic_url}失败")
except:
check_step(False, f"下载剧照{id}: {pic_url}失败")
check_step(True)
check_step(True)

inner_bar.set_description('写入NFO')
write_nfo(movie.info, movie.nfo_file)
Expand Down
2 changes: 2 additions & 0 deletions core/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ null_for_publisher = #未知发行商
[Picture]
# 尽可能下载高清封面?(高清封面大小约 8-10 MiB,远大于普通封面,如果你的网络条件不佳,会降低整理速度)
use_big_cover = yes
# 是否下载剧照?
use_extra_fanarts = no
# 启用图像识别裁剪海报
use_ai_crop = no
# 要使用图像识别来裁剪的番号系列($label), \d表示纯数字番号(FC2和识别到的无码影片会自动使用图像识别裁剪)
Expand Down

0 comments on commit 22aac1d

Please sign in to comment.