From 024dfa6f0438221920a96d8d5cc0de79de1a10c5 Mon Sep 17 00:00:00 2001 From: mo_yy Date: Wed, 5 Feb 2020 00:53:45 +0800 Subject: [PATCH] 3.3 --- ADC_function.py | 1 + AVDC_Main.py | 106 +++++++++++++++++++++++++++++++--------------- avsox.py | 20 +++++---- config.ini | 2 +- core.py | 27 +++--------- fanza.py | 33 +++++++++++---- fc2fans_club.py | 33 +++++++++++---- javbus.py | 58 ++++++++++++++++--------- javdb.py | 50 +++++++++++----------- siro.py | 47 ++++++++++++-------- update_check.json | 4 +- 11 files changed, 236 insertions(+), 145 deletions(-) diff --git a/ADC_function.py b/ADC_function.py index cbc82b645..f03d3e863 100755 --- a/ADC_function.py +++ b/ADC_function.py @@ -104,3 +104,4 @@ def get_html(url, cookies=None): # 网页请求核心 i += 1 print('[-]Connect retry ' + str(i) + '/' + str(retry_count)) print('[-]Connect Failed! Please check your Proxy or Network!') + return 'ProxyError' diff --git a/AVDC_Main.py b/AVDC_Main.py index 0962bab34..e2f387bc2 100644 --- a/AVDC_Main.py +++ b/AVDC_Main.py @@ -29,7 +29,7 @@ def __init__(self, parent=None): self.Ui = Ui_AVDV() # 实例化 Ui self.Ui.setupUi(self) # 初始化Ui self.Init_Ui() - self.version = '3.22' + self.version = '3.3' self.Init() self.Load_Config() self.show_version() @@ -293,8 +293,12 @@ def select_file_thread(self, file_name): file_root = os.getcwd().replace("\\\\", "/").replace("\\", "/") file_path = file_name.replace(file_root, '.').replace("\\\\", "/").replace("\\", "/") file_name = os.path.splitext(file_name.split('/')[-1])[0] + file_name = getNumber(file_name) self.add_text_main("[!]Making Data for [" + file_path + "], the number is [" + file_name + "]") - self.core_main(file_path, file_name) + try: + self.core_main(file_path, file_name) + except Exception: + self.add_text_main('[-]Error in Core!') self.add_text_main("[*]======================================================") # ========================================================================小工具-视频移动 @@ -332,7 +336,6 @@ def add_text_main(self, text): def moveFailedFolder(self, filepath, failed_folder): self.add_text_main('[-]Move to Failed output folder') shutil.move(filepath, str(os.getcwd()) + '/' + failed_folder + '/') - # os._exit(0) # =====================资源下载部分=========================== def DownloadFileWithFilename(self, url, filename, path, Config, filepath, @@ -468,6 +471,7 @@ def smallCoverCheck(self, path, number, imagecut, cover_small, c_word, option, C w = img.width h = img.height img.save(path + '/' + number + c_word + '.png') + self.add_text_main('[+]Image Cut! ' + number + c_word + '.png') time.sleep(1) os.remove(path + '/1.jpg') if option == 'kodi': @@ -479,6 +483,7 @@ def smallCoverCheck(self, path, number, imagecut, cover_small, c_word, option, C w = img.width h = img.height img.save(path + '/' + number + c_word + '-poster.jpg') + self.add_text_main('[+]Image Cut! ' + number + c_word + '-poster.jpg') time.sleep(1) os.remove(path + '/1.jpg') if option == 'plex': @@ -490,11 +495,12 @@ def smallCoverCheck(self, path, number, imagecut, cover_small, c_word, option, C w = img.width h = img.height img.save(path + '/poster.png') + self.add_text_main('[+]Image Cut! poster.png') os.remove(path + '/1.jpg') # ========================================================================打印NFO - def PrintFiles(self, option, path, c_word, naming_rule, part, cn_sub, json_data, filepath, failed_folder, tag): - title, studio, year, outline, runtime, director, actor_photo, actor, release, number, cover, website = get_info( + def PrintFiles(self, option, path, c_word, naming_rule, part, cn_sub, json_data, filepath, failed_folder): + title, studio, year, outline, runtime, director, actor_photo, actor, release, tag, number, cover, website = get_info( json_data) naming_rule = naming_rule.split('-') name_title = '' @@ -508,7 +514,7 @@ def PrintFiles(self, option, path, c_word, naming_rule, part, cn_sub, json_data, try: if not os.path.exists(path): os.makedirs(path) - with open(path + "/" + number + c_word + ".nfo", "wt", encoding='UTF-8') as code: + with open(path + "/" + number + part + c_word + ".nfo", "wt", encoding='UTF-8') as code: print('', file=code) print("", file=code) print(" " + name_title + part + "", file=code) @@ -521,12 +527,12 @@ def PrintFiles(self, option, path, c_word, naming_rule, part, cn_sub, json_data, print(" " + str(runtime).replace(" ", "") + "", file=code) print(" " + director + "", file=code) if option == 'emby': - print(" " + number + c_word + ".png", file=code) - print(" " + number + c_word + ".png", file=code) - print(" " + number + c_word + '.jpg' + "", file=code) + print(" " + number + part + c_word + ".png", file=code) + print(" " + number + part + c_word + ".png", file=code) + print(" " + number + part + c_word + '.jpg' + "", file=code) elif option == 'kodi': - print(" " + number + c_word + "-poster.jpg", file=code) - print(" " + number + c_word + '-fanart.jpg' + "", file=code) + print(" " + number + part + c_word + "-poster.jpg", file=code) + print(" " + number + part + c_word + '-fanart.jpg' + "", file=code) elif option == 'plex': print(" poster.png", file=code) print(" thumb.png", file=code) @@ -565,7 +571,7 @@ def PrintFiles(self, option, path, c_word, naming_rule, part, cn_sub, json_data, print(" " + cover + "", file=code) print(" " + website + "", file=code) print("", file=code) - self.add_text_main("[+]Writeed! " + number + c_word + ".nfo") + self.add_text_main("[+]Nfo Writed! " + number + part + c_word + ".nfo") except IOError as e: self.add_text_main("[-]Write Failed!") self.add_text_main(e) @@ -585,6 +591,7 @@ def cutImage(self, option, imagecut, path, number, c_word): h = img.height img2 = img.crop((w / 1.9, 0, w, h)) img2.save(path + '/poster.png') + self.add_text_main('[+]Image Cut! ' + 'poster.png') except: self.add_text_main('[-]Cover cut failed!') elif imagecut == 0: @@ -592,6 +599,7 @@ def cutImage(self, option, imagecut, path, number, c_word): w = img.width h = img.height img.save(path + '/poster.png') + self.add_text_main('[+]Image Cut! ' + 'poster.png') elif option == 'emby': if imagecut == 1: try: @@ -601,6 +609,7 @@ def cutImage(self, option, imagecut, path, number, c_word): h = img.height img2 = img.crop((w / 1.9, 0, w, h)) img2.save(path + '/' + number + c_word + '.png') + self.add_text_main('[+]Image Cut! ' + number + c_word + '.png') except: self.add_text_main('[-]Cover cut failed!') elif imagecut == 0: @@ -608,6 +617,7 @@ def cutImage(self, option, imagecut, path, number, c_word): w = img.width h = img.height img.save(path + '/' + number + c_word + '.png') + self.add_text_main('[+]Image Cut! ' + number + c_word + '.png') elif option == 'kodi': if imagecut == 1: try: @@ -617,6 +627,7 @@ def cutImage(self, option, imagecut, path, number, c_word): h = img.height img2 = img.crop((w / 1.9, 0, w, h)) img2.save(path + '/' + number + c_word + '-poster.jpg') + self.add_text_main('[+]Image Cut! ' + number + c_word + '-poster.jpg') except: self.add_text_main('[-]Cover cut failed!') elif imagecut == 0: @@ -629,6 +640,16 @@ def cutImage(self, option, imagecut, path, number, c_word): except: img = img.convert('RGB') img.save(path + '/' + number + c_word + '-poster.jpg') + self.add_text_main('[+]Image Cut! ' + number + c_word + '-poster.jpg') + + def copyRenameJpgToBackdrop(self, option, path, number, c_word): + 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 + '/' + number + c_word + '.jpg', path + '/Backdrop.jpg') + if option == 'kodi': + shutil.copy(path + '/' + number + c_word + '-fanart.jpg', path + '/Backdrop.jpg') def pasteFileToFolder(self, filepath, path, number, c_word, config): # 文件路径,番号,后缀,要移动至的位置 houzhui = str( @@ -636,8 +657,10 @@ def pasteFileToFolder(self, filepath, path, number, c_word, config): # 文件 try: if config['common']['soft_link'] == '1': # 如果soft_link=1 使用软链接 os.symlink(filepath, path + '/' + number + c_word + houzhui) + self.add_text_main('[+]Movie Linked! ' + number + c_word + houzhui) else: os.rename(filepath, path + '/' + number + c_word + houzhui) + self.add_text_main('[+]Movie Moved! ' + number + c_word + houzhui) if os.path.exists(os.getcwd() + '/' + number + c_word + '.srt'): # 字幕移动 os.rename(os.getcwd() + '/' + number + c_word + '.srt', path + '/' + number + c_word + '.srt') self.add_text_main('[+]Sub moved!') @@ -653,7 +676,6 @@ def pasteFileToFolder(self, filepath, path, number, c_word, config): # 文件 # os._exit(0) except PermissionError: self.add_text_main('[-]Error! Please run as administrator!') - # os._exit(0) def pasteFileToFolder_mode2(self, filepath, path, multi_part, number, part, c_word, config): # 文件路径,番号,后缀,要移动至的位置 if multi_part == 1: @@ -662,17 +684,19 @@ def pasteFileToFolder_mode2(self, filepath, path, multi_part, number, part, c_wo re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group()) try: if config['common']['soft_link'] == '1': - os.symlink(filepath, path + '/' + number + part + c_word + houzhui) + os.symlink(filepath, path + '/' + number + c_word + houzhui) + self.add_text_main('[+]Movie Linked! ' + number + c_word + houzhui) else: - os.rename(filepath, path + '/' + number + part + c_word + houzhui) + os.rename(filepath, path + '/' + number + c_word + houzhui) + self.add_text_main('[+]Movie Moved! ' + number + c_word + houzhui) if os.path.exists(number + '.srt'): # 字幕移动 - os.rename(number + part + c_word + '.srt', path + '/' + number + part + c_word + '.srt') + os.rename(number + part + c_word + '.srt', path + '/' + number + c_word + '.srt') self.add_text_main('[+]Sub moved!') elif os.path.exists(number + part + c_word + '.ass'): - os.rename(number + part + c_word + '.ass', path + '/' + number + part + c_word + '.ass') + os.rename(number + part + c_word + '.ass', path + '/' + number + c_word + '.ass') self.add_text_main('[+]Sub moved!') elif os.path.exists(number + part + c_word + '.sub'): - os.rename(number + part + c_word + '.sub', path + '/' + number + part + c_word + '.sub') + os.rename(number + part + c_word + '.sub', path + '/' + number + c_word + '.sub') self.add_text_main('[+]Sub moved!') self.add_text_main('[!]Success') except FileExistsError: @@ -751,6 +775,10 @@ def core_main(self, file_path, number_th): c_word = '' option = '' cn_sub = '' + filepath = file_path # 影片的路径 + number = number_th.replace('_', '-') + if not re.match('\D{2,}0\d{4,}', number): + number = number.upper() config_file = 'config.ini' Config = ConfigParser() Config.read(config_file, encoding='UTF-8') @@ -761,8 +789,6 @@ def core_main(self, file_path, number_th): program_mode = Config['common']['main_mode'] # 运行模式 failed_folder = Config['common']['failed_output_folder'] # 失败输出目录 success_folder = Config['common']['success_output_folder'] # 成功输出目录 - filepath = file_path # 影片的路径 - number = number_th # =======================================================================抓取网站设置 json_data = {} if self.Ui.radioButton_all.isChecked(): @@ -770,15 +796,17 @@ def core_main(self, file_path, number_th): elif self.Ui.radioButton_javdb.isChecked(): time.sleep(3) json_data = getDataFromJSON(number, Config, 2) # 仅javdb - imagecut = json_data['imagecut'] - tag = json_data['tag'] - # =======================================================================调试模式 - self.debug_mode(json_data, Config) # =======================================================================是否找到影片信息 - if json_data['title'] == '' or number == '': + if json_data['website'] == 'timeout': + self.add_text_main('[-]Connect Failed! Please check your Proxy or Network!') + self.moveFailedFolder(filepath, failed_folder) + return + if json_data['title'] == '' or json_data['number'] == '': self.add_text_main('[-]Movie Data not found!') self.moveFailedFolder(filepath, failed_folder) return + # =======================================================================调试模式 + self.debug_mode(json_data, Config) # =======================================================================判断-C,-CD后缀 if '-CD' in filepath or '-cd' in filepath: multi_part = 1 @@ -796,18 +824,18 @@ def core_main(self, file_path, number_th): self.add_text_main('[+]Folder : ' + path) self.add_text_main('[+]From : ' + json_data['website']) # =======================================================================刮削模式 + number = json_data['number'] if program_mode == '1': if multi_part == 1: - number += part # 这时number会被附加上CD1后缀 - self.smallCoverCheck(path, number, imagecut, json_data['cover_small'], c_word, option, Config, filepath, + number += part # 这时number会被附加上-CDx后缀 + self.smallCoverCheck(path, number, json_data['imagecut'], json_data['cover_small'], c_word, option, Config, filepath, failed_folder) # 检查小封面 self.imageDownload(option, json_data['cover'], number, c_word, path, multi_part, Config, filepath, failed_folder) # creatFoder会返回番号路径 - self.cutImage(option, imagecut, path, number, c_word) # 裁剪图 - copyRenameJpgToBackdrop(option, path, number, c_word) + self.cutImage(option, json_data['imagecut'], path, number, c_word) # 裁剪图 + self.copyRenameJpgToBackdrop(option, path, number, c_word) self.PrintFiles(option, path, c_word, json_data['naming_rule'], part, cn_sub, json_data, filepath, - failed_folder, - tag) # 打印文件 + failed_folder) # 打印文件 self.pasteFileToFolder(filepath, path, number, c_word, Config) # 移动文件 # =======================================================================整理模式 elif program_mode == '2': @@ -822,15 +850,17 @@ def UpdateCheck(self): check = 0 if UpdateCheckSwitch(check) == '1': html2 = get_html('https://raw.githubusercontent.com/moyy996/AVDC/master/update_check.json') + if html2 == 'ProxyError': + return 'ProxyError' html = json.loads(str(html2)) - if float(self.version) < float(html['version']): self.add_text_main('[*] * New update ' + html['version'] + ' *') self.add_text_main('[*] ↓ Download ↓') self.add_text_main('[*] ' + html['download']) self.add_text_main('[*]======================================================') else: - self.add_text_main('[!]No newer version available!') + self.add_text_main('[!]No Newer Version Available!') + return 'True' def CreatFailedFolder(self, failed_folder): if not os.path.exists(failed_folder + '/'): # 新建failed文件夹 @@ -857,13 +887,18 @@ def AVDC_Main(self): success_folder = config['common']['success_output_folder'] failed_folder = config['common']['failed_output_folder'] # 失败输出目录 escape_folder = config['escape']['folders'] # 多级目录刮削需要排除的目录 - # =======================================================================检测更新,新建failed目录,获取影片列表 + # =======================================================================检测更新,判断网络情况,新建failed目录,获取影片列表 os.chdir(os.getcwd()) - self.UpdateCheck() + if self.UpdateCheck() == 'ProxyError': + self.add_text_main('[-]Connect Failed! Please check your Proxy or Network!') + self.Ui.pushButton_start_cap.setEnabled(True) + self.add_text_main("[*]======================================================") + return self.CreatFailedFolder(failed_folder) # 新建failed文件夹 movie_list = movie_lists(escape_folder) # 获取所有需要刮削的影片列表 count = 0 count_all = str(len(movie_list)) + self.add_text_main("[*]======================================================") self.add_text_main('[+]Find ' + count_all + ' movies') if config['common']['soft_link'] == '1': self.add_text_main('[!] --- Soft link mode is ENABLE! ----') @@ -893,6 +928,7 @@ def AVDC_Main(self): self.add_text_main('[-]Move ' + movie + ' to failed folder') except shutil.Error as error_info: self.add_text_main('[-] ' + str(error_info)) + self.add_text_main("[*]======================================================") continue self.Ui.pushButton_start_cap.setEnabled(True) self.CEF(success_folder) diff --git a/avsox.py b/avsox.py index 1aec377b6..35e1f12dc 100644 --- a/avsox.py +++ b/avsox.py @@ -21,7 +21,7 @@ def getTitle(a): try: html = etree.fromstring(a, etree.HTMLParser()) result = str(html.xpath('/html/body/div[2]/h3/text()')).strip(" ['']") # [0] - return result.replace('/', '') + return result.replace('/', '').replace('_', '-') except: return '' @@ -101,12 +101,10 @@ def main(number): result1 = str(html.xpath('//*[@id="waterfall"]/div/a/@href')).strip(" ['']") if result1 == '' or result1 == 'null' or result1 == 'None': a = get_html('https://avsox.host/cn/search/' + number.replace('-', '_')) - print(a) html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() result1 = str(html.xpath('//*[@id="waterfall"]/div/a/@href')).strip(" ['']") if result1 == '' or result1 == 'null' or result1 == 'None': a = get_html('https://avsox.host/cn/search/' + number.replace('_', '')) - print(a) html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() result1 = str(html.xpath('//*[@id="waterfall"]/div/a/@href')).strip(" ['']") web = get_html(result1) @@ -115,7 +113,7 @@ def main(number): try: dic = { 'actor': getActor(web), - 'title': getTitle(web).strip(getNum(web)), + 'title': getTitle(web).strip(getNum(web)).strip().replace(' ', '-'), 'studio': getStudio(info), 'outline': '', # 'runtime': getRuntime(info), @@ -133,10 +131,16 @@ def main(number): 'source': 'avsox.py', } except: - dic = { - 'title': '', - } + if a == 'ProxyError': + dic = { + 'title': '', + 'website': 'timeout', + } + else: + dic = { + 'title': '', + } js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') return js -# print(main('012717_472')) +# print(main('050517-522')) diff --git a/config.ini b/config.ini index f031057f4..0e7807711 100644 --- a/config.ini +++ b/config.ini @@ -8,7 +8,7 @@ website = all [proxy] proxy = -timeout = 10 +timeout = 7 retry = 3 [Name_Rule] diff --git a/core.py b/core.py index 548e2cb05..221ae6761 100755 --- a/core.py +++ b/core.py @@ -47,15 +47,8 @@ def getDataFromJSON(file_number, config, mode): # 从JSON返回元数据 # == elif 'siro' in file_number or 'SIRO' in file_number or 'Siro' in file_number: json_data = json.loads(siro.main(file_number)) - elif not '-' in file_number or '_' in file_number: + elif re.match('\D{2,}00\d{4,}', file_number): json_data = json.loads(fanza.main(file_number)) - if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取 - json_data = json.loads(javbus.main(file_number)) - if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取 - json_data = json.loads(avsox.main(file_number)) - if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取 - json_data = json.loads(javdb.main(file_number)) - # == else: json_data = json.loads(javbus.main(file_number)) if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取 @@ -66,8 +59,10 @@ def getDataFromJSON(file_number, config, mode): # 从JSON返回元数据 json_data = json.loads(javdb.main(file_number)) # ================================================网站规则添加结束================================================ - + if json_data['website'] == 'timeout': + return json_data title = json_data['title'] + number = json_data['number'].replace('_', '-') actor_list = str(json_data['actor']).strip("[ ]").replace("'", '').split(',') # 字符串转列表 release = json_data['release'] try: @@ -99,6 +94,7 @@ def getDataFromJSON(file_number, config, mode): # 从JSON返回元数据 # 返回处理后的json_data json_data['title'] = title + json_data['number'] = number json_data['actor'] = actor json_data['release'] = release json_data['cover_small'] = cover_small @@ -118,17 +114,8 @@ def get_info(json_data): # 返回json里的数据 actor_photo = json_data['actor_photo'] actor = json_data['actor'] release = json_data['release'] + tag = json_data['tag'] number = json_data['number'] cover = json_data['cover'] website = json_data['website'] - return title, studio, year, outline, runtime, director, actor_photo, actor, release, number, cover, website - - -def copyRenameJpgToBackdrop(option, path, number, c_word): - 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 + '/' + number + c_word + '.jpg', path + '/Backdrop.jpg') - if option == 'kodi': - shutil.copy(path + '/' + number + c_word + '-fanart.jpg', path + '/Backdrop.jpg') + return title, studio, year, outline, runtime, director, actor_photo, actor, release, tag, number, cover, website diff --git a/fanza.py b/fanza.py index 0de740675..de9c189ee 100644 --- a/fanza.py +++ b/fanza.py @@ -23,6 +23,16 @@ def getActor(a): # //*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1] return result +def getActorPhoto(actor): # //*[@id="star_qdt"]/li/a/img + actor = actor.split(',') + d = {} + for i in actor: + if ',' not in i: + p = {i: ''} + d.update(p) + return d + + def getStudio(a): html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() try: @@ -41,9 +51,9 @@ def getRuntime(a): def getLabel(a): html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() try: - result1 = html.xpath("//td[contains(text(),'シリーズ:')]/following-sibling::td/a/text()")[0] + result1 = html.xpath("//td[contains(text(),'レーベル:')]/following-sibling::td/a/text()")[0] except: - result1 = html.xpath("//td[contains(text(),'シリーズ:')]/following-sibling::td/text()")[0] + result1 = html.xpath("//td[contains(text(),'レーベル:')]/following-sibling::td/text()")[0] return result1 @@ -110,13 +120,14 @@ def main(number): htmlcode = get_html('https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=' + number) url = 'https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=' + number try: + actor = getActor(htmlcode) dic = { 'title': getTitle(htmlcode).strip(getActor(htmlcode)), 'studio': getStudio(htmlcode), 'outline': getOutline(htmlcode), 'runtime': getRuntime(htmlcode), 'director': getDirector(htmlcode), - 'actor': getActor(htmlcode), + 'actor': actor, 'release': getRelease(htmlcode), 'number': getNum(htmlcode), 'cover': getCover(htmlcode, number), @@ -124,17 +135,23 @@ def main(number): 'tag': getTag(htmlcode), 'label': getLabel(htmlcode), 'year': getYear(getRelease(htmlcode)), # str(re.search('\d{4}',getRelease(a)).group()), - 'actor_photo': '', + 'actor_photo': getActorPhoto(actor), 'website': url, 'source': 'siro.py', } except: - dic = { - 'title': '', - } + if htmlcode == 'ProxyError': + dic = { + 'title': '', + 'website': 'timeout', + } + else: + dic = { + 'title': '', + } js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':')) # .encode('UTF-8') return js # main('DV-1562') # input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。") -# print(main('ssni00384')) +# print(main('ssni00684')) diff --git a/fc2fans_club.py b/fc2fans_club.py index 1de7366a6..1b19825f9 100755 --- a/fc2fans_club.py +++ b/fc2fans_club.py @@ -22,6 +22,15 @@ def getActor(htmlcode): return '' +def getActorPhoto(actor): # //*[@id="star_qdt"]/li/a/img + actor = actor.split('/') + d = {} + for i in actor: + p = {i: ''} + d.update(p) + return d + + def getStudio(htmlcode): # 获取厂商 html = etree.fromstring(htmlcode, etree.HTMLParser()) result = str(html.xpath('/html/body/div[2]/div/div[1]/h5[3]/a[1]/text()')).strip(" ['']") @@ -80,31 +89,37 @@ def main(number): 'http://adult.contents.fc2.com/article_search.php?id=' + number + '&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php') htmlcode = ADC_function.get_html('https://fc2club.com//html/FC2-' + number + '.html') actor = getActor(htmlcode) - if getActor(htmlcode) == '': + if len(actor) == 0: actor = 'FC2系列' try: dic = { - 'title': getTitle(htmlcode), + 'title': getTitle(htmlcode).replace(' ', '-'), 'studio': getStudio(htmlcode), 'year': '', # str(re.search('\d{4}',getRelease(number)).group()), 'outline': getOutline(htmlcode2), 'runtime': getYear(getRelease(htmlcode)), 'director': getStudio(htmlcode), - 'actor': actor, + 'actor': actor.replace('/', ','), 'release': getRelease(number), 'number': 'FC2-' + number, 'cover': getCover(htmlcode, number, htmlcode2), 'imagecut': 0, 'tag': getTag(htmlcode), - 'actor_photo': '', + 'actor_photo': getActorPhoto(actor), 'website': 'https://fc2club.com//html/FC2-' + number + '.html', - 'source': 'https://fc2club.com//html/FC2-' + number + '.html', + 'source': 'fc2fans_club.py', } except: - dic = { - 'title': '', - } + if htmlcode2 == 'ProxyError': + dic = { + 'title': '', + 'website': 'timeout', + } + else: + dic = { + 'title': '', + } js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') return js -# print(main('1051725')) +# print(main('1121040')) diff --git a/javbus.py b/javbus.py index 3018b1631..426c6c8a1 100755 --- a/javbus.py +++ b/javbus.py @@ -89,7 +89,13 @@ def getOutline(htmlcode): # 获取演员 def getSerise(htmlcode): html = etree.fromstring(htmlcode, etree.HTMLParser()) - result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[7]/a/text()')).strip(" ['']") + result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[6]/a/text()')).strip(" ['']") + return result + + +def getSerise_uncensored(htmlcode): + html = etree.fromstring(htmlcode, etree.HTMLParser()) + result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[5]/a/text()')).strip(" ['']") return result @@ -141,23 +147,37 @@ def main_uncensored(number): if getTitle(htmlcode) == '': htmlcode = get_html('https://www.javbus.com/' + number.replace('-', '_')) dww_htmlcode = get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", '')) - dic = { - 'title': str(re.sub('\w+-\d+-', '', getTitle(htmlcode))).replace(getNum(htmlcode) + '-', ''), - 'studio': getStudio(htmlcode), - 'year': getYear(htmlcode), - 'outline': getOutline(dww_htmlcode), - 'runtime': getRuntime(htmlcode), - 'director': getDirector(htmlcode), - 'actor': getActor(htmlcode), - 'release': getRelease(htmlcode), - 'number': getNum(htmlcode), - 'cover': getCover(htmlcode), - 'tag': getTag(htmlcode), - 'label': getSerise(htmlcode), - 'imagecut': 0, - 'actor_photo': '', - 'website': 'https://www.javbus.com/' + number, - 'source': 'javbus.py', - } + try: + dic = { + 'title': str(re.sub('\w+-\d+-', '', getTitle(htmlcode))).replace(getNum(htmlcode) + '-', ''), + 'studio': getStudio(htmlcode), + 'year': getYear(htmlcode), + 'outline': getOutline(dww_htmlcode), + 'runtime': getRuntime(htmlcode), + 'director': getDirector(htmlcode), + 'actor': getActor(htmlcode), + 'release': getRelease(htmlcode), + 'number': getNum(htmlcode), + 'cover': getCover(htmlcode), + 'tag': getTag(htmlcode), + 'label': getSerise_uncensored(htmlcode), + 'imagecut': 0, + 'actor_photo': getActorPhoto(htmlcode), + 'website': 'https://www.javbus.com/' + number, + 'source': 'javbus.py', + } + except: + if htmlcode == 'ProxyError': + dic = { + 'title': '', + 'website': 'timeout', + } + else: + dic = { + 'title': '', + } js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') return js + +# print(main('SSNI-658')) +# print(main_uncensored('050517_522')) diff --git a/javdb.py b/javdb.py index 4fca86724..4f6f02b6b 100755 --- a/javdb.py +++ b/javdb.py @@ -18,19 +18,17 @@ def getTitle(a): def getActor(a): # //*[@id="center_column"]/div[2]/div[1]/div/table/tbody/tr[1]/td/text() html = etree.fromstring(a, etree.HTMLParser()) # //table/tr[1]/td[1]/text() - result1 = str(html.xpath('//strong[contains(text(),"演員")]/../following-sibling::span/text()')).strip(" ['']") - result2 = str(html.xpath('//strong[contains(text(),"演員")]/../following-sibling::span/a/text()')).strip(" ['']") - return str(result1 + result2).strip('+').replace(",\\xa0", "").replace("'", "").replace(' ', '').replace(',,', - '').lstrip( - ',').replace(',', ', ') + result1 = html.xpath('//strong[contains(text(),"演員")]/../following-sibling::span/text()') + result2 = html.xpath('//strong[contains(text(),"演員")]/../following-sibling::span/a/text()') + return result1 + result2 def getActorPhoto(actor): # //*[@id="star_qdt"]/li/a/img - a = actor.split(',') d = {} - for i in a: - p = {i: ''} - d.update(p) + for i in actor: + if ',' not in i or ')' in i: + p = {i: ''} + d.update(p) return d @@ -130,10 +128,8 @@ def main(number): result1 = html.xpath('//*[@id="videos"]/div/div/a/@href')[count - 1] b = get_html('https://javdb.com' + result1).replace(u'\xa0', u' ') dic = { - 'actor': getActor(b), - 'title': getTitle(b).replace("\\n", '').replace(' ', '').replace(getActor(a), '').replace(getNum(a), - '').replace( - '无码', '').replace('有码', '').lstrip(' ').replace(number, ''), + 'actor': str(getActor(b)).strip(" [',']").replace('\'', ''), + 'title': getTitle(b).replace("\\n", '').replace('_', '-').replace(number, '').strip().replace(' ', '-').replace(' ', '-'), 'studio': getStudio(b), 'outline': getOutline(b), 'runtime': getRuntime(b), @@ -152,17 +148,21 @@ def main(number): } if getNum(b) != number: # 与搜索到的番号不匹配 dic['title'] = '' - dic['number'] = '' - js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') - return js except: - dic = { - 'title': '', - } - js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') - return js - - -# main('MIDE-139') + if a == 'ProxyError': + dic = { + 'title': '', + 'website': 'timeout', + } + else: + dic = { + 'title': '', + } + js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') + return js + + +# print(main('SSNI-658')) # input("[+][+]Press enter key exit, you can check the error messge before you exit.\n[+][+]按回车键结束,你可以在结束之前查看和错误信息。") -# print(main('YMDD-178')) +# print(main('ABS-141')) +# print(main('050517-522')) diff --git a/siro.py b/siro.py index 844f24d42..376ef69eb 100755 --- a/siro.py +++ b/siro.py @@ -116,24 +116,35 @@ def main(number2): '').replace('\n ', '').replace( '\n ', '') - dic = { - 'title': getTitle(htmlcode).replace("\\n", '').replace(' ', ''), - 'studio': getStudio(a), - 'outline': getOutline(htmlcode), - 'runtime': getRuntime(a), - 'director': getDirector(a), - 'actor': getActor(a), - 'release': getRelease(a), - 'number': getNum(a), - 'cover': getCover(htmlcode), - 'imagecut': 0, - 'tag': getTag(a), - 'label': getLabel(a), - 'year': getYear(getRelease(a)), # str(re.search('\d{4}',getRelease(a)).group()), - 'actor_photo': '', - 'website': 'https://www.mgstage.com/product/product_detail/' + str(number) + '/', - 'source': 'siro.py', - } + try: + dic = { + 'title': getTitle(htmlcode).replace("\\n", '').replace(' ', ''), + 'studio': getStudio(a), + 'outline': getOutline(htmlcode), + 'runtime': getRuntime(a), + 'director': getDirector(a), + 'actor': getActor(a), + 'release': getRelease(a), + 'number': getNum(a), + 'cover': getCover(htmlcode), + 'imagecut': 0, + 'tag': getTag(a), + 'label': getLabel(a), + 'year': getYear(getRelease(a)), # str(re.search('\d{4}',getRelease(a)).group()), + 'actor_photo': '', + 'website': 'https://www.mgstage.com/product/product_detail/' + str(number) + '/', + 'source': 'siro.py', + } + except: + if htmlcode == 'ProxyError': + dic = { + 'title': '', + 'website': 'timeout', + } + else: + dic = { + 'title': '', + } js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') return js diff --git a/update_check.json b/update_check.json index 12eabe252..2a9bdc306 100644 --- a/update_check.json +++ b/update_check.json @@ -1,5 +1,5 @@ { - "version": "3.22", - "version_show":"3.22", + "version": "3.3", + "version_show":"3.3", "download": "https://github.com/moyy996/AVDC/releases" }