From 9663f7b47337b23086821cc637b46199cc81aaee Mon Sep 17 00:00:00 2001 From: ninjadogz Date: Thu, 31 Oct 2019 22:15:43 +0900 Subject: [PATCH] =?UTF-8?q?core.py=E5=90=8C=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit core.py同期 --- core.py | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 2 deletions(-) diff --git a/core.py b/core.py index 7044401..8231a21 100755 --- a/core.py +++ b/core.py @@ -178,6 +178,9 @@ def getDataFromJSON(file_number): #从JSON返回元数据 title = title.replace('<', '') title = title.replace('>', '') title = title.replace('|', '') + tmpArr = cover_small.split(',') + if len(tmpArr) > 0: + cover_small = tmpArr[0].strip('\"').strip('\'') # ====================处理异常字符 END================== #\/:*?"<>| naming_rule = eval(config['Name_Rule']['naming_rule']) @@ -195,6 +198,14 @@ def smallCoverCheck(): img.save(path + '/' + number + '.png') time.sleep(1) os.remove(path + '/1.jpg') + if option == 'kodi': + DownloadFileWithFilename(cover_small, '1.jpg', path) + img = Image.open(path + '/1.jpg') + w = img.width + h = img.height + img.save(path + '/' + number + '-poster.jpg') + time.sleep(1) + os.remove(path + '/1.jpg') if option == 'plex': DownloadFileWithFilename(cover_small, '1.jpg', path) try: @@ -209,7 +220,7 @@ def creatFolder(): #创建文件夹 global actor global path if len(os.getcwd()+path) > 240: #新建成功输出文件夹 - path = success_folder+'/'+location_rule.replace("'actor'","'manypeople'",3).replace("actor","'manypeople'",3) #path为影片+元数据所在目录 + path = success_folder+'/'+location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录 else: path = success_folder+'/'+location_rule #print(path) @@ -284,6 +295,11 @@ def imageDownload(filepath): #封面是否下载成功,否则移动到failed print('[+]Image Downloaded!', path + '/' + number + part + '.jpg') else: print('[+]Image Downloaded!', path + '/' + number + '.jpg') + elif option == 'kodi': + if DownloadFileWithFilename(cover, number + '-fanart.jpg', path) == 'failed': + moveFailedFolder() + DownloadFileWithFilename(cover, number + '-fanart.jpg', path) + print('[+]Image Downloaded!', path + '/' + number + '-fanart.jpg') elif option == 'plex': if DownloadFileWithFilename(cover, 'fanart.jpg', path) == 'failed': moveFailedFolder() @@ -387,6 +403,52 @@ def PrintFiles(filepath): print(" " + "https://www.javbus.com/" + number + "", file=code) print("", file=code) print("[+]Writeed! " + path + "/" + number + ".nfo") + elif option == 'kodi': + with open(path + "/" + number + ".nfo", "wt", encoding='UTF-8') as code: + print("", file=code) + print(" " + naming_rule + "", file=code) + print(" ", file=code) + print(" ", file=code) + print(" " + studio + "+", file=code) + print(" " + year + "", file=code) + print(" " + outline + "", file=code) + print(" " + outline + "", file=code) + print(" " + str(runtime).replace(" ", "") + "", file=code) + print(" " + director + "", file=code) + print(" " + number + "-poster.jpg", file=code) + print(" " + number + '-fanart.jpg' + "", file=code) + try: + for key, value in actor_photo.items(): + print(" ", file=code) + print(" " + key + "", file=code) + if not actor_photo == '': # or actor_photo == []: + print(" " + value + "", file=code) + print(" ", file=code) + except: + aaaa = '' + print(" " + studio + "", file=code) + print(" ", file=code) + if cn_sub == '1': + print(" 中文字幕", file=code) + try: + for i in tag: + print(" " + i + "", file=code) + except: + aaaaa = '' + try: + for i in tag: + print(" " + i + "", file=code) + except: + aaaaaaaa = '' + if cn_sub == '1': + print(" 中文字幕", file=code) + print(" " + number + "", file=code) + print(" " + release + "", file=code) + print(" " + cover + "", file=code) + print(" " + "https://www.javbus.com/" + number + "", file=code) + print("", file=code) + print("[+]Writeed! " + path + "/" + number + ".nfo") except IOError as e: print("[-]Write Failed!") print(e) @@ -428,9 +490,28 @@ def cutImage(): w = img.width h = img.height img.save(path + '/' + number + '.png') + elif option == 'kodi': + if imagecut == 1: + try: + img = Image.open(path + '/' + number + '-fanart.jpg') + imgSize = img.size + w = img.width + h = img.height + img2 = img.crop((w / 1.9, 0, w, h)) + img2.save(path + '/' + number + '-poster.jpg') + except: + print('[-]Cover cut failed!') + elif imagecut == 0: + img = Image.open(path + '/' + number + '-fanart.jpg') + w = img.width + h = img.height + img.save(path + '/' + number + '-poster.jpg') def pasteFileToFolder(filepath, path): #文件路径,番号,后缀,要移动至的位置 global houzhui houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group()) + if part == '-CD1' and option == 'kodi': + global number + number += part try: os.rename(filepath, path + '/' + number + houzhui) except FileExistsError: @@ -446,6 +527,8 @@ def renameJpgToBackdrop_copy(): shutil.copy(path + '/poster.png', path + '/thumb.png') if option == 'emby': shutil.copy(path + '/' + number + '.jpg', path + '/Backdrop.jpg') + if option == 'kodi': + shutil.copy(path + '/' + number + '-fanart.jpg', path + '/Backdrop.jpg') def renameBackdropToJpg_copy(): if option == 'plex': shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg') @@ -453,6 +536,8 @@ def renameBackdropToJpg_copy(): if option == 'emby': shutil.copy(path + '/Backdrop.jpg', path + '/' + number + '.jpg') print('[+]Image Downloaded!', path + '/' + number + '.jpg') + if option == 'kodi': + print('跳过分集图片下载') def get_part(filepath): try: if re.search('-CD\d+', filepath): @@ -500,7 +585,7 @@ if __name__ == '__main__': if part == '-CD1' or multi_part == 0: smallCoverCheck() imageDownload(filepath) # creatFoder会返回番号路径 - if multi_part == 1: + if multi_part == 1 and option != 'kodi': number += part PrintFiles(filepath) # 打印文件 cutImage() # 裁剪图