Update 1.3
This commit is contained in:
		
							parent
							
								
									ae99c652f5
								
							
						
					
					
						commit
						73c0126fb8
					
				| @ -14,7 +14,7 @@ os.chdir(os.getcwd()) | |||||||
| 
 | 
 | ||||||
| # ============global var=========== | # ============global var=========== | ||||||
| 
 | 
 | ||||||
| version='1.2' | version='1.3' | ||||||
| 
 | 
 | ||||||
| config = ConfigParser() | config = ConfigParser() | ||||||
| config.read(config_file, encoding='UTF-8') | config.read(config_file, encoding='UTF-8') | ||||||
| @ -69,11 +69,11 @@ def lists_from_test(custom_nuber): #电影列表 | |||||||
|     a.append(custom_nuber) |     a.append(custom_nuber) | ||||||
|     return a |     return a | ||||||
| def CEF(path): | def CEF(path): | ||||||
|  |     try: | ||||||
|         files = os.listdir(path)  # 获取路径下的子文件(夹)列表 |         files = os.listdir(path)  # 获取路径下的子文件(夹)列表 | ||||||
|         for file in files: |         for file in files: | ||||||
|         try: #试图删除空目录,非空目录删除会报错 |  | ||||||
|             os.removedirs(path + '/' + file)  # 删除这个空文件夹 |             os.removedirs(path + '/' + file)  # 删除这个空文件夹 | ||||||
|             print('[+]Deleting empty folder',path + '/' + file) |             print('[+]Deleting empty folder', path + '/' + file) | ||||||
|     except: |     except: | ||||||
|         a='' |         a='' | ||||||
| def rreplace(self, old, new, *max): | def rreplace(self, old, new, *max): | ||||||
| @ -83,30 +83,27 @@ def rreplace(self, old, new, *max): | |||||||
|         count = max[0] |         count = max[0] | ||||||
|     return new.join(self.rsplit(old, count)) |     return new.join(self.rsplit(old, count)) | ||||||
| def getNumber(filepath): | def getNumber(filepath): | ||||||
|  |     filepath = filepath.replace('.\\','') | ||||||
|     try:  # 普通提取番号 主要处理包含减号-的番号 |     try:  # 普通提取番号 主要处理包含减号-的番号 | ||||||
|  |         filepath = filepath.replace("_", "-") | ||||||
|  |         filepath.strip('22-sht.me').strip('-HD').strip('-hd') | ||||||
|  |         filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath))  # 去除文件名中时间 | ||||||
|         try: |         try: | ||||||
|             filepath1 = filepath.replace("_", "-") |  | ||||||
|             filepath1.strip('22-sht.me').strip('-HD').strip('-hd') |  | ||||||
|             filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath1))  # 去除文件名中时间 |  | ||||||
|             file_number = re.search('\w+-\d+', filename).group() |             file_number = re.search('\w+-\d+', filename).group() | ||||||
|             return file_number |         except:  # 提取类似mkbd-s120番号 | ||||||
|         except: |             file_number = re.search('\w+-\w+\d+', filename).group() | ||||||
|             filepath1 = filepath.replace("_", "-") |  | ||||||
|             filepath1.strip('22-sht.me').strip('-HD').strip('-hd') |  | ||||||
|             filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath1))  # 去除文件名中时间 |  | ||||||
|             file_number = re.search('\w+-\w+', filename).group() |  | ||||||
|         return file_number |         return file_number | ||||||
|     except:  # 提取不含减号-的番号 |     except:  # 提取不含减号-的番号 | ||||||
|         try: |         try: | ||||||
|             filename1 = str(re.sub("ts6\d", "", filepath)).strip('Tokyo-hot').strip('tokyo-hot') |             filename = str(re.sub("ts6\d", "", filepath)).strip('Tokyo-hot').strip('tokyo-hot') | ||||||
|             filename0 = str(re.sub(".*?\.com-\d+", "", filename1)).strip('_') |             filename = str(re.sub(".*?\.com-\d+", "", filename)).replace('_', '') | ||||||
|             file_number = str(re.search('\w+\d{4}', filename0).group(0)) |             file_number = str(re.search('\w+\d{4}', filename).group(0)) | ||||||
|             return file_number |             return file_number | ||||||
|         except:  # 提取无减号番号 |         except:  # 提取无减号番号 | ||||||
|             filename1 = str(re.sub("ts6\d", "", filepath))  # 去除ts64/265 |             filename = str(re.sub("ts6\d", "", filepath))  # 去除ts64/265 | ||||||
|             filename0 = str(re.sub(".*?\.com-\d+", "", filename1)) |             filename = str(re.sub(".*?\.com-\d+", "", filename)) | ||||||
|             file_number2 = str(re.match('\w+', filename0).group()) |             file_number = str(re.match('\w+', filename).group()) | ||||||
|             file_number = str(file_number2.replace(re.match("^[A-Za-z]+", file_number2).group(),re.match("^[A-Za-z]+", file_number2).group() + '-')) |             file_number = str(file_number.replace(re.match("^[A-Za-z]+", file_number).group(),re.match("^[A-Za-z]+", file_number).group() + '-')) | ||||||
|             return file_number |             return file_number | ||||||
| 
 | 
 | ||||||
| def RunCore(): | def RunCore(): | ||||||
|  | |||||||
							
								
								
									
										73
									
								
								core.py
									
									
									
									
									
								
							
							
						
						
									
										73
									
								
								core.py
									
									
									
									
									
								
							| @ -50,8 +50,8 @@ cover_small='' | |||||||
| naming_rule  =''#eval(config['Name_Rule']['naming_rule']) | naming_rule  =''#eval(config['Name_Rule']['naming_rule']) | ||||||
| location_rule=''#eval(config['Name_Rule']['location_rule']) | location_rule=''#eval(config['Name_Rule']['location_rule']) | ||||||
| program_mode   = Config['common']['main_mode'] | program_mode   = Config['common']['main_mode'] | ||||||
| failed_folder= Config['common']['failed_output_folder'] | failed_folder  = Config['common']['failed_output_folder'] | ||||||
| success_folder=Config['common']['success_output_folder'] | success_folder = Config['common']['success_output_folder'] | ||||||
| #=====================本地文件处理=========================== | #=====================本地文件处理=========================== | ||||||
| 
 | 
 | ||||||
| def moveFailedFolder(): | def moveFailedFolder(): | ||||||
| @ -96,6 +96,7 @@ def getDataFromJSON(file_number): #从JSON返回元数据 | |||||||
|     global website |     global website | ||||||
|     global actor_photo |     global actor_photo | ||||||
|     global cover_small |     global cover_small | ||||||
|  |     global json_data | ||||||
| 
 | 
 | ||||||
|     global naming_rule |     global naming_rule | ||||||
|     global location_rule |     global location_rule | ||||||
| @ -115,8 +116,7 @@ def getDataFromJSON(file_number): #从JSON返回元数据 | |||||||
|             json_data = json.loads(javdb.main(file_number)) |             json_data = json.loads(javdb.main(file_number)) | ||||||
|     # == |     # == | ||||||
|     elif 'fc2' in file_number or 'FC2' in file_number: |     elif 'fc2' in file_number or 'FC2' in file_number: | ||||||
|         json_data = json.loads(fc2fans_club.main( |         json_data = json.loads(fc2fans_club.main(file_number)) | ||||||
|             file_number)) |  | ||||||
|     # == |     # == | ||||||
|     elif 'HEYZO' in number or 'heyzo' in number or 'Heyzo' in number: |     elif 'HEYZO' in number or 'heyzo' in number or 'Heyzo' in number: | ||||||
|         json_data = json.loads(avsox.main(file_number)) |         json_data = json.loads(avsox.main(file_number)) | ||||||
| @ -163,24 +163,15 @@ def getDataFromJSON(file_number): #从JSON返回元数据 | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     # ====================处理异常字符====================== #\/:*?"<>| |     # ====================处理异常字符====================== #\/:*?"<>| | ||||||
|     if '\\' in title: |     title = title.replace('\\', '') | ||||||
|         title=title.replace('\\', ' ') |     title = title.replace('/', '') | ||||||
|     elif r'/' in title: |     title = title.replace(':', '') | ||||||
|         title=title.replace(r'/', '') |     title = title.replace('*', '') | ||||||
|     elif ':' in title: |     title = title.replace('?', '') | ||||||
|         title=title.replace(':', '') |     title = title.replace('"', '') | ||||||
|     elif '*' in title: |     title = title.replace('<', '') | ||||||
|         title=title.replace('*', '') |     title = title.replace('>', '') | ||||||
|     elif '?' in title: |     title = title.replace('|', '') | ||||||
|         title=title.replace('?', '') |  | ||||||
|     elif '"' in title: |  | ||||||
|         title=title.replace('"', '') |  | ||||||
|     elif '<' in title: |  | ||||||
|         title=title.replace('<', '') |  | ||||||
|     elif '>' in title: |  | ||||||
|         title=title.replace('>', '') |  | ||||||
|     elif '|' in title: |  | ||||||
|         title=title.replace('|', '') |  | ||||||
|     # ====================处理异常字符 END================== #\/:*?"<>| |     # ====================处理异常字符 END================== #\/:*?"<>| | ||||||
| 
 | 
 | ||||||
|     naming_rule   = eval(config['Name_Rule']['naming_rule']) |     naming_rule   = eval(config['Name_Rule']['naming_rule']) | ||||||
| @ -205,9 +196,8 @@ def smallCoverCheck(): | |||||||
| def creatFolder(): #创建文件夹 | def creatFolder(): #创建文件夹 | ||||||
|     global actor |     global actor | ||||||
|     global path |     global path | ||||||
|     if len(actor) > 240:                    #新建成功输出文件夹 |     if len(os.getcwd()+path) > 240:                    #新建成功输出文件夹 | ||||||
|         path = success_folder+'/'+location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录 |         path = success_folder+'/'+location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录 | ||||||
|         #print(path) |  | ||||||
|     else: |     else: | ||||||
|         path = success_folder+'/'+location_rule |         path = success_folder+'/'+location_rule | ||||||
|         #print(path) |         #print(path) | ||||||
| @ -286,10 +276,6 @@ def imageDownload(filepath): #封面是否下载成功,否则移动到failed | |||||||
|         DownloadFileWithFilename(cover, 'fanart.jpg', path) |         DownloadFileWithFilename(cover, 'fanart.jpg', path) | ||||||
|         print('[+]Image Downloaded!', path + '/fanart.jpg') |         print('[+]Image Downloaded!', path + '/fanart.jpg') | ||||||
| def PrintFiles(filepath): | def PrintFiles(filepath): | ||||||
|     #global path |  | ||||||
|     global title |  | ||||||
|     global cn_sub |  | ||||||
|     global actor_photo |  | ||||||
|     try: |     try: | ||||||
|         if not os.path.exists(path): |         if not os.path.exists(path): | ||||||
|             os.makedirs(path) |             os.makedirs(path) | ||||||
| @ -437,15 +423,8 @@ def pasteFileToFolder(filepath, path): #文件路径,番号,后缀,要移 | |||||||
|         print('[-]File Exists! Please check your movie!') |         print('[-]File Exists! Please check your movie!') | ||||||
|         print('[-]move to the root folder of the program.') |         print('[-]move to the root folder of the program.') | ||||||
|         os._exit(0) |         os._exit(0) | ||||||
| def pasteFileToFolder_mode2(filepath, path): #文件路径,番号,后缀,要移动至的位置 |     except PermissionError: | ||||||
|     global houzhui |         print('[-]Error! Please run as administrator!') | ||||||
|     houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group()) |  | ||||||
|     try: |  | ||||||
|         os.rename(filepath, path + houzhui) |  | ||||||
|         print('[+]Movie ' + number + ' move to target folder Finished!') |  | ||||||
|     except: |  | ||||||
|         print('[-]File Exists! Please check your movie!') |  | ||||||
|         print('[-]move to the root folder of the program.') |  | ||||||
|         os._exit(0) |         os._exit(0) | ||||||
| def renameJpgToBackdrop_copy(): | def renameJpgToBackdrop_copy(): | ||||||
|     if option == 'plex': |     if option == 'plex': | ||||||
| @ -453,7 +432,6 @@ def renameJpgToBackdrop_copy(): | |||||||
|         shutil.copy(path + '/poster.png', path + '/thumb.png') |         shutil.copy(path + '/poster.png', path + '/thumb.png') | ||||||
|     if option == 'emby': |     if option == 'emby': | ||||||
|         shutil.copy(path + '/' + number + '.jpg', path + '/Backdrop.jpg') |         shutil.copy(path + '/' + number + '.jpg', path + '/Backdrop.jpg') | ||||||
| 
 |  | ||||||
| def renameBackdropToJpg_copy(): | def renameBackdropToJpg_copy(): | ||||||
|     if option == 'plex': |     if option == 'plex': | ||||||
|         shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg') |         shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg') | ||||||
| @ -468,6 +446,20 @@ def get_part(filepath): | |||||||
|     except: |     except: | ||||||
|         print("[-]failed!Please rename the filename again!") |         print("[-]failed!Please rename the filename again!") | ||||||
|         moveFailedFolder() |         moveFailedFolder() | ||||||
|  | def debug_mode(): | ||||||
|  |     try: | ||||||
|  |         if config['debug_mode']['switch'] == '1': | ||||||
|  |             print('[+] ---Debug info---') | ||||||
|  |             for i, v in json_data.items(): | ||||||
|  |                 if i == 'outline': | ||||||
|  |                     print('[+] -', i, ':', len(v), 'characters') | ||||||
|  |                     continue | ||||||
|  |                 if i == 'actor_photo' or i == 'year': | ||||||
|  |                     continue | ||||||
|  |                 print('[+] -', i, ':', v) | ||||||
|  |             print('[+] ---Debug info---') | ||||||
|  |     except: | ||||||
|  |         aaa='' | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     filepath=argparse_get_file()[0] #影片的路径 |     filepath=argparse_get_file()[0] #影片的路径 | ||||||
| 
 | 
 | ||||||
| @ -488,14 +480,15 @@ if __name__ == '__main__': | |||||||
|         number = argparse_get_file()[1] |         number = argparse_get_file()[1] | ||||||
|     CreatFailedFolder() |     CreatFailedFolder() | ||||||
|     getDataFromJSON(number)  # 定义番号 |     getDataFromJSON(number)  # 定义番号 | ||||||
|  |     debug_mode() | ||||||
|     creatFolder()  # 创建文件夹 |     creatFolder()  # 创建文件夹 | ||||||
|     if program_mode == '1': |     if program_mode == '1': | ||||||
|         if part == '-CD1' or multi_part == 0: |         if part == '-CD1' or multi_part == 0: | ||||||
|  |             smallCoverCheck() | ||||||
|             imageDownload(filepath)  # creatFoder会返回番号路径 |             imageDownload(filepath)  # creatFoder会返回番号路径 | ||||||
|             if multi_part == 1: |             if multi_part == 1: | ||||||
|                 number += part |                 number += part | ||||||
|             PrintFiles(filepath)  # 打印文件 |             PrintFiles(filepath)  # 打印文件 | ||||||
|             smallCoverCheck() |  | ||||||
|             cutImage()  # 裁剪图 |             cutImage()  # 裁剪图 | ||||||
|             renameJpgToBackdrop_copy() |             renameJpgToBackdrop_copy() | ||||||
|         else: |         else: | ||||||
| @ -503,4 +496,4 @@ if __name__ == '__main__': | |||||||
|             renameBackdropToJpg_copy() |             renameBackdropToJpg_copy() | ||||||
|         pasteFileToFolder(filepath, path)  # 移动文件 |         pasteFileToFolder(filepath, path)  # 移动文件 | ||||||
|     elif program_mode == '2': |     elif program_mode == '2': | ||||||
|         pasteFileToFolder_mode2(filepath, path)  # 移动文件 |         pasteFileToFolder(filepath, path)  # 移动文件 | ||||||
|  | |||||||
| @ -4,10 +4,8 @@ import json | |||||||
| import ADC_function | import ADC_function | ||||||
| 
 | 
 | ||||||
| def getTitle(htmlcode): #获取厂商 | def getTitle(htmlcode): #获取厂商 | ||||||
|     #print(htmlcode) |  | ||||||
|     html = etree.fromstring(htmlcode,etree.HTMLParser()) |     html = etree.fromstring(htmlcode,etree.HTMLParser()) | ||||||
|     result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/h2/text()')).strip(" ['']") |     result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/h2/text()')).strip(" ['']") | ||||||
|     #print(result2) |  | ||||||
|     return result |     return result | ||||||
| def getActor(htmlcode): | def getActor(htmlcode): | ||||||
|     try: |     try: | ||||||
| @ -26,21 +24,14 @@ def getStudio(htmlcode): #获取厂商 | |||||||
| def getNum(htmlcode):     #获取番号 | def getNum(htmlcode):     #获取番号 | ||||||
|     html = etree.fromstring(htmlcode, etree.HTMLParser()) |     html = etree.fromstring(htmlcode, etree.HTMLParser()) | ||||||
|     result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']") |     result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']") | ||||||
|     #print(result) |  | ||||||
|     return result |     return result | ||||||
| def getRelease(htmlcode2): # | def getRelease(htmlcode2): # | ||||||
|     #a=ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id='+str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")+'&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php') |  | ||||||
|     html=etree.fromstring(htmlcode2,etree.HTMLParser()) |     html=etree.fromstring(htmlcode2,etree.HTMLParser()) | ||||||
|     result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[4]/text()')).strip(" ['']") |     result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[4]/text()')).strip(" ['']") | ||||||
|     return result |     return result | ||||||
| def getCover(htmlcode2): #获取厂商 # | def getCover(htmlcode2): #获取厂商 # | ||||||
|     #a = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id=' + str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-") + '&utm_source=aff_php&utm_medium=source_code&utm_campaign=from_aff_php') |  | ||||||
|     html = etree.fromstring(htmlcode2, etree.HTMLParser()) |     html = etree.fromstring(htmlcode2, etree.HTMLParser()) | ||||||
|     result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[1]/a/img/@src')).strip(" ['']") |     result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[1]/a/img/@src')).strip(" ['']") | ||||||
|     # if result == '': |  | ||||||
|     #     html = etree.fromstring(htmlcode, etree.HTMLParser()) |  | ||||||
|     #     result2 = str(html.xpath('//*[@id="slider"]/ul[1]/li[1]/img/@src')).strip(" ['']") |  | ||||||
|     #     return result2 |  | ||||||
|     return 'http:' + result |     return 'http:' + result | ||||||
| def getOutline(htmlcode2):     #获取番号 # | def getOutline(htmlcode2):     #获取番号 # | ||||||
|     html = etree.fromstring(htmlcode2, etree.HTMLParser()) |     html = etree.fromstring(htmlcode2, etree.HTMLParser()) | ||||||
| @ -58,7 +49,7 @@ def getYear(release): | |||||||
|         return '' |         return '' | ||||||
| 
 | 
 | ||||||
| def main(number): | def main(number): | ||||||
|     number=number.replace('PPV','').replace('ppv','').strip('fc2_').strip('fc2-').strip('ppv-').strip('PPV-').strip('FC2_').strip('FC2-').strip('ppv-').strip('PPV-') |     number=number.replace('PPV','').replace('ppv','').strip('fc2_').strip('fc2-').strip('ppv-').strip('PPV-').strip('FC2_').strip('FC2-').strip('ppv-').strip('PPV-').replace('fc2ppv-','').replace('FC2PPV-','') | ||||||
|     htmlcode2 = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id='+str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")+'') |     htmlcode2 = ADC_function.get_html('http://adult.contents.fc2.com/article_search.php?id='+str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")+'') | ||||||
|     #htmlcode = ADC_function.get_html('http://fc2fans.club/html/FC2-' + number + '.html') |     #htmlcode = ADC_function.get_html('http://fc2fans.club/html/FC2-' + number + '.html') | ||||||
|     dic = { |     dic = { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user