diff --git a/core.py b/core.py index a7bf420..892ea39 100644 --- a/core.py +++ b/core.py @@ -16,11 +16,12 @@ year='' outline='' runtime='' director='' -actor='' +actor=[] release='' number='' cover='' imagecut='' +tag=[] #=====================资源下载部分=========================== def DownloadFileWithFilename(url,filename,path): #path = examle:photo , video.in the Project Folder! @@ -58,12 +59,21 @@ def PrintFiles(path): print(" " + number + ".png", file=code) print(" " + number + ".png", file=code) print(" "+number + '.jpg'+"", file=code) - print(" ", file=code) - print(" " + actor + "", file=code) - print(" ", 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: + aaaa='' print(" " + number + "", file=code) print(" " + release + "", file=code) print(" "+cover+"", file=code) @@ -96,34 +106,47 @@ def getNumberFromFilename(filepath): global number global cover global imagecut + global tag - filename = str(os.path.basename(filepath)) #电影文件名 - str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filename)) + filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", os.path.basename(filepath))) print("[!]Making Data for ["+filename+"]") - a = str(re.search('\w+-\w+', filename).group()) + file_number = str(re.search('\w+-\w+', filename).group()) #print(a) - - # =======================网站规则添加============================== 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: - json_data = json.loads(fc2fans_club.main(a)) + json_data = json.loads(fc2fans_club.main(file_number)) 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: - json_data = json.loads(siro.main(a)) + json_data = json.loads(siro.main(file_number)) elif 'SIRO' in filename: - json_data = json.loads(siro.main(a)) + json_data = json.loads(siro.main(file_number)) elif '259luxu' in filename: - json_data = json.loads(siro.main(a)) + json_data = json.loads(siro.main(file_number)) elif '259LUXU' in filename: - json_data = json.loads(siro.main(a)) + json_data = json.loads(siro.main(file_number)) else: - json_data = json.loads(javbus.main(a)) - # ====================网站规则添加结束============================== + json_data = json.loads(javbus.main(file_number)) + + +#================================================网站规则添加结束================================================ + + + + + title = json_data['title'] studio = json_data['studio'] @@ -131,11 +154,12 @@ def getNumberFromFilename(filepath): outline = json_data['outline'] runtime = json_data['runtime'] director = json_data['director'] - actor = json_data['actor'] + 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(',') except: print('[-]File '+filename+'`s number can not be caught') print('[-]Move ' + filename + ' to failed folder') @@ -151,19 +175,21 @@ def getNumberFromFilename(filepath): path = '' #设置path为全局变量,后面移动文件要用 def creatFolder(): + actor2 = str(actor).strip("[ ]").replace("'",'').replace(" ",'') global path if not os.path.exists('failed/'): #新建failed文件夹 os.makedirs('failed/') if not os.path.exists('failed/'): print("[-]failed!Dirs can not be make (Please run as Administrator)") os._exit(0) - if len(actor) > 240: #新建成功输出文件夹 + if len(actor2) > 240: #新建成功输出文件夹 path = 'JAV_output' + '/' + '超多人' + '/' + number #path为影片+元数据所在目录 else: - path = 'JAV_output' + '/' + str(actor) + '/' + str(number) + path = 'JAV_output' + '/' + str(actor2) + '/' + str(number) if not os.path.exists(path): os.makedirs(path) path = str(os.getcwd())+'/'+path + def imageDownload(filepath): #封面是否下载成功,否则移动到failed if DownloadFileWithFilename(cover,str(number) + '.jpg', path) == 'failed': shutil.move(filepath, 'failed/') diff --git a/fc2fans_club.py b/fc2fans_club.py index bb2cda6..d854ce8 100644 --- a/fc2fans_club.py +++ b/fc2fans_club.py @@ -31,6 +31,11 @@ def getOutline(htmlcode,number): #获取番号 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 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): str(number).lstrip("FC2-").lstrip("fc2-").lstrip("fc2_").lstrip("fc2-") @@ -47,6 +52,7 @@ def main(number): 'number': 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 diff --git a/javbus.py b/javbus.py index 7d20586..fc68aef 100644 --- a/javbus.py +++ b/javbus.py @@ -29,8 +29,7 @@ def getStudio(htmlcode): #获取厂商 def getYear(htmlcode): #获取年份 html = etree.fromstring(htmlcode,etree.HTMLParser()) 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 result2 + return result def getCover(htmlcode): #获取封面链接 doc = pq(htmlcode) image = doc('a.bigImage') @@ -49,8 +48,8 @@ def getActor(htmlcode): #获取女优 soup=BeautifulSoup(htmlcode,'lxml') a=soup.find_all(attrs={'class':'star-name'}) for i in a: - b.append(i.text) - return ",".join(b) + b.append(i.get_text()) + return b 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(" ['']") @@ -64,6 +63,18 @@ def getOutline(htmlcode): #获取演员 result = str(doc('tr td div.mg-b20.lh4 p.mg-b20').text()) 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): htmlcode=get_html('https://www.javbus.com/'+number) 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), 'cover': getCover(htmlcode), 'imagecut': 1, + 'tag':getTag(htmlcode) } js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'),)#.encode('UTF-8') return js def main_uncensored(number): - htmlcode=get_html('https://www.javbus.com/'+number) - dww_htmlcode=get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", '')) + htmlcode = get_html('https://www.javbus.com/' + number) + dww_htmlcode = get_html("https://www.dmm.co.jp/mono/dvd/-/detail/=/cid=" + number.replace("-", '')) + #print('un') + #print('https://www.javbus.com/' + number) dic = { 'title': getTitle(htmlcode), 'studio': getStudio(htmlcode), 'year': getYear(htmlcode), - 'outline': getOutline(dww_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') - return js + js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8') + + 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(): # json_data=json.loads(main('ipx-292')) @@ -115,15 +156,17 @@ def main_uncensored(number): # release = str(json_data['release']) # number = str(json_data['number']) # cover = str(json_data['cover']) +# tag = str(json_data['tag']) # -# # print(title) -# # print(studio) -# # print(year) -# # print(outline) -# # print(runtime) -# # print(director) -# # print(actor) -# # print(release) -# # print(number) -# # print(cover) +# print(title) +# print(studio) +# print(year) +# print(outline) +# print(runtime) +# print(director) +# print(actor) +# print(release) +# print(number) +# print(cover) +# print(tag) # return1() \ No newline at end of file diff --git a/siro.py b/siro.py index f5d4681..548d610 100644 --- a/siro.py +++ b/siro.py @@ -42,6 +42,10 @@ def getRelease(a): html = etree.fromstring(a, etree.HTMLParser()) result=str(html.xpath('//table[2]/tr[5]/td/text()')).strip(" ['\\n ']") 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): html = etree.fromstring(htmlcode, etree.HTMLParser()) 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): htmlcode=get_html('https://www.mgstage.com/product/product_detail/'+str(number)) soup = BeautifulSoup(htmlcode, 'lxml') - a = str(soup.find(attrs={'class': 'detail_data'})) + a = str(soup.find(attrs={'class': 'detail_data'})).replace('\n ','') dic = { 'title': getTitle(htmlcode).replace("\\n",'').replace(' ',''), 'studio': getStudio(a), @@ -71,6 +75,7 @@ def main(number): 'number': number, 'cover': getCover(htmlcode), '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