Add get-video-properties in requirements.txt & fix some codes

This commit is contained in:
Wayne Lui
2022-11-22 17:14:57 +08:00
parent 031294ac05
commit e84d75a50a
2 changed files with 54 additions and 41 deletions

36
core.py
View File

@@ -84,7 +84,8 @@ def small_cover_check(path, filename, cover_small, movie_path, json_headers=None
def create_folder(json_data): # 创建文件夹
title, studio, year, outline, runtime, director, actor_photo, release, number, cover, trailer, website, series, label = get_info(json_data)
title, studio, year, outline, runtime, director, actor_photo, release, number, cover, trailer, website, series, label = get_info(
json_data)
conf = config.getInstance()
success_folder = conf.success_folder()
actor = json_data.get('actor')
@@ -151,13 +152,15 @@ def download_file_with_filename(url, filename, path, filepath, json_headers=None
def trailer_download(trailer, leak_word, c_word, hack_word, number, path, filepath):
if download_file_with_filename(trailer, number + leak_word + c_word + hack_word + '-trailer.mp4', path, filepath) == 'failed':
if download_file_with_filename(trailer, number + leak_word + c_word + hack_word + '-trailer.mp4', path,
filepath) == 'failed':
return
configProxy = config.getInstance().proxy()
for i in range(configProxy.retry):
if file_not_exist_or_empty(path + '/' + number + leak_word + c_word + hack_word + '-trailer.mp4'):
print('[!]Video Download Failed! Trying again. [{}/3]', i + 1)
download_file_with_filename(trailer, number + leak_word + c_word + hack_word + '-trailer.mp4', path, filepath)
download_file_with_filename(trailer, number + leak_word + c_word + hack_word + '-trailer.mp4', path,
filepath)
continue
else:
break
@@ -197,7 +200,8 @@ def actor_photo_download(actors, save_dir, number):
failed += 1
print(f"[-]Actor photo '{dn_list[i][0]}' to '{dn_list[i][1]}' download failed!")
if failed: # 非致命错误电影不移入失败文件夹将来可以用模式3补齐
print(f"[-]Failed downloaded {failed}/{len(result)} actor photo for [{number}] to '{actors_dir}', you may retry run mode 3 later.")
print(
f"[-]Failed downloaded {failed}/{len(result)} actor photo for [{number}] to '{actors_dir}', you may retry run mode 3 later.")
else:
print(f"[+]Successfully downloaded {len(result)} actor photo.")
@@ -262,7 +266,8 @@ def extrafanart_download_threadpool(url_list, save_dir, number,json_data=None):
failed += 1
print(f'[-]Extrafanart {i} for [{number}] download failed!')
if failed: # 非致命错误电影不移入失败文件夹将来可以用模式3补齐
print(f"[-]Failed downloaded {failed}/{len(result)} extrafanart images for [{number}] to '{extrafanart_dir}', you may retry run mode 3 later.")
print(
f"[-]Failed downloaded {failed}/{len(result)} extrafanart images for [{number}] to '{extrafanart_dir}', you may retry run mode 3 later.")
else:
print(f"[+]Successfully downloaded {len(result)} extrafanarts.")
if conf.debug():
@@ -307,8 +312,10 @@ def image_download(cover, fanart_path, thumb_path, path, filepath, json_headers=
shutil.copyfile(full_filepath, os.path.join(path, thumb_path))
def print_files(path, leak_word, c_word, naming_rule, part, cn_sub, json_data, filepath, tag, actor_list, liuchu, uncensored, hack_word,_4k,fanart_path,poster_path,thumb_path):
title, studio, year, outline, runtime, director, actor_photo, release, number, cover, trailer, website, series, label = get_info(json_data)
def print_files(path, leak_word, c_word, naming_rule, part, cn_sub, json_data, filepath, tag, actor_list, liuchu,
uncensored, hack_word, _4k, fanart_path, poster_path, thumb_path):
title, studio, year, outline, runtime, director, actor_photo, release, number, cover, trailer, website, series, label = get_info(
json_data)
if config.getInstance().main_mode() == 3: # 模式3下由于视频文件不做任何改变.nfo文件必须和视频文件名称除后缀外完全一致KODI等软件方可支持
nfo_path = str(Path(filepath).with_suffix('.nfo'))
else:
@@ -539,6 +546,8 @@ def add_to_pic(pic_path, img_pic, size, count, mode):
]
img_pic.paste(img_subt, (pos[count]['x'], pos[count]['y']), mask=a)
img_pic.save(pic_path, quality=95)
# ========================结束=================================
@@ -600,7 +609,8 @@ def paste_file_to_folder(filepath, path, multi_part, number, part, leak_word, c_
return
def paste_file_to_folder_mode2(filepath, path, multi_part, number, part, leak_word, c_word, hack_word): # 文件路径,番号,后缀,要移动至的位置
def paste_file_to_folder_mode2(filepath, path, multi_part, number, part, leak_word, c_word,
hack_word): # 文件路径,番号,后缀,要移动至的位置
if multi_part == 1:
number += part # 这时number会被附加上CD1后缀
filepath_obj = pathlib.Path(filepath)
@@ -821,7 +831,8 @@ def core_main(movie_path, number_th, oCC, specified_source=None, specified_url=N
hack_word = "-hack"
# 判断是否4k
if '4K' in tag: tag.remove('4K') # 从tag中移除'4K'
if '4K' in tag:
tag.remove('4K') # 从tag中移除'4K'
props = get_video_properties(movie_path) # 判断是否为4K视频
if props['width'] >= 4096 or props['height'] >= 2160:
_4k = '4k'
@@ -834,7 +845,6 @@ def core_main(movie_path, number_th, oCC, specified_source=None, specified_url=N
# 创建文件夹
# path = create_folder(rootpath + '/' + conf.success_folder(), json_data.get('location_rule'), json_data)
cover = json_data.get('cover')
ext = image_ext(cover)
fanart_path = f"{number}{leak_word}{c_word}{hack_word}-fanart{ext}"
@@ -897,7 +907,8 @@ def core_main(movie_path, number_th, oCC, specified_source=None, specified_url=N
paste_file_to_folder(movie_path, path, multi_part, number, part, leak_word, c_word, hack_word)
# 最后输出.nfo元数据文件以完成.nfo文件创建作为任务成功标志
print_files(path, leak_word, c_word, json_data.get('naming_rule'), part, cn_sub, json_data, movie_path, tag, json_data.get('actor_list'), liuchu, uncensored, hack_word
print_files(path, leak_word, c_word, json_data.get('naming_rule'), part, cn_sub, json_data, movie_path, tag,
json_data.get('actor_list'), liuchu, uncensored, hack_word
, _4k, fanart_path, poster_path, thumb_path)
elif conf.main_mode() == 2:
@@ -958,4 +969,5 @@ def core_main(movie_path, number_th, oCC, specified_source=None, specified_url=N
# 最后输出.nfo元数据文件以完成.nfo文件创建作为任务成功标志
print_files(path, leak_word, c_word, json_data.get('naming_rule'), part, cn_sub, json_data, movie_path,
tag, json_data.get('actor_list'), liuchu, uncensored, hack_word,fanart_path,poster_path,thumb_path)
tag, json_data.get('actor_list'), liuchu, uncensored, hack_word, fanart_path, poster_path,
thumb_path)

View File

@@ -9,3 +9,4 @@ certifi
MechanicalSoup
opencc-python-reimplemented
face_recognition
get-video-properties