From e91b7a85bf0ab6227c18ebbc77e30872338d442c Mon Sep 17 00:00:00 2001
From: wenead99 <42309414+wenead99@users.noreply.github.com>
Date: Mon, 17 Jun 2019 16:14:17 +0800
Subject: [PATCH] 0.10 Beta10 Update
---
ADC_function.py | 41 +++-----
core.py | 263 ++++++++++++++++++++++++------------------------
fc2fans_club.py | 8 +-
javbus.py | 43 ++++++--
proxy.ini | 16 +++
5 files changed, 201 insertions(+), 170 deletions(-)
create mode 100644 proxy.ini
diff --git a/ADC_function.py b/ADC_function.py
index 62006fe..e356b5b 100644
--- a/ADC_function.py
+++ b/ADC_function.py
@@ -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.')
\ No newline at end of file
+ print("[-]Connect Failed.")
\ No newline at end of file
diff --git a/core.py b/core.py
index adb394b..4013eeb 100644
--- a/core.py
+++ b/core.py
@@ -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("", file=code)
- print(" " + title + "", file=code)
- print(" ", file=code)
- print(" ", file=code)
- print(" " + studio + "+", file=code)
- print(" " + year + "", file=code)
- print(" "+outline+"", file=code)
- print(" "+outline+"", file=code)
- print(" "+str(runtime).replace(" ","")+"", file=code)
- print(" " + director + "", file=code)
- print(" " + number + ".png", file=code)
- print(" " + number + ".png", file=code)
- print(" "+number + '.jpg'+"", file=code)
- try:
- for u in actor:
- print(" ", file=code)
- print(" " + u + "", file=code)
- print(" ", file=code)
- except:
- aaaa=''
- print(" " + studio + "", file=code)
- print(" ", file=code)
- try:
- for i in tag:
- print(" " + i + "", file=code)
- except:
- aaaaa=''
- try:
- for i in tag:
- print(" " + i + "", file=code)
- except:
- aaaaaaaa=''
- print(" " + number + "", file=code)
- print(" " + release + "", file=code)
- print(" "+cover+"", file=code)
- print(" " + "https://www.javbus.com/"+number + "", file=code)
- print("", 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("", file=code)
+ print(" " + title + "", file=code)
+ print(" ", file=code)
+ print(" ", file=code)
+ print(" " + studio + "+", file=code)
+ print(" " + year + "", file=code)
+ print(" "+outline+"", file=code)
+ print(" "+outline+"", file=code)
+ print(" "+str(runtime).replace(" ","")+"", file=code)
+ print(" " + director + "", file=code)
+ print(" " + naming_rule + ".png", file=code)
+ print(" " + naming_rule + ".png", file=code)
+ print(" "+naming_rule + '.jpg'+"", file=code)
+ try:
+ for u in actor_list:
+ print(" ", file=code)
+ print(" " + u + "", file=code)
+ print(" ", file=code)
+ except:
+ aaaa=''
+ print(" " + studio + "", file=code)
+ print(" ", file=code)
+ try:
+ for i in tag:
+ print(" " + i + "", file=code)
+ except:
+ aaaaa=''
+ try:
+ for i in tag:
+ print(" " + i + "", file=code)
+ except:
+ aaaaaaaa=''
+ print(" " + number + "", file=code)
+ print(" " + release + "", file=code)
+ print(" "+cover+"", file=code)
+ print(" " + "https://www.javbus.com/"+number + "", file=code)
+ print("", 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() #影片的路径
diff --git a/fc2fans_club.py b/fc2fans_club.py
index d854ce8..27482e7 100644
--- a/fc2fans_club.py
+++ b/fc2fans_club.py
@@ -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
\ No newline at end of file
+ return js
+
+#print(main('1104989'))
\ No newline at end of file
diff --git a/javbus.py b/javbus.py
index 2b8744b..da62764 100644
--- a/javbus.py
+++ b/javbus.py
@@ -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),
diff --git a/proxy.ini b/proxy.ini
new file mode 100644
index 0000000..a2e75d3
--- /dev/null
+++ b/proxy.ini
@@ -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=封面URL,tag=类型
+# 例子:
+# rule=str('JAV_output/'+actor+'/'+actor+' '+' ['+year+']'+title+' ['+number+']')
+# 例子结束
+# 自定义字符(字符串)要加冒号'(内容)',字符串连接要用加号+
+#
+#============================================================
\ No newline at end of file