Update 1.3

This commit is contained in:
Yoshiko 2019-10-06 01:14:12 +08:00 committed by GitHub
parent ae99c652f5
commit 73c0126fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 75 deletions

View File

@ -14,7 +14,7 @@ os.chdir(os.getcwd())
# ============global var===========
version='1.2'
version='1.3'
config = ConfigParser()
config.read(config_file, encoding='UTF-8')
@ -69,13 +69,13 @@ def lists_from_test(custom_nuber): #电影列表
a.append(custom_nuber)
return a
def CEF(path):
files = os.listdir(path) # 获取路径下的子文件(夹)列表
for file in files:
try: #试图删除空目录,非空目录删除会报错
try:
files = os.listdir(path) # 获取路径下的子文件(夹)列表
for file in files:
os.removedirs(path + '/' + file) # 删除这个空文件夹
print('[+]Deleting empty folder',path + '/' + file)
except:
a=''
print('[+]Deleting empty folder', path + '/' + file)
except:
a=''
def rreplace(self, old, new, *max):
#从右开始替换文件名中内容,源字符串,将被替换的子字符串, 新字符串用于替换old子字符串可选字符串, 替换不超过 max 次
count = len(self)
@ -83,30 +83,27 @@ def rreplace(self, old, new, *max):
count = max[0]
return new.join(self.rsplit(old, count))
def getNumber(filepath):
filepath = filepath.replace('.\\','')
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:
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()
return file_number
except:
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
except: # 提取类似mkbd-s120番号
file_number = re.search('\w+-\w+\d+', filename).group()
return file_number
except: # 提取不含减号-的番号
try:
filename1 = str(re.sub("ts6\d", "", filepath)).strip('Tokyo-hot').strip('tokyo-hot')
filename0 = str(re.sub(".*?\.com-\d+", "", filename1)).strip('_')
file_number = str(re.search('\w+\d{4}', filename0).group(0))
filename = str(re.sub("ts6\d", "", filepath)).strip('Tokyo-hot').strip('tokyo-hot')
filename = str(re.sub(".*?\.com-\d+", "", filename)).replace('_', '')
file_number = str(re.search('\w+\d{4}', filename).group(0))
return file_number
except: # 提取无减号番号
filename1 = str(re.sub("ts6\d", "", filepath)) # 去除ts64/265
filename0 = str(re.sub(".*?\.com-\d+", "", filename1))
file_number2 = str(re.match('\w+', filename0).group())
file_number = str(file_number2.replace(re.match("^[A-Za-z]+", file_number2).group(),re.match("^[A-Za-z]+", file_number2).group() + '-'))
filename = str(re.sub("ts6\d", "", filepath)) # 去除ts64/265
filename = str(re.sub(".*?\.com-\d+", "", filename))
file_number = str(re.match('\w+', filename).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
def RunCore():

75
core.py
View File

@ -49,9 +49,9 @@ actor_photo={}
cover_small=''
naming_rule =''#eval(config['Name_Rule']['naming_rule'])
location_rule=''#eval(config['Name_Rule']['location_rule'])
program_mode = Config['common']['main_mode']
failed_folder= Config['common']['failed_output_folder']
success_folder=Config['common']['success_output_folder']
program_mode = Config['common']['main_mode']
failed_folder = Config['common']['failed_output_folder']
success_folder = Config['common']['success_output_folder']
#=====================本地文件处理===========================
def moveFailedFolder():
@ -96,6 +96,7 @@ def getDataFromJSON(file_number): #从JSON返回元数据
global website
global actor_photo
global cover_small
global json_data
global naming_rule
global location_rule
@ -115,8 +116,7 @@ def getDataFromJSON(file_number): #从JSON返回元数据
json_data = json.loads(javdb.main(file_number))
# ==
elif 'fc2' in file_number or 'FC2' in file_number:
json_data = json.loads(fc2fans_club.main(
file_number))
json_data = json.loads(fc2fans_club.main(file_number))
# ==
elif 'HEYZO' in number or 'heyzo' in number or 'Heyzo' in number:
json_data = json.loads(avsox.main(file_number))
@ -163,24 +163,15 @@ def getDataFromJSON(file_number): #从JSON返回元数据
# ====================处理异常字符====================== #\/:*?"<>|
if '\\' in title:
title=title.replace('\\', ' ')
elif r'/' in title:
title=title.replace(r'/', '')
elif ':' in title:
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('<', '')
elif '>' in title:
title=title.replace('>', '')
elif '|' in title:
title=title.replace('|', '')
title = title.replace('\\', '')
title = title.replace('/', '')
title = title.replace(':', '')
title = title.replace('*', '')
title = title.replace('?', '')
title = title.replace('"', '')
title = title.replace('<', '')
title = title.replace('>', '')
title = title.replace('|', '')
# ====================处理异常字符 END================== #\/:*?"<>|
naming_rule = eval(config['Name_Rule']['naming_rule'])
@ -205,9 +196,8 @@ def smallCoverCheck():
def creatFolder(): #创建文件夹
global actor
global path
if len(actor) > 240: #新建成功输出文件夹
if len(os.getcwd()+path) > 240: #新建成功输出文件夹
path = success_folder+'/'+location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录
#print(path)
else:
path = success_folder+'/'+location_rule
#print(path)
@ -286,10 +276,6 @@ def imageDownload(filepath): #封面是否下载成功否则移动到failed
DownloadFileWithFilename(cover, 'fanart.jpg', path)
print('[+]Image Downloaded!', path + '/fanart.jpg')
def PrintFiles(filepath):
#global path
global title
global cn_sub
global actor_photo
try:
if not os.path.exists(path):
os.makedirs(path)
@ -437,15 +423,8 @@ def pasteFileToFolder(filepath, path): #文件路径,番号,后缀,要移
print('[-]File Exists! Please check your movie!')
print('[-]move to the root folder of the program.')
os._exit(0)
def pasteFileToFolder_mode2(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())
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.')
except PermissionError:
print('[-]Error! Please run as administrator!')
os._exit(0)
def renameJpgToBackdrop_copy():
if option == 'plex':
@ -453,7 +432,6 @@ def renameJpgToBackdrop_copy():
shutil.copy(path + '/poster.png', path + '/thumb.png')
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')
@ -468,6 +446,20 @@ def get_part(filepath):
except:
print("[-]failed!Please rename the filename again!")
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__':
filepath=argparse_get_file()[0] #影片的路径
@ -488,14 +480,15 @@ if __name__ == '__main__':
number = argparse_get_file()[1]
CreatFailedFolder()
getDataFromJSON(number) # 定义番号
debug_mode()
creatFolder() # 创建文件夹
if program_mode == '1':
if part == '-CD1' or multi_part == 0:
smallCoverCheck()
imageDownload(filepath) # creatFoder会返回番号路径
if multi_part == 1:
number += part
PrintFiles(filepath) # 打印文件
smallCoverCheck()
cutImage() # 裁剪图
renameJpgToBackdrop_copy()
else:
@ -503,4 +496,4 @@ if __name__ == '__main__':
renameBackdropToJpg_copy()
pasteFileToFolder(filepath, path) # 移动文件
elif program_mode == '2':
pasteFileToFolder_mode2(filepath, path) # 移动文件
pasteFileToFolder(filepath, path) # 移动文件

View File

@ -4,10 +4,8 @@ import json
import ADC_function
def getTitle(htmlcode): #获取厂商
#print(htmlcode)
html = etree.fromstring(htmlcode,etree.HTMLParser())
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/h2/text()')).strip(" ['']")
#print(result2)
return result
def getActor(htmlcode):
try:
@ -26,21 +24,14 @@ def getStudio(htmlcode): #获取厂商
def getNum(htmlcode): #获取番号
html = etree.fromstring(htmlcode, etree.HTMLParser())
result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[1]/span[2]/text()')).strip(" ['']")
#print(result)
return result
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())
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[1]/div/div[2]/dl/dd[4]/text()')).strip(" ['']")
return result
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())
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
def getOutline(htmlcode2): #获取番号 #
html = etree.fromstring(htmlcode2, etree.HTMLParser())
@ -58,7 +49,7 @@ def getYear(release):
return ''
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-")+'')
#htmlcode = ADC_function.get_html('http://fc2fans.club/html/FC2-' + number + '.html')
dic = {