From cc362a2a263833be8ee1775ac9afd7cf118e6dcd Mon Sep 17 00:00:00 2001 From: Yoshiko <42309414+yoshiko2@users.noreply.github.com> Date: Tue, 9 Jul 2019 17:47:43 +0800 Subject: [PATCH] Beta 11.5 Update --- ADC_function.py | 28 +++++++++++++------- AV_Data_Capture.py | 11 ++++---- core.py | 66 +++++++++++++++++++++++++++------------------- javbus.py | 2 +- siro.py | 2 +- 5 files changed, 65 insertions(+), 44 deletions(-) diff --git a/ADC_function.py b/ADC_function.py index 43da93c..859afc9 100644 --- a/ADC_function.py +++ b/ADC_function.py @@ -3,27 +3,36 @@ from configparser import RawConfigParser import os import re from retrying import retry +import time import sys -# content = open('config.ini').read() -# content = re.sub(r"\xfe\xff","", content) -# content = re.sub(r"\xff\xfe","", content) -# content = re.sub(r"\xef\xbb\xbf","", content) -# open('BaseConfig.cfg', 'w').write(content) - config = RawConfigParser() if os.path.exists('config.ini'): - config.read('config.ini', encoding='UTF-8') + try: + config.read('config.ini', encoding='UTF-8') + except: + print('[-]Config.ini read failed! Please use the offical file!') else: + print('[+]config.ini: not found, creating...') with open("config.ini", "wt", encoding='UTF-8') as code: print("[proxy]",file=code) print("proxy=127.0.0.1:1080",file=code) print("timeout=10", file=code) + print("retry=3", file=code) + print("", file=code) print("[Name_Rule]", file=code) - print("location_rule='JAV_output/'+actor+'/['+number+']-'+title",file=code) + print("location_rule='JAV_output/'+actor+'/'+number",file=code) print("naming_rule=number+'-'+title",file=code) + print("", file=code) print("[update]",file=code) - print("update_check=1") + print("update_check=1",file=code) + time.sleep(2) + print('[+]config.ini: created!') + try: + config.read('config.ini', encoding='UTF-8') + except: + print('[-]Config.ini read failed! Please use the offical file!') + def UpdateCheckSwitch(): check=str(config['update']['update_check']) if check == '1': @@ -60,4 +69,3 @@ def get_html(url,cookies = None):#网页请求核心 print('[-]Connect retry '+str(i)+'/'+str(retry_count)) - diff --git a/AV_Data_Capture.py b/AV_Data_Capture.py index b7bb698..f24c9a9 100644 --- a/AV_Data_Capture.py +++ b/AV_Data_Capture.py @@ -7,7 +7,7 @@ import ADC_function import json import shutil -version='0.11.4' +version='0.11.5' os.chdir(os.getcwd()) def UpdateCheck(): @@ -109,13 +109,14 @@ def getNumber(filepath): print('[-]' + str(os.path.basename(filepath)) + ' :', e2) print('[-]Move ' + os.path.basename(filepath) + ' to failed folder') shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/') + def RunCore(): if os.path.exists('core.py'): - os.system('python core.py' + ' "' + i + '" --number "'+getNumber(i)+'"') #选择从py文件启动 (用于源码py) + os.system('python core.py' + ' "' + i + '" --number "'+getNumber(i)+'"') #从py文件启动(用于源码py) elif os.path.exists('core.exe'): - os.system('core.exe' + ' "' + i + '" --number "'+getNumber(i)+'"') #选择从exe文件启动(用于EXE版程序: + os.system('core.exe' + ' "' + i + '" --number "'+getNumber(i)+'"') #从exe启动(用于EXE版程序) elif os.path.exists('core.py') and os.path.exists('core.exe'): - os.system('python core.py' + ' "' + i + '" --number "' + getNumber(i) + '"') # 选择从py文件启动 (用于源码py) + os.system('python core.py' + ' "' + i + '" --number "' + getNumber(i) + '"') #从py文件启动(用于源码py) if __name__ =='__main__': print('[*]===========AV Data Capture===========') @@ -131,7 +132,7 @@ if __name__ =='__main__': count = count + 1 percentage = str(count/int(count_all)*100)[:4]+'%' print('[!] - '+percentage+' ['+str(count)+'/'+count_all+'] -') - print("[!]Making Data for [" + i + "],the number is [" + getNumber(i) + "]") + print("[!]Making Data for [" + i + "], the number is [" + getNumber(i) + "]") RunCore() print("[*]=====================================") diff --git a/core.py b/core.py index c099774..30622b6 100644 --- a/core.py +++ b/core.py @@ -37,6 +37,11 @@ naming_rule =''#eval(config['Name_Rule']['naming_rule']) location_rule=''#eval(config['Name_Rule']['location_rule']) #=====================本地文件处理=========================== +def moveFailedFolder(): + global filepath + print('[-]Move to "failed"') + shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/') + os._exit(0) def argparse_get_file(): parser = argparse.ArgumentParser() parser.add_argument("--number", help="Enter Number on here", default='') @@ -72,6 +77,9 @@ def getDataFromJSON(file_number): #从JSON返回元数据 global naming_rule global location_rule + + # ================================================网站规则添加开始================================================ + try: # 添加 需要 正则表达式的规则 # =======================javdb.py======================= if re.search('^\d{5,}', file_number).group() in file_number: @@ -84,28 +92,31 @@ def getDataFromJSON(file_number): #从JSON返回元数据 elif 'FC2' in file_number: json_data = json.loads(fc2fans_club.main( file_number.strip('FC2_').strip('FC2-').strip('ppv-').strip('PPV-').strip('fc2_').strip('fc2-').strip('ppv-').strip('PPV-'))) - # print(file_number.strip('FC2_').strip('FC2-').strip('ppv-').strip('PPV-')) # =======================javbus.py======================= else: json_data = json.loads(javbus.main(file_number)) # ================================================网站规则添加结束================================================ - title = str(json_data['title']).replace(' ','') - studio = json_data['studio'] - year = json_data['year'] - outline = json_data['outline'] - runtime = json_data['runtime'] - director = json_data['director'] - actor_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(',') # 字符串转列表 - release = json_data['release'] - number = json_data['number'] - cover = json_data['cover'] - imagecut = json_data['imagecut'] - tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表 - actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '') - actor_photo = json_data['actor_photo'] - website = json_data['website'] + title = str(json_data['title']).replace(' ','') + studio = json_data['studio'] + year = json_data['year'] + outline = json_data['outline'] + runtime = json_data['runtime'] + director = json_data['director'] + actor_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(',') # 字符串转列表 + release = json_data['release'] + number = json_data['number'] + cover = json_data['cover'] + imagecut = json_data['imagecut'] + tag = str(json_data['tag']).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表 + actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '') + actor_photo = json_data['actor_photo'] + website = json_data['website'] + + if title == '' or number == '': + print('[-]Movie Data not found!') + moveFailedFolder() # ====================处理异常字符====================== #\/:*?"<>| if '\\' in title: @@ -163,20 +174,24 @@ def DownloadFileWithFilename(url,filename,path): #path = examle:photo , video.in headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'} r = requests.get(url, headers=headers, timeout=timeout,proxies={"http": "http://" + str(proxy), "https": "https://" + str(proxy)}) + if r == '': + print('[-]Movie Data not found!') + os._exit(0) with open(str(path) + "/" + filename, "wb") as code: code.write(r.content) return - # print(bytes(r),file=code) else: if not os.path.exists(path): os.makedirs(path) headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'} r = requests.get(url, timeout=timeout, headers=headers) + if r == '': + print('[-]Movie Data not found!') + os._exit(0) with open(str(path) + "/" + filename, "wb") as code: code.write(r.content) return - # print(bytes(r),file=code) except requests.exceptions.RequestException: i += 1 print('[-]Image Download : Connect retry '+str(i)+'/'+str(retry_count)) @@ -189,11 +204,11 @@ def DownloadFileWithFilename(url,filename,path): #path = examle:photo , video.in except requests.exceptions.ConnectTimeout: i += 1 print('[-]Image Download : Connect retry '+str(i)+'/'+str(retry_count)) + moveFailedFolder() def imageDownload(filepath): #封面是否下载成功,否则移动到failed global path if DownloadFileWithFilename(cover,'fanart.jpg', path) == 'failed': - shutil.move(filepath, 'failed/') - os._exit(0) + moveFailedFolder() DownloadFileWithFilename(cover, 'fanart.jpg', path) print('[+]Image Downloaded!', path +'/fanart.jpg') def PrintFiles(filepath): @@ -253,13 +268,11 @@ def PrintFiles(filepath): except IOError as e: print("[-]Write Failed!") print(e) - shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/') - os._exit(0) + moveFailedFolder() except Exception as e1: print(e1) print("[-]Write Failed!") - shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/') - os._exit(0) + moveFailedFolder() def cutImage(): if imagecut == 1: try: @@ -282,7 +295,7 @@ def pasteFileToFolder(filepath, path): #文件路径,番号,后缀,要移 os.rename(filepath, number + houzhui) shutil.move(number + houzhui, path) def renameJpgToBackdrop_copy(): - shutil.copy(path+'/fanart.jpg', path+'/Backdrop.jpg') + shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg') shutil.copy(path + '/poster.png', path + '/thumb.png') if __name__ == '__main__': @@ -297,7 +310,7 @@ if __name__ == '__main__': print("[!]Making Data for [" + number + "]") except: print("[-]failed!Please rename the filename again!") - shutil.move(filepath,'failed/') + moveFailedFolder() else: number = argparse_get_file()[1] CreatFailedFolder() @@ -308,4 +321,3 @@ if __name__ == '__main__': cutImage() # 裁剪图 pasteFileToFolder(filepath, path) # 移动文件 renameJpgToBackdrop_copy() - # time.sleep(20) diff --git a/javbus.py b/javbus.py index 92c4fb4..6f3a465 100644 --- a/javbus.py +++ b/javbus.py @@ -89,7 +89,7 @@ def getTag(htmlcode): # 获取演员 def main(number): try: - if re.search('\d+\D+', number).group() in number: + if re.search('\d+\D+', number).group() in number or 'siro' in number or 'SIRO' in number or 'Siro' in number: js = siro.main(number) return js except: diff --git a/siro.py b/siro.py index 2b144a5..0cd8b09 100644 --- a/siro.py +++ b/siro.py @@ -101,4 +101,4 @@ def main(number2): js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8') return js -#print(main('300maan-401')) \ No newline at end of file +#print(main('300maan-373')) \ No newline at end of file