From fd05706636dcd836cc35cfcb7bf748484308f9d7 Mon Sep 17 00:00:00 2001 From: mo_yy <54110819+moyy996@users.noreply.github.com> Date: Mon, 19 Aug 2019 10:18:32 +0800 Subject: [PATCH] Update core.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 支持分集 --- core.py | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/core.py b/core.py index 30f1258..a18de08 100755 --- a/core.py +++ b/core.py @@ -41,6 +41,7 @@ imagecut='' tag=[] cn_sub='' multi_part=0 +part='' path='' houzhui='' website='' @@ -273,7 +274,13 @@ def imageDownload(filepath): #封面是否下载成功,否则移动到failed if DownloadFileWithFilename(cover, number + '.jpg', path) == 'failed': moveFailedFolder() DownloadFileWithFilename(cover, number + '.jpg', path) - print('[+]Image Downloaded!', path + '/' + number + '.jpg') + if multi_part == 1: + old_name = os.path.join(path, number + '.jpg') + new_name = os.path.join(path, number + part + '.jpg') + os.rename(old_name, new_name) + print('[+]Image Downloaded!', path + '/' + number + part + '.jpg') + else: + print('[+]Image Downloaded!', path + '/' + number + '.jpg') elif option == 'plex': if DownloadFileWithFilename(cover, 'fanart.jpg', path) == 'failed': moveFailedFolder() @@ -448,9 +455,22 @@ def renameJpgToBackdrop_copy(): if option == 'emby': shutil.copy(path + '/' + number + '.jpg', path + '/Backdrop.jpg') +def renameBackdropToJpg_copy(): + if option == 'plex': + shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg') + shutil.copy(path + '/poster.png', path + '/thumb.png') + if option == 'emby': + shutil.copy(path + '/Backdrop.jpg', path + '/' + number + '.jpg') + print('[+]Image Downloaded!', path + '/' + number + '.jpg') +def get_part(filepath): + if re.search('-CD\d+', filepath): + return re.findall('-CD\d+', filepath)[0] if __name__ == '__main__': filepath=argparse_get_file()[0] #影片的路径 + if '-CD' in filepath or '-cd' in filepath: + multi_part = 1 + part = get_part(filepath) if '-c.' in filepath or '-C.' in filepath or '中文' in filepath or '字幕' in filepath: cn_sub='1' @@ -467,11 +487,17 @@ if __name__ == '__main__': getDataFromJSON(number) # 定义番号 creatFolder() # 创建文件夹 if program_mode == '1': - imageDownload(filepath) # creatFoder会返回番号路径 - PrintFiles(filepath) # 打印文件 - smallCoverCheck() - cutImage() # 裁剪图 + if part == '-CD1' or multi_part == 0: + imageDownload(filepath) # creatFoder会返回番号路径 + if multi_part == 1: + number += part + PrintFiles(filepath) # 打印文件 + smallCoverCheck() + cutImage() # 裁剪图 + renameJpgToBackdrop_copy() + else: + number += part + renameBackdropToJpg_copy() pasteFileToFolder(filepath, path) # 移动文件 - renameJpgToBackdrop_copy() elif program_mode == '2': pasteFileToFolder_mode2(filepath, path) # 移动文件