Add get-video-properties in requirements.txt & fix some codes
This commit is contained in:
60
core.py
60
core.py
@@ -84,14 +84,15 @@ def small_cover_check(path, filename, cover_small, movie_path, json_headers=None
|
|||||||
|
|
||||||
|
|
||||||
def create_folder(json_data): # 创建文件夹
|
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()
|
conf = config.getInstance()
|
||||||
success_folder = conf.success_folder()
|
success_folder = conf.success_folder()
|
||||||
actor = json_data.get('actor')
|
actor = json_data.get('actor')
|
||||||
location_rule = eval(conf.location_rule(), json_data)
|
location_rule = eval(conf.location_rule(), json_data)
|
||||||
if 'actor' in conf.location_rule() and len(actor) > 100:
|
if 'actor' in conf.location_rule() and len(actor) > 100:
|
||||||
print(conf.location_rule())
|
print(conf.location_rule())
|
||||||
location_rule = eval(conf.location_rule().replace("actor","'多人作品'"), json_data)
|
location_rule = eval(conf.location_rule().replace("actor", "'多人作品'"), json_data)
|
||||||
maxlen = conf.max_title_len()
|
maxlen = conf.max_title_len()
|
||||||
if 'title' in conf.location_rule() and len(title) > maxlen:
|
if 'title' in conf.location_rule() and len(title) > maxlen:
|
||||||
shorttitle = title[0:maxlen]
|
shorttitle = title[0:maxlen]
|
||||||
@@ -129,7 +130,7 @@ def download_file_with_filename(url, filename, path, filepath, json_headers=None
|
|||||||
except:
|
except:
|
||||||
print(f"[-]Fatal error! Can not make folder '{path}'")
|
print(f"[-]Fatal error! Can not make folder '{path}'")
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
r = get_html(url=url,return_type='content',json_headers=json_headers)
|
r = get_html(url=url, return_type='content', json_headers=json_headers)
|
||||||
if r == '':
|
if r == '':
|
||||||
print('[-]Movie Download Data not found!')
|
print('[-]Movie Download Data not found!')
|
||||||
return
|
return
|
||||||
@@ -144,20 +145,22 @@ def download_file_with_filename(url, filename, path, filepath, json_headers=None
|
|||||||
# moveFailedFolder(filepath)
|
# moveFailedFolder(filepath)
|
||||||
# return
|
# return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('[-]Image Download :Error',e)
|
print('[-]Image Download :Error', e)
|
||||||
print('[-]Connect Failed! Please check your Proxy or Network!')
|
print('[-]Connect Failed! Please check your Proxy or Network!')
|
||||||
moveFailedFolder(filepath)
|
moveFailedFolder(filepath)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def trailer_download(trailer, leak_word, c_word, hack_word, number, path, filepath):
|
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
|
return
|
||||||
configProxy = config.getInstance().proxy()
|
configProxy = config.getInstance().proxy()
|
||||||
for i in range(configProxy.retry):
|
for i in range(configProxy.retry):
|
||||||
if file_not_exist_or_empty(path+'/' + number + leak_word + c_word + hack_word + '-trailer.mp4'):
|
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)
|
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
|
continue
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
@@ -197,7 +200,8 @@ def actor_photo_download(actors, save_dir, number):
|
|||||||
failed += 1
|
failed += 1
|
||||||
print(f"[-]Actor photo '{dn_list[i][0]}' to '{dn_list[i][1]}' download failed!")
|
print(f"[-]Actor photo '{dn_list[i][0]}' to '{dn_list[i][1]}' download failed!")
|
||||||
if failed: # 非致命错误,电影不移入失败文件夹,将来可以用模式3补齐
|
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:
|
else:
|
||||||
print(f"[+]Successfully downloaded {len(result)} actor photo.")
|
print(f"[+]Successfully downloaded {len(result)} actor photo.")
|
||||||
|
|
||||||
@@ -239,7 +243,7 @@ def extrafanart_download_one_by_one(data, path, filepath, json_data=None):
|
|||||||
print(f'[!]Extrafanart download one by one mode runtime {time.perf_counter() - tm_start:.3f}s')
|
print(f'[!]Extrafanart download one by one mode runtime {time.perf_counter() - tm_start:.3f}s')
|
||||||
|
|
||||||
|
|
||||||
def extrafanart_download_threadpool(url_list, save_dir, number,json_data=None):
|
def extrafanart_download_threadpool(url_list, save_dir, number, json_data=None):
|
||||||
tm_start = time.perf_counter()
|
tm_start = time.perf_counter()
|
||||||
conf = config.getInstance()
|
conf = config.getInstance()
|
||||||
extrafanart_dir = Path(save_dir) / conf.get_extrafanart()
|
extrafanart_dir = Path(save_dir) / conf.get_extrafanart()
|
||||||
@@ -262,7 +266,8 @@ def extrafanart_download_threadpool(url_list, save_dir, number,json_data=None):
|
|||||||
failed += 1
|
failed += 1
|
||||||
print(f'[-]Extrafanart {i} for [{number}] download failed!')
|
print(f'[-]Extrafanart {i} for [{number}] download failed!')
|
||||||
if failed: # 非致命错误,电影不移入失败文件夹,将来可以用模式3补齐
|
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:
|
else:
|
||||||
print(f"[+]Successfully downloaded {len(result)} extrafanarts.")
|
print(f"[+]Successfully downloaded {len(result)} extrafanarts.")
|
||||||
if conf.debug():
|
if conf.debug():
|
||||||
@@ -307,12 +312,14 @@ def image_download(cover, fanart_path, thumb_path, path, filepath, json_headers=
|
|||||||
shutil.copyfile(full_filepath, os.path.join(path, thumb_path))
|
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):
|
def print_files(path, leak_word, c_word, naming_rule, part, cn_sub, json_data, filepath, tag, actor_list, liuchu,
|
||||||
title, studio, year, outline, runtime, director, actor_photo, release, number, cover, trailer, website, series, label = get_info(json_data)
|
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等软件方可支持
|
if config.getInstance().main_mode() == 3: # 模式3下,由于视频文件不做任何改变,.nfo文件必须和视频文件名称除后缀外完全一致,KODI等软件方可支持
|
||||||
nfo_path = str(Path(filepath).with_suffix('.nfo'))
|
nfo_path = str(Path(filepath).with_suffix('.nfo'))
|
||||||
else:
|
else:
|
||||||
nfo_path = os.path.join(path,f"{number}{part}{leak_word}{c_word}{hack_word}.nfo")
|
nfo_path = os.path.join(path, f"{number}{part}{leak_word}{c_word}{hack_word}.nfo")
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
try:
|
try:
|
||||||
@@ -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.paste(img_subt, (pos[count]['x'], pos[count]['y']), mask=a)
|
||||||
img_pic.save(pic_path, quality=95)
|
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
|
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:
|
if multi_part == 1:
|
||||||
number += part # 这时number会被附加上CD1后缀
|
number += part # 这时number会被附加上CD1后缀
|
||||||
filepath_obj = pathlib.Path(filepath)
|
filepath_obj = pathlib.Path(filepath)
|
||||||
@@ -821,9 +831,10 @@ def core_main(movie_path, number_th, oCC, specified_source=None, specified_url=N
|
|||||||
hack_word = "-hack"
|
hack_word = "-hack"
|
||||||
|
|
||||||
# 判断是否4k
|
# 判断是否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视频
|
props = get_video_properties(movie_path) # 判断是否为4K视频
|
||||||
if props['width'] >=4096 or props['height'] >= 2160:
|
if props['width'] >= 4096 or props['height'] >= 2160:
|
||||||
_4k = '4k'
|
_4k = '4k'
|
||||||
_4k_world = '-4k'
|
_4k_world = '-4k'
|
||||||
|
|
||||||
@@ -832,8 +843,7 @@ def core_main(movie_path, number_th, oCC, specified_source=None, specified_url=N
|
|||||||
debug_print(json_data)
|
debug_print(json_data)
|
||||||
|
|
||||||
# 创建文件夹
|
# 创建文件夹
|
||||||
#path = create_folder(rootpath + '/' + conf.success_folder(), json_data.get('location_rule'), json_data)
|
# path = create_folder(rootpath + '/' + conf.success_folder(), json_data.get('location_rule'), json_data)
|
||||||
|
|
||||||
|
|
||||||
cover = json_data.get('cover')
|
cover = json_data.get('cover')
|
||||||
ext = image_ext(cover)
|
ext = image_ext(cover)
|
||||||
@@ -887,7 +897,7 @@ def core_main(movie_path, number_th, oCC, specified_source=None, specified_url=N
|
|||||||
|
|
||||||
# 添加水印
|
# 添加水印
|
||||||
if conf.is_watermark():
|
if conf.is_watermark():
|
||||||
add_mark(os.path.join(path,poster_path), os.path.join(path,thumb_path), cn_sub, leak, uncensored, hack)
|
add_mark(os.path.join(path, poster_path), os.path.join(path, thumb_path), cn_sub, leak, uncensored, hack)
|
||||||
|
|
||||||
# 兼容Jellyfin封面图文件名规则
|
# 兼容Jellyfin封面图文件名规则
|
||||||
if multi_part and conf.jellyfin_multi_part_fanart():
|
if multi_part and conf.jellyfin_multi_part_fanart():
|
||||||
@@ -897,8 +907,9 @@ 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)
|
paste_file_to_folder(movie_path, path, multi_part, number, part, leak_word, c_word, hack_word)
|
||||||
|
|
||||||
# 最后输出.nfo元数据文件,以完成.nfo文件创建作为任务成功标志
|
# 最后输出.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,
|
||||||
,_4k,fanart_path,poster_path,thumb_path)
|
json_data.get('actor_list'), liuchu, uncensored, hack_word
|
||||||
|
, _4k, fanart_path, poster_path, thumb_path)
|
||||||
|
|
||||||
elif conf.main_mode() == 2:
|
elif conf.main_mode() == 2:
|
||||||
# 创建文件夹
|
# 创建文件夹
|
||||||
@@ -906,7 +917,7 @@ def core_main(movie_path, number_th, oCC, specified_source=None, specified_url=N
|
|||||||
# 移动文件
|
# 移动文件
|
||||||
paste_file_to_folder_mode2(movie_path, path, multi_part, number, part, leak_word, c_word, hack_word)
|
paste_file_to_folder_mode2(movie_path, path, multi_part, number, part, leak_word, c_word, hack_word)
|
||||||
if conf.is_watermark():
|
if conf.is_watermark():
|
||||||
add_mark(os.path.join(path,poster_path), os.path.join(path,thumb_path), cn_sub, leak, uncensored, hack)
|
add_mark(os.path.join(path, poster_path), os.path.join(path, thumb_path), cn_sub, leak, uncensored, hack)
|
||||||
|
|
||||||
elif conf.main_mode() == 3:
|
elif conf.main_mode() == 3:
|
||||||
path = str(Path(movie_path).parent)
|
path = str(Path(movie_path).parent)
|
||||||
@@ -950,7 +961,7 @@ def core_main(movie_path, number_th, oCC, specified_source=None, specified_url=N
|
|||||||
|
|
||||||
# 添加水印
|
# 添加水印
|
||||||
if conf.is_watermark():
|
if conf.is_watermark():
|
||||||
add_mark(os.path.join(path,poster_path), os.path.join(path,thumb_path), cn_sub, leak, uncensored, hack)
|
add_mark(os.path.join(path, poster_path), os.path.join(path, thumb_path), cn_sub, leak, uncensored, hack)
|
||||||
|
|
||||||
# 兼容Jellyfin封面图文件名规则
|
# 兼容Jellyfin封面图文件名规则
|
||||||
if multi_part and conf.jellyfin_multi_part_fanart():
|
if multi_part and conf.jellyfin_multi_part_fanart():
|
||||||
@@ -958,4 +969,5 @@ def core_main(movie_path, number_th, oCC, specified_source=None, specified_url=N
|
|||||||
|
|
||||||
# 最后输出.nfo元数据文件,以完成.nfo文件创建作为任务成功标志
|
# 最后输出.nfo元数据文件,以完成.nfo文件创建作为任务成功标志
|
||||||
print_files(path, leak_word, c_word, json_data.get('naming_rule'), part, cn_sub, json_data, movie_path,
|
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)
|
||||||
|
|||||||
@@ -9,3 +9,4 @@ certifi
|
|||||||
MechanicalSoup
|
MechanicalSoup
|
||||||
opencc-python-reimplemented
|
opencc-python-reimplemented
|
||||||
face_recognition
|
face_recognition
|
||||||
|
get-video-properties
|
||||||
|
|||||||
Reference in New Issue
Block a user