0.10 Beta10 Update

This commit is contained in:
wenead99 2019-06-17 16:14:17 +08:00 committed by GitHub
parent dddaf5c74f
commit e91b7a85bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 201 additions and 170 deletions

View File

@ -12,33 +12,24 @@ else:
def get_html(url):#网页请求核心
if not str(config['proxy']['proxy']) == '':
proxies = {
"http" : "http://" + str(config['proxy']['proxy']),
"https": "https://" + str(config['proxy']['proxy'])
}
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3100.0 Safari/537.36'}
getweb = requests.get(str(url), headers=headers, proxies=proxies)
getweb.encoding = 'utf-8'
# print(getweb.text)
try:
proxies = {"http": "http://" + str(config['proxy']['proxy']),
"https": "https://" + str(config['proxy']['proxy'])}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3100.0 Safari/537.36'}
getweb = requests.get(str(url), timeout=10, headers=headers, proxies=proxies)
getweb.encoding = 'utf-8'
# print(getweb.text)
try:
return getweb.text
except:
print('[-]Connected failed!:Proxy error')
return getweb.text
except:
aaaa=''
#print('[-]Connect Failed.')
print('[-]Connected failed!:Proxy error')
else:
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'}
getweb = requests.get(str(url), headers=headers)
getweb.encoding = 'utf-8'
try:
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'}
getweb = requests.get(str(url), timeout=10, headers=headers)
getweb.encoding = 'utf-8'
try:
return getweb.text
except:
print("[-]Connect Failed.")
return getweb.text
except:
aaaa = ''
#print('[-]Connect Failed.')
print("[-]Connect Failed.")

263
core.py
View File

@ -18,109 +18,15 @@ year=''
outline=''
runtime=''
director=''
actor=[]
actor_list=[]
actor=''
release=''
number=''
cover=''
imagecut=''
tag=[]
#=====================资源下载部分===========================
def DownloadFileWithFilename(url,filename,path): #path = examle:photo , video.in the Project Folder!
config = ConfigParser()
config.read('proxy.ini', encoding='UTF-8')
proxy = str(config['proxy']['proxy'])
if not str(config['proxy']['proxy']) == '':
try:
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=10, headers=headers,proxies={"http": "http://" + str(proxy), "https": "https://" + str(proxy)})
with open(str(path) + "/" + str(filename), "wb") as code:
code.write(r.content)
# print(bytes(r),file=code)
except IOError as e:
print("[-]Movie not found in All website!")
print("[-]" + str(filename), e)
# print("[*]=====================================")
return "failed"
except Exception as e1:
print(e1)
print("[-]Download Failed2!")
time.sleep(3)
os._exit(0)
else:
try:
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=10, headers=headers)
with open(str(path) + "/" + str(filename), "wb") as code:
code.write(r.content)
# print(bytes(r),file=code)
except IOError as e:
print("[-]Movie not found in All website!")
print("[-]" + str(filename), e)
# print("[*]=====================================")
return "failed"
except Exception as e1:
print(e1)
print("[-]Download Failed2!")
time.sleep(3)
os._exit(0)
def PrintFiles(path):
try:
if not os.path.exists(path):
os.makedirs(path)
with open(path + "/" + number + ".nfo", "wt", encoding='UTF-8') as code:
print("<movie>", file=code)
print(" <title>" + title + "</title>", file=code)
print(" <set>", file=code)
print(" </set>", file=code)
print(" <studio>" + studio + "+</studio>", file=code)
print(" <year>" + year + "</year>", file=code)
print(" <outline>"+outline+"</outline>", file=code)
print(" <plot>"+outline+"</plot>", file=code)
print(" <runtime>"+str(runtime).replace(" ","")+"</runtime>", file=code)
print(" <director>" + director + "</director>", file=code)
print(" <poster>" + number + ".png</poster>", file=code)
print(" <thumb>" + number + ".png</thumb>", file=code)
print(" <fanart>"+number + '.jpg'+"</fanart>", file=code)
try:
for u in actor:
print(" <actor>", file=code)
print(" <name>" + u + "</name>", file=code)
print(" </actor>", file=code)
except:
aaaa=''
print(" <maker>" + studio + "</maker>", file=code)
print(" <label>", file=code)
print(" </label>", file=code)
try:
for i in tag:
print(" <tag>" + i + "</tag>", file=code)
except:
aaaaa=''
try:
for i in tag:
print(" <genre>" + i + "</genre>", file=code)
except:
aaaaaaaa=''
print(" <num>" + number + "</num>", file=code)
print(" <release>" + release + "</release>", file=code)
print(" <cover>"+cover+"</cover>", file=code)
print(" <website>" + "https://www.javbus.com/"+number + "</website>", file=code)
print("</movie>", file=code)
print("[+]Writeed! "+path + "/" + number + ".nfo")
except IOError as e:
print("[-]Write Failed!")
print(e)
except Exception as e1:
print(e1)
print("[-]Write Failed!")
naming_rule =''#eval(config['Name_Rule']['naming_rule'])
location_rule=''#eval(config['Name_Rule']['location_rule'])
#=====================本地文件处理===========================
def argparse_get_file():
import argparse
@ -135,7 +41,6 @@ def CreatFailedFolder():
except:
print("[-]failed!can not be make folder 'failed'\n[-](Please run as Administrator)")
os._exit(0)
def getNumberFromFilename(filepath):
global title
global studio
@ -143,6 +48,7 @@ def getNumberFromFilename(filepath):
global outline
global runtime
global director
global actor_list
global actor
global release
global number
@ -150,6 +56,9 @@ def getNumberFromFilename(filepath):
global imagecut
global tag
global naming_rule
global location_rule
#================================================获取文件番号================================================
try: #试图提取番号
# ====番号获取主程序====
@ -170,7 +79,7 @@ def getNumberFromFilename(filepath):
if not re.search('\w-', file_number).group() == 'None':
file_number = re.search('\w+-\w+', filename).group()
#上面是插入减号-到番号中
print("[!]Making Data for [" + filename + "],the number is [" + file_number + "]")
print("[!]Making Data for [" + filename + "],the number is [" + file_number + "]")
# ====番号获取主程序=结束===
except Exception as e: #番号提取异常
print('[-]'+str(os.path.basename(filepath))+' Cannot catch the number :')
@ -235,20 +144,22 @@ def getNumberFromFilename(filepath):
title = json_data['title']
studio = json_data['studio']
year = json_data['year']
outline = json_data['outline']
runtime = json_data['runtime']
director = json_data['director']
actor = str(json_data['actor']).strip("[ ]").replace("'",'').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(',') #字符串转列表
title = json_data['title']
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("'",'').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(" ",'')
naming_rule = eval(config['Name_Rule']['naming_rule'])
location_rule =eval(config['Name_Rule']['location_rule'])
except IOError as e:
print('[-]'+str(e))
print('[-]Move ' + filename + ' to failed folder')
@ -260,47 +171,137 @@ def getNumberFromFilename(filepath):
print('[-]Move ' + filename + ' to failed folder')
shutil.move(filepath, str(os.getcwd())+'/'+'failed/')
os._exit(0)
path = '' #设置path为全局变量后面移动文件要用
def creatFolder():
actor2 = str(actor).strip("[ ]").replace("'",'').replace(" ",'')
global path
if len(actor2) > 240: #新建成功输出文件夹
path = 'JAV_output' + '/' + '超多人' + '/' + number #path为影片+元数据所在目录
if len(actor) > 240: #新建成功输出文件夹
path = location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录
#print(path)
else:
path = 'JAV_output' + '/' + str(actor2) + '/' + str(number)
path = location_rule
#print(path)
if not os.path.exists(path):
os.makedirs(path)
path = str(os.getcwd())+'/'+path
#=====================资源下载部分===========================
def DownloadFileWithFilename(url,filename,path): #path = examle:photo , video.in the Project Folder!
config = ConfigParser()
config.read('proxy.ini', encoding='UTF-8')
proxy = str(config['proxy']['proxy'])
if not str(config['proxy']['proxy']) == '':
try:
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, headers=headers,proxies={"http": "http://" + str(proxy), "https": "https://" + str(proxy)})
with open(str(path) + "/" + filename, "wb") as code:
code.write(r.content)
# print(bytes(r),file=code)
except IOError as e:
print("[-]Movie not found in All website!")
print("[-]" + filename, e)
# print("[*]=====================================")
return "failed"
except Exception as e1:
print(e1)
print("[-]Download Failed2!")
time.sleep(3)
os._exit(0)
else:
try:
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, headers=headers)
with open(str(path) + "/" + filename, "wb") as code:
code.write(r.content)
# print(bytes(r),file=code)
except IOError as e:
print("[-]Movie not found in All website!")
print("[-]" + filename, e)
# print("[*]=====================================")
return "failed"
except Exception as e1:
print(e1)
print("[-]Download Failed2!")
time.sleep(3)
os._exit(0)
def PrintFiles(path):
try:
if not os.path.exists(path):
os.makedirs(path)
with open(path + "/" + naming_rule + ".nfo", "wt", encoding='UTF-8') as code:
print("<movie>", file=code)
print(" <title>" + title + "</title>", file=code)
print(" <set>", file=code)
print(" </set>", file=code)
print(" <studio>" + studio + "+</studio>", file=code)
print(" <year>" + year + "</year>", file=code)
print(" <outline>"+outline+"</outline>", file=code)
print(" <plot>"+outline+"</plot>", file=code)
print(" <runtime>"+str(runtime).replace(" ","")+"</runtime>", file=code)
print(" <director>" + director + "</director>", file=code)
print(" <poster>" + naming_rule + ".png</poster>", file=code)
print(" <thumb>" + naming_rule + ".png</thumb>", file=code)
print(" <fanart>"+naming_rule + '.jpg'+"</fanart>", file=code)
try:
for u in actor_list:
print(" <actor>", file=code)
print(" <name>" + u + "</name>", file=code)
print(" </actor>", file=code)
except:
aaaa=''
print(" <maker>" + studio + "</maker>", file=code)
print(" <label>", file=code)
print(" </label>", file=code)
try:
for i in tag:
print(" <tag>" + i + "</tag>", file=code)
except:
aaaaa=''
try:
for i in tag:
print(" <genre>" + i + "</genre>", file=code)
except:
aaaaaaaa=''
print(" <num>" + number + "</num>", file=code)
print(" <release>" + release + "</release>", file=code)
print(" <cover>"+cover+"</cover>", file=code)
print(" <website>" + "https://www.javbus.com/"+number + "</website>", file=code)
print("</movie>", file=code)
print("[+]Writeed! "+path + "/" + naming_rule + ".nfo")
except IOError as e:
print("[-]Write Failed!")
print(e)
except Exception as e1:
print(e1)
print("[-]Write Failed!")
def imageDownload(filepath): #封面是否下载成功否则移动到failed
if DownloadFileWithFilename(cover,str(number) + '.jpg', path) == 'failed':
if DownloadFileWithFilename(cover,naming_rule+ '.jpg', path) == 'failed':
shutil.move(filepath, 'failed/')
os._exit(0)
DownloadFileWithFilename(cover, number + '.jpg', path)
print('[+]Image Downloaded!', path +'/'+number+'.jpg')
DownloadFileWithFilename(cover, naming_rule + '.jpg', path)
print('[+]Image Downloaded!', path +'/'+naming_rule+'.jpg')
def cutImage():
if imagecut == 1:
try:
img = Image.open(path + '/' + number + '.jpg')
img = Image.open(path + '/' + naming_rule + '.jpg')
imgSize = img.size
w = img.width
h = img.height
img2 = img.crop((w / 1.9, 0, w, h))
img2.save(path + '/' + number + '.png')
img2.save(path + '/' + naming_rule + '.png')
except:
print('[-]Cover cut failed!')
else:
img = Image.open(path + '/' + number + '.jpg')
img = Image.open(path + '/' + naming_rule + '.jpg')
w = img.width
h = img.height
img.save(path + '/' + number + '.png')
img.save(path + '/' + naming_rule + '.png')
def pasteFileToFolder(filepath, path): #文件路径,番号,后缀,要移动至的位置
houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|avi|rmvb|wmv|mov|mp4|mkv|flv)$', filepath).group())
os.rename(filepath, number + houzhui)
shutil.move(number + houzhui, path)
os.rename(filepath, naming_rule + houzhui)
shutil.move(naming_rule + houzhui, path)
if __name__ == '__main__':
filepath=argparse_get_file() #影片的路径

View File

@ -43,16 +43,18 @@ def main(number):
dic = {
'title': getTitle(htmlcode),
'studio': getStudio(htmlcode),
'year': getRelease(number),
'year': str(re.search('\d{4}',getRelease(number)).group()),
'outline': getOutline(htmlcode,number),
'runtime': '',
'director': getStudio(htmlcode),
'actor': '',
'release': getRelease(number),
'number': number,
'number': 'FC2-'+number,
'cover': getCover(htmlcode,number),
'imagecut': 0,
'tag':" ",
}
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
return js
return js
#print(main('1104989'))

View File

@ -79,20 +79,41 @@ def main(number):
htmlcode=get_html('https://www.javbus.com/'+number)
dww_htmlcode=get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", ''))
dic = {
'title': getTitle(htmlcode),
'studio': getStudio(htmlcode),
'year': getYear(htmlcode),
'outline': getOutline(dww_htmlcode),
'runtime': getRuntime(htmlcode),
'title': getTitle(htmlcode),
'studio': getStudio(htmlcode),
'year': str(re.search('\d{4}',getYear(htmlcode)).group()),
'outline': getOutline(dww_htmlcode),
'runtime': getRuntime(htmlcode),
'director': getDirector(htmlcode),
'actor': getActor(htmlcode),
'release': getRelease(htmlcode),
'number': getNum(htmlcode),
'cover': getCover(htmlcode),
'actor': getActor(htmlcode),
'release': getRelease(htmlcode),
'number': getNum(htmlcode),
'cover': getCover(htmlcode),
'imagecut': 1,
'tag':getTag(htmlcode)
'tag': getTag(htmlcode)
}
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
if 'HEYZO' in number or 'heyzo' in number or 'Heyzo' in number:
htmlcode = get_html('https://www.javbus.com/' + number)
dww_htmlcode = get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", ''))
dic = {
'title': getTitle(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),
'imagecut': 1,
'tag': getTag(htmlcode)
}
js2 = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8')
return js2
return js
def main_uncensored(number):
@ -120,7 +141,7 @@ def main_uncensored(number):
'title': getTitle(htmlcode),
'studio': getStudio(htmlcode),
'year': getYear(htmlcode),
'outline': getOutline(htmlcode),
'outline': '',
'runtime': getRuntime(htmlcode),
'director': getDirector(htmlcode),
'actor': getActor(htmlcode),

16
proxy.ini Normal file
View File

@ -0,0 +1,16 @@
[proxy]
proxy=127.0.0.1:1080
[Name_Rule]
location_rule='JAV_output/'+actor+'/'+actor+'-'+year+'- '+title+'['+number+']'
naming_rule=actor+'-'+year+'- '+title+'['+number+']'
#============================================================
#
# title=标题,number=番号stdio=片商,year=年份,director=导演actor=女优outline=简介
# runtime=时长release=上市日期cover=封面URLtag=类型
# 例子:
# rule=str('JAV_output/'+actor+'/'+actor+' '+' ['+year+']'+title+' ['+number+']')
# 例子结束
# 自定义字符(字符串)要加冒号'(内容)',字符串连接要用加号+
#
#============================================================