6 Commits
0.3 ... 0.4

Author SHA1 Message Date
wenead99
917614975e Beta 0.4 更新 *更好的错误提示 2019-05-30 19:15:02 +08:00
wenead99
e3d9955e5b Beta 0.4 更新 *新增:重命名文件时替换'_'为'-' 2019-05-30 19:13:45 +08:00
wenead99
69fa8d3f05 Beta 0.4 更新 *新增:替换'_'为'-' 2019-05-30 19:12:58 +08:00
wenead99
b5f82f77a1 0.3.2 Beta 完善错误提示 2019-05-29 12:10:16 +08:00
wenead99
5f627d24e0 0.3.1 Beta 修改无法导出nfo文件和介绍BUG 2019-05-29 09:07:17 +08:00
wenead99
6817cd2093 0.3.1 Beta 修改无法导出nfo文件BUG 2019-05-29 08:42:28 +08:00
2 changed files with 35 additions and 19 deletions

View File

@@ -21,7 +21,8 @@ def movie_lists():
total = a2+b2+c2+d2+e2+f2+g2 total = a2+b2+c2+d2+e2+f2+g2
return total return total
def lists_from_test(custom_nuber): def lists_from_test(custom_nuber): #电影列表
a=[] a=[]
a.append(custom_nuber) a.append(custom_nuber)
return a return a
@@ -35,11 +36,25 @@ def CEF(path):
except: except:
a='' a=''
def rreplace(self, old, new, *max):
#从右开始替换文件名中内容,源字符串,将被替换的子字符串, 新字符串用于替换old子字符串可选字符串, 替换不超过 max 次
count = len(self)
if max and str(max[0]).isdigit():
count = max[0]
return new.join(self.rsplit(old, count))
if __name__ =='__main__': if __name__ =='__main__':
os.chdir(os.getcwd()) os.chdir(os.getcwd())
for i in movie_lists(): for i in movie_lists(): #遍历电影列表 交给core处理
os.system('python core.py' + ' "' + i + '"') if '_' in i:
os.rename(i, rreplace(i,'_','-',1))
i = rreplace(i,'_','-',1)
os.system('python core.py' + ' "' + i + '"') #选择从py文件启动 用于源码py
#os.system('core.exe' + ' "' + i + '"') #选择从exe文件启动用于EXE版程序
print("[*]=====================================")
print("[!]Cleaning empty folders") print("[!]Cleaning empty folders")
CEF('JAV_output') CEF('JAV_output')
print("[+]All finished!!!") print("[+]All finished!!!")
time.sleep(3) time.sleep(3)

33
core.py
View File

@@ -12,13 +12,11 @@ import time
#=====================爬虫核心部分========================== #=====================爬虫核心部分==========================
def get_html(url):#网页请求核心 def get_html(url):#网页请求核心
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'} 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),proxies={"http": "http://127.0.0.1:2334","https": "https://127.0.0.1:2334"},timeout=5,headers=headers).text getweb = requests.get(str(url),timeout=5,headers=headers).text
try: try:
return getweb return getweb
except Exception as e: except:
print(e) print("[-]Connect Failed! Please check your Proxy.")
except IOError as e1:
print(e1)
def getTitle(htmlcode): #获取标题 def getTitle(htmlcode): #获取标题
doc = pq(htmlcode) doc = pq(htmlcode)
@@ -75,17 +73,15 @@ def DownloadFileWithFilename(url,filename,path): #path = examle:photo , video.in
with open(str(path) + "/"+str(filename), "wb") as code: with open(str(path) + "/"+str(filename), "wb") as code:
code.write(r.content) code.write(r.content)
except IOError as e: except IOError as e:
print("[-]Download Failed1!") print("[-]Movie not found in All website!")
print("[-]Error:"+str(e)) #print("[*]=====================================")
print("[-]Movie not found in Javbus.com!")
print("[*]=====================================")
return "failed" return "failed"
except Exception as e1: except Exception as e1:
print(e1) print(e1)
print("[-]Download Failed2!") print("[-]Download Failed2!")
time.sleep(3) time.sleep(3)
os._exit(0) os._exit(0)
def PrintFiles(html,html_outline,path): def PrintFiles(html,path,number):
try: try:
if not os.path.exists(path): if not os.path.exists(path):
os.makedirs(path) os.makedirs(path)
@@ -96,8 +92,8 @@ def PrintFiles(html,html_outline,path):
print(" </set>", file=code) print(" </set>", file=code)
print(" <studio>" + getStudio(html) + "+</studio>", file=code) print(" <studio>" + getStudio(html) + "+</studio>", file=code)
print(" <year>" + getYear(html) + "</year>", file=code) print(" <year>" + getYear(html) + "</year>", file=code)
print(" <outline>"+getOutline(html_outline)+"</outline>", file=code) print(" <outline>"+getOutline(get_html_dww(number))+"</outline>", file=code)
print(" <plot>"+getOutline(html_outline)+"</plot>", file=code) print(" <plot>"+getOutline(get_html_dww(number))+"</plot>", file=code)
print(" <runtime>"+str(getRuntime(html)).replace(" ","")+"</runtime>", file=code) print(" <runtime>"+str(getRuntime(html)).replace(" ","")+"</runtime>", file=code)
print(" <director>" + getDirector(html) + "</director>", file=code) print(" <director>" + getDirector(html) + "</director>", file=code)
print(" <poster>" + getNum(html) + ".png</poster>", file=code) print(" <poster>" + getNum(html) + ".png</poster>", file=code)
@@ -122,8 +118,9 @@ def PrintFiles(html,html_outline,path):
print(e1) print(e1)
print("[-]Write Failed!") print("[-]Write Failed!")
#=====================本地文件处理=========================== #=====================本地文件处理===========================
def argparse_get_file(): def argparse_get_file():
import argparse import argparse
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@@ -173,11 +170,14 @@ def imageDownload(htmlcode,filepath,number): #封面是否下载成功,否则
shutil.move(filepath, 'failed/') shutil.move(filepath, 'failed/')
os._exit(0) os._exit(0)
DownloadFileWithFilename(getCover(htmlcode), number + '.jpg', path) DownloadFileWithFilename(getCover(htmlcode), number + '.jpg', path)
print('[+]Downloaded!', path +'/'+number+'.jpg') print('[+]Image Downloaded!', path +'/'+number+'.jpg')
def cutImage(number): def cutImage(number):
try: try:
img = Image.open(path + '/' + number + '.jpg') img = Image.open(path + '/' + number + '.jpg')
img2 = img.crop((421, 0, 800, 538)) 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 + '/' + number + '.png')
except: except:
print('[-]Cover cut failed!') print('[-]Cover cut failed!')
@@ -192,5 +192,6 @@ if __name__ == '__main__':
htmlcode=get_html_javbus(number) #获取的HTML代码 htmlcode=get_html_javbus(number) #获取的HTML代码
creatFolder(htmlcode,number) #创建文件夹 creatFolder(htmlcode,number) #创建文件夹
imageDownload(htmlcode,filepath,number) #creatFoder会返回番号路径 imageDownload(htmlcode,filepath,number) #creatFoder会返回番号路径
cutImage(number) #裁剪图片 PrintFiles(htmlcode, path,number)#打印文件
cutImage(number) #裁剪图
pasteFileToFolder(filepath,number,path) #移动文件 pasteFileToFolder(filepath,number,path) #移动文件