0.6 更新:Javbus抓取的元数据支持标签功能,优化无码视频抓取
This commit is contained in:
parent
cfccd00367
commit
532c5bfbe3
74
core.py
74
core.py
@ -16,11 +16,12 @@ year=''
|
|||||||
outline=''
|
outline=''
|
||||||
runtime=''
|
runtime=''
|
||||||
director=''
|
director=''
|
||||||
actor=''
|
actor=[]
|
||||||
release=''
|
release=''
|
||||||
number=''
|
number=''
|
||||||
cover=''
|
cover=''
|
||||||
imagecut=''
|
imagecut=''
|
||||||
|
tag=[]
|
||||||
|
|
||||||
#=====================资源下载部分===========================
|
#=====================资源下载部分===========================
|
||||||
def DownloadFileWithFilename(url,filename,path): #path = examle:photo , video.in the Project Folder!
|
def DownloadFileWithFilename(url,filename,path): #path = examle:photo , video.in the Project Folder!
|
||||||
@ -58,12 +59,21 @@ def PrintFiles(path):
|
|||||||
print(" <poster>" + number + ".png</poster>", file=code)
|
print(" <poster>" + number + ".png</poster>", file=code)
|
||||||
print(" <thumb>" + number + ".png</thumb>", file=code)
|
print(" <thumb>" + number + ".png</thumb>", file=code)
|
||||||
print(" <fanart>"+number + '.jpg'+"</fanart>", file=code)
|
print(" <fanart>"+number + '.jpg'+"</fanart>", file=code)
|
||||||
print(" <actor>", file=code)
|
try:
|
||||||
print(" <name>" + actor + "</name>", file=code)
|
for u in actor:
|
||||||
print(" </actor>", file=code)
|
print(" <actor>", file=code)
|
||||||
|
print(" <name>" + u + "</name>", file=code)
|
||||||
|
print(" </actor>", file=code)
|
||||||
|
except:
|
||||||
|
aaaa=''
|
||||||
print(" <maker>" + studio + "</maker>", file=code)
|
print(" <maker>" + studio + "</maker>", file=code)
|
||||||
print(" <label>", file=code)
|
print(" <label>", file=code)
|
||||||
print(" </label>", file=code)
|
print(" </label>", file=code)
|
||||||
|
try:
|
||||||
|
for i in tag:
|
||||||
|
print(" <tag>" + i + "</tag>", file=code)
|
||||||
|
except:
|
||||||
|
aaaa=''
|
||||||
print(" <num>" + number + "</num>", file=code)
|
print(" <num>" + number + "</num>", file=code)
|
||||||
print(" <release>" + release + "</release>", file=code)
|
print(" <release>" + release + "</release>", file=code)
|
||||||
print(" <cover>"+cover+"</cover>", file=code)
|
print(" <cover>"+cover+"</cover>", file=code)
|
||||||
@ -96,34 +106,47 @@ def getNumberFromFilename(filepath):
|
|||||||
global number
|
global number
|
||||||
global cover
|
global cover
|
||||||
global imagecut
|
global imagecut
|
||||||
|
global tag
|
||||||
|
|
||||||
filename = str(os.path.basename(filepath)) #电影文件名
|
filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", os.path.basename(filepath)))
|
||||||
str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filename))
|
|
||||||
print("[!]Making Data for ["+filename+"]")
|
print("[!]Making Data for ["+filename+"]")
|
||||||
a = str(re.search('\w+-\w+', filename).group())
|
file_number = str(re.search('\w+-\w+', filename).group())
|
||||||
#print(a)
|
#print(a)
|
||||||
|
|
||||||
# =======================网站规则添加==============================
|
|
||||||
try:
|
try:
|
||||||
try:
|
|
||||||
if re.search('^\d{5,}', a).group() in filename:
|
|
||||||
json_data = json.loads(javbus.main_uncensored(a.replace("-", "_")))
|
|
||||||
except:
|
|
||||||
|
|
||||||
|
#================================================网站规则添加开始================================================
|
||||||
|
|
||||||
|
|
||||||
|
try: #添加 需要 正则表达式的规则
|
||||||
|
if re.search('^\d{5,}', file_number).group() in filename:
|
||||||
|
json_data = json.loads(javbus.main_uncensored(file_number))
|
||||||
|
except: #添加 无需 正则表达式的规则
|
||||||
if 'fc2' in filename:
|
if 'fc2' in filename:
|
||||||
json_data = json.loads(fc2fans_club.main(a))
|
json_data = json.loads(fc2fans_club.main(file_number))
|
||||||
elif 'FC2' in filename:
|
elif 'FC2' in filename:
|
||||||
json_data = json.loads(fc2fans_club.main(a))
|
json_data = json.loads(fc2fans_club.main(file_number))
|
||||||
elif 'siro' in filename:
|
elif 'siro' in filename:
|
||||||
json_data = json.loads(siro.main(a))
|
json_data = json.loads(siro.main(file_number))
|
||||||
elif 'SIRO' in filename:
|
elif 'SIRO' in filename:
|
||||||
json_data = json.loads(siro.main(a))
|
json_data = json.loads(siro.main(file_number))
|
||||||
elif '259luxu' in filename:
|
elif '259luxu' in filename:
|
||||||
json_data = json.loads(siro.main(a))
|
json_data = json.loads(siro.main(file_number))
|
||||||
elif '259LUXU' in filename:
|
elif '259LUXU' in filename:
|
||||||
json_data = json.loads(siro.main(a))
|
json_data = json.loads(siro.main(file_number))
|
||||||
else:
|
else:
|
||||||
json_data = json.loads(javbus.main(a))
|
json_data = json.loads(javbus.main(file_number))
|
||||||
# ====================网站规则添加结束==============================
|
|
||||||
|
|
||||||
|
#================================================网站规则添加结束================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
title = json_data['title']
|
title = json_data['title']
|
||||||
studio = json_data['studio']
|
studio = json_data['studio']
|
||||||
@ -131,11 +154,12 @@ def getNumberFromFilename(filepath):
|
|||||||
outline = json_data['outline']
|
outline = json_data['outline']
|
||||||
runtime = json_data['runtime']
|
runtime = json_data['runtime']
|
||||||
director = json_data['director']
|
director = json_data['director']
|
||||||
actor = json_data['actor']
|
actor = str(json_data['actor']).strip("[ ]").replace("'",'').replace(" ",'').split(',')
|
||||||
release = json_data['release']
|
release = json_data['release']
|
||||||
number = json_data['number']
|
number = json_data['number']
|
||||||
cover = json_data['cover']
|
cover = json_data['cover']
|
||||||
imagecut = json_data['imagecut']
|
imagecut = json_data['imagecut']
|
||||||
|
tag = str(json_data['tag']).strip("[ ]").replace("'",'').replace(" ",'').split(',')
|
||||||
except:
|
except:
|
||||||
print('[-]File '+filename+'`s number can not be caught')
|
print('[-]File '+filename+'`s number can not be caught')
|
||||||
print('[-]Move ' + filename + ' to failed folder')
|
print('[-]Move ' + filename + ' to failed folder')
|
||||||
@ -151,19 +175,21 @@ def getNumberFromFilename(filepath):
|
|||||||
path = '' #设置path为全局变量,后面移动文件要用
|
path = '' #设置path为全局变量,后面移动文件要用
|
||||||
|
|
||||||
def creatFolder():
|
def creatFolder():
|
||||||
|
actor2 = str(actor).strip("[ ]").replace("'",'').replace(" ",'')
|
||||||
global path
|
global path
|
||||||
if not os.path.exists('failed/'): #新建failed文件夹
|
if not os.path.exists('failed/'): #新建failed文件夹
|
||||||
os.makedirs('failed/')
|
os.makedirs('failed/')
|
||||||
if not os.path.exists('failed/'):
|
if not os.path.exists('failed/'):
|
||||||
print("[-]failed!Dirs can not be make (Please run as Administrator)")
|
print("[-]failed!Dirs can not be make (Please run as Administrator)")
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
if len(actor) > 240: #新建成功输出文件夹
|
if len(actor2) > 240: #新建成功输出文件夹
|
||||||
path = 'JAV_output' + '/' + '超多人' + '/' + number #path为影片+元数据所在目录
|
path = 'JAV_output' + '/' + '超多人' + '/' + number #path为影片+元数据所在目录
|
||||||
else:
|
else:
|
||||||
path = 'JAV_output' + '/' + str(actor) + '/' + str(number)
|
path = 'JAV_output' + '/' + str(actor2) + '/' + str(number)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
path = str(os.getcwd())+'/'+path
|
path = str(os.getcwd())+'/'+path
|
||||||
|
|
||||||
def imageDownload(filepath): #封面是否下载成功,否则移动到failed
|
def imageDownload(filepath): #封面是否下载成功,否则移动到failed
|
||||||
if DownloadFileWithFilename(cover,str(number) + '.jpg', path) == 'failed':
|
if DownloadFileWithFilename(cover,str(number) + '.jpg', path) == 'failed':
|
||||||
shutil.move(filepath, 'failed/')
|
shutil.move(filepath, 'failed/')
|
||||||
|
@ -31,6 +31,11 @@ def getOutline(htmlcode,number): #获取番号
|
|||||||
html = etree.fromstring(a, etree.HTMLParser())
|
html = etree.fromstring(a, etree.HTMLParser())
|
||||||
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[4]/p/text()')).replace("\\n",'',10000).strip(" ['']").replace("'",'',10000)
|
result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[4]/p/text()')).replace("\\n",'',10000).strip(" ['']").replace("'",'',10000)
|
||||||
return result
|
return result
|
||||||
|
# def getTag(htmlcode,number): #获取番号
|
||||||
|
# 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(a, etree.HTMLParser())
|
||||||
|
# result = str(html.xpath('//*[@id="container"]/div[1]/div/article/section[4]/p/text()')).replace("\\n",'',10000).strip(" ['']").replace("'",'',10000)
|
||||||
|
# return result
|
||||||
|
|
||||||
def main(number):
|
def main(number):
|
||||||
str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")
|
str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-")
|
||||||
@ -47,6 +52,7 @@ def main(number):
|
|||||||
'number': number,
|
'number': number,
|
||||||
'cover': getCover(htmlcode,number),
|
'cover': getCover(htmlcode,number),
|
||||||
'imagecut': 0,
|
'imagecut': 0,
|
||||||
|
'tag':" ",
|
||||||
}
|
}
|
||||||
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
|
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
|
||||||
return js
|
return js
|
81
javbus.py
81
javbus.py
@ -29,8 +29,7 @@ def getStudio(htmlcode): #获取厂商
|
|||||||
def getYear(htmlcode): #获取年份
|
def getYear(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[2]/text()')).strip(" ['']")
|
result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[2]/text()')).strip(" ['']")
|
||||||
result2 = str(re.search('\d{4}', result).group(0))
|
return result
|
||||||
return result2
|
|
||||||
def getCover(htmlcode): #获取封面链接
|
def getCover(htmlcode): #获取封面链接
|
||||||
doc = pq(htmlcode)
|
doc = pq(htmlcode)
|
||||||
image = doc('a.bigImage')
|
image = doc('a.bigImage')
|
||||||
@ -49,8 +48,8 @@ def getActor(htmlcode): #获取女优
|
|||||||
soup=BeautifulSoup(htmlcode,'lxml')
|
soup=BeautifulSoup(htmlcode,'lxml')
|
||||||
a=soup.find_all(attrs={'class':'star-name'})
|
a=soup.find_all(attrs={'class':'star-name'})
|
||||||
for i in a:
|
for i in a:
|
||||||
b.append(i.text)
|
b.append(i.get_text())
|
||||||
return ",".join(b)
|
return b
|
||||||
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(" ['']")
|
||||||
@ -64,6 +63,18 @@ def getOutline(htmlcode): #获取演员
|
|||||||
result = str(doc('tr td div.mg-b20.lh4 p.mg-b20').text())
|
result = str(doc('tr td div.mg-b20.lh4 p.mg-b20').text())
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def getTag(htmlcode): # 获取演员
|
||||||
|
tag = []
|
||||||
|
soup = BeautifulSoup(htmlcode, 'lxml')
|
||||||
|
a = soup.find_all(attrs={'class': 'genre'})
|
||||||
|
for i in a:
|
||||||
|
if 'onmouseout' in str(i):
|
||||||
|
continue
|
||||||
|
tag.append(i.get_text())
|
||||||
|
return tag
|
||||||
|
|
||||||
|
|
||||||
def main(number):
|
def main(number):
|
||||||
htmlcode=get_html('https://www.javbus.com/'+number)
|
htmlcode=get_html('https://www.javbus.com/'+number)
|
||||||
dww_htmlcode=get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", ''))
|
dww_htmlcode=get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", ''))
|
||||||
@ -79,28 +90,58 @@ def main(number):
|
|||||||
'number': getNum(htmlcode),
|
'number': getNum(htmlcode),
|
||||||
'cover': getCover(htmlcode),
|
'cover': getCover(htmlcode),
|
||||||
'imagecut': 1,
|
'imagecut': 1,
|
||||||
|
'tag':getTag(htmlcode)
|
||||||
}
|
}
|
||||||
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
|
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
|
||||||
return js
|
return js
|
||||||
|
|
||||||
def main_uncensored(number):
|
def main_uncensored(number):
|
||||||
htmlcode=get_html('https://www.javbus.com/'+number)
|
htmlcode = get_html('https://www.javbus.com/' + number)
|
||||||
dww_htmlcode=get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", ''))
|
dww_htmlcode = get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", ''))
|
||||||
|
#print('un')
|
||||||
|
#print('https://www.javbus.com/' + number)
|
||||||
dic = {
|
dic = {
|
||||||
'title': getTitle(htmlcode),
|
'title': getTitle(htmlcode),
|
||||||
'studio': getStudio(htmlcode),
|
'studio': getStudio(htmlcode),
|
||||||
'year': getYear(htmlcode),
|
'year': getYear(htmlcode),
|
||||||
'outline': getOutline(dww_htmlcode),
|
'outline': getOutline(htmlcode),
|
||||||
'runtime': getRuntime(htmlcode),
|
'runtime': getRuntime(htmlcode),
|
||||||
'director': getDirector(htmlcode),
|
'director': getDirector(htmlcode),
|
||||||
'actor': getActor(htmlcode),
|
'actor': getActor(htmlcode),
|
||||||
'release': getRelease(htmlcode),
|
'release': getRelease(htmlcode),
|
||||||
'number': getNum(htmlcode),
|
'number': getNum(htmlcode),
|
||||||
'cover': getCover(htmlcode),
|
'cover': getCover(htmlcode),
|
||||||
|
'tag': getTag(htmlcode),
|
||||||
'imagecut': 0,
|
'imagecut': 0,
|
||||||
}
|
}
|
||||||
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
|
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8')
|
||||||
return js
|
|
||||||
|
if getYear(htmlcode) == '':
|
||||||
|
#print('un2')
|
||||||
|
number2 = number.replace('-', '_')
|
||||||
|
htmlcode = get_html('https://www.javbus.com/' + number2)
|
||||||
|
#print('https://www.javbus.com/' + number2)
|
||||||
|
dww_htmlcode = get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number2.replace("_", ''))
|
||||||
|
dic = {
|
||||||
|
'title': getTitle(htmlcode),
|
||||||
|
'studio': getStudio(htmlcode),
|
||||||
|
'year': getYear(htmlcode),
|
||||||
|
'outline': getOutline(htmlcode),
|
||||||
|
'runtime': getRuntime(htmlcode),
|
||||||
|
'director': getDirector(htmlcode),
|
||||||
|
'actor': getActor(htmlcode),
|
||||||
|
'release': getRelease(htmlcode),
|
||||||
|
'number': getNum(htmlcode),
|
||||||
|
'cover': getCover(htmlcode),
|
||||||
|
'tag': getTag(htmlcode),
|
||||||
|
'imagecut': 0,
|
||||||
|
}
|
||||||
|
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8')
|
||||||
|
#print(js)
|
||||||
|
return js
|
||||||
|
else:
|
||||||
|
bbb=''
|
||||||
|
|
||||||
|
|
||||||
# def return1():
|
# def return1():
|
||||||
# json_data=json.loads(main('ipx-292'))
|
# json_data=json.loads(main('ipx-292'))
|
||||||
@ -115,15 +156,17 @@ def main_uncensored(number):
|
|||||||
# release = str(json_data['release'])
|
# release = str(json_data['release'])
|
||||||
# number = str(json_data['number'])
|
# number = str(json_data['number'])
|
||||||
# cover = str(json_data['cover'])
|
# cover = str(json_data['cover'])
|
||||||
|
# tag = str(json_data['tag'])
|
||||||
#
|
#
|
||||||
# # print(title)
|
# print(title)
|
||||||
# # print(studio)
|
# print(studio)
|
||||||
# # print(year)
|
# print(year)
|
||||||
# # print(outline)
|
# print(outline)
|
||||||
# # print(runtime)
|
# print(runtime)
|
||||||
# # print(director)
|
# print(director)
|
||||||
# # print(actor)
|
# print(actor)
|
||||||
# # print(release)
|
# print(release)
|
||||||
# # print(number)
|
# print(number)
|
||||||
# # print(cover)
|
# print(cover)
|
||||||
|
# print(tag)
|
||||||
# return1()
|
# return1()
|
7
siro.py
7
siro.py
@ -42,6 +42,10 @@ def getRelease(a):
|
|||||||
html = etree.fromstring(a, etree.HTMLParser())
|
html = etree.fromstring(a, etree.HTMLParser())
|
||||||
result=str(html.xpath('//table[2]/tr[5]/td/text()')).strip(" ['\\n ']")
|
result=str(html.xpath('//table[2]/tr[5]/td/text()')).strip(" ['\\n ']")
|
||||||
return result
|
return result
|
||||||
|
def getTag(a):
|
||||||
|
html = etree.fromstring(a, etree.HTMLParser())
|
||||||
|
result=str(html.xpath('//table[2]/tr[9]/td/text()')).strip(" ['\\n ']")
|
||||||
|
return result
|
||||||
def getCover(htmlcode):
|
def getCover(htmlcode):
|
||||||
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
html = etree.fromstring(htmlcode, etree.HTMLParser())
|
||||||
result = str(html.xpath('//*[@id="center_column"]/div[2]/div[1]/div/div/h2/img/@src')).strip(" ['']")
|
result = str(html.xpath('//*[@id="center_column"]/div[2]/div[1]/div/div/h2/img/@src')).strip(" ['']")
|
||||||
@ -58,7 +62,7 @@ def getOutline(htmlcode):
|
|||||||
def main(number):
|
def main(number):
|
||||||
htmlcode=get_html('https://www.mgstage.com/product/product_detail/'+str(number))
|
htmlcode=get_html('https://www.mgstage.com/product/product_detail/'+str(number))
|
||||||
soup = BeautifulSoup(htmlcode, 'lxml')
|
soup = BeautifulSoup(htmlcode, 'lxml')
|
||||||
a = str(soup.find(attrs={'class': 'detail_data'}))
|
a = str(soup.find(attrs={'class': 'detail_data'})).replace('\n ','')
|
||||||
dic = {
|
dic = {
|
||||||
'title': getTitle(htmlcode).replace("\\n",'').replace(' ',''),
|
'title': getTitle(htmlcode).replace("\\n",'').replace(' ',''),
|
||||||
'studio': getStudio(a),
|
'studio': getStudio(a),
|
||||||
@ -71,6 +75,7 @@ def main(number):
|
|||||||
'number': number,
|
'number': number,
|
||||||
'cover': getCover(htmlcode),
|
'cover': getCover(htmlcode),
|
||||||
'imagecut': 0,
|
'imagecut': 0,
|
||||||
|
'tag':' ',
|
||||||
}
|
}
|
||||||
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
|
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8')
|
||||||
return js
|
return js
|
Loading…
Reference in New Issue
Block a user