javbus:fix uri

This commit is contained in:
lededev
2021-06-06 04:31:12 +08:00
parent 9538a873bc
commit 0989195008
2 changed files with 23 additions and 14 deletions

View File

@@ -47,9 +47,10 @@ def getYear(htmlcode): #获取年份
def getCover(htmlcode): #获取封面链接 def getCover(htmlcode): #获取封面链接
doc = pq(htmlcode) doc = pq(htmlcode)
image = doc('a.bigImage') image = doc('a.bigImage')
if not "javbus.com" in image.attr('href'): uri = image.attr('href')
return "https://www.javbus.com" + image.attr('href') if uri[0] == '/':
return image.attr('href') return "https://www.javbus.com" + uri
return uri
def getRelease(htmlcode): #获取出版日期 def getRelease(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(" ['']")
@@ -193,3 +194,4 @@ def main(number):
if __name__ == "__main__" : if __name__ == "__main__" :
print(main('ipx-292')) print(main('ipx-292'))
print(main('CEMD-011'))

29
core.py
View File

@@ -4,6 +4,7 @@ import pathlib
import re import re
import shutil import shutil
import platform import platform
import errno
from PIL import Image from PIL import Image
from io import BytesIO from io import BytesIO
@@ -49,7 +50,7 @@ def moveFailedFolder(filepath, failed_folder):
def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON返回元数据 def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON返回元数据
""" """
iterate through all services and fetch the data iterate through all services and fetch the data
""" """
func_mapping = { func_mapping = {
@@ -150,17 +151,17 @@ def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON
cover_small = '' cover_small = ''
else: else:
cover_small = json_data.get('cover_small') cover_small = json_data.get('cover_small')
if json_data.get('trailer') == None: if json_data.get('trailer') == None:
trailer = '' trailer = ''
else: else:
trailer = json_data.get('trailer') trailer = json_data.get('trailer')
if json_data.get('extrafanart') == None: if json_data.get('extrafanart') == None:
extrafanart = '' extrafanart = ''
else: else:
extrafanart = json_data.get('extrafanart') extrafanart = json_data.get('extrafanart')
imagecut = json_data.get('imagecut') imagecut = json_data.get('imagecut')
tag = str(json_data.get('tag')).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表 @ tag = str(json_data.get('tag')).strip("[ ]").replace("'", '').replace(" ", '').split(',') # 字符串转列表 @
actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '') actor = str(actor_list).strip("[ ]").replace("'", '').replace(" ", '')
@@ -226,7 +227,7 @@ def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON
studio = re.sub('.*/妄想族','妄想族',studio) studio = re.sub('.*/妄想族','妄想族',studio)
studio = studio.replace('/',' ') studio = studio.replace('/',' ')
# === 替换Studio片假名 END # === 替换Studio片假名 END
location_rule = eval(conf.location_rule()) location_rule = eval(conf.location_rule())
if 'actor' in conf.location_rule() and len(actor) > 100: if 'actor' in conf.location_rule() and len(actor) > 100:
@@ -277,7 +278,7 @@ def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON
json_data['trailer'] = '' json_data['trailer'] = ''
else: else:
json_data['trailer'] = '' json_data['trailer'] = ''
if conf.is_extrafanart(): if conf.is_extrafanart():
if extrafanart: if extrafanart:
json_data['extrafanart'] = extrafanart json_data['extrafanart'] = extrafanart
@@ -285,7 +286,7 @@ def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON
json_data['extrafanart'] = '' json_data['extrafanart'] = ''
else: else:
json_data['extrafanart'] = '' json_data['extrafanart'] = ''
naming_rule="" naming_rule=""
for i in conf.naming_rule().split("+"): for i in conf.naming_rule().split("+"):
if i not in json_data: if i not in json_data:
@@ -644,6 +645,9 @@ def paste_file_to_folder(filepath, path, number, leak_word, c_word, conf: config
except PermissionError: except PermissionError:
print('[-]Error! Please run as administrator!') print('[-]Error! Please run as administrator!')
return return
except OSError as oserr:
print('[-]OS Error errno ' + oserr.errno)
return
def paste_file_to_folder_mode2(filepath, path, multi_part, number, part, leak_word, c_word, conf): # 文件路径,番号,后缀,要移动至的位置 def paste_file_to_folder_mode2(filepath, path, multi_part, number, part, leak_word, c_word, conf): # 文件路径,番号,后缀,要移动至的位置
@@ -656,7 +660,7 @@ def paste_file_to_folder_mode2(filepath, path, multi_part, number, part, leak_wo
os.symlink(filepath, path + '/' + number + part + leak_word + c_word + houzhui) os.symlink(filepath, path + '/' + number + part + leak_word + c_word + houzhui)
else: else:
os.rename(filepath, path + '/' + number + part + leak_word + c_word + houzhui) os.rename(filepath, path + '/' + number + part + leak_word + c_word + houzhui)
sub_res = conf.sub_rule() sub_res = conf.sub_rule()
for subname in sub_res: for subname in sub_res:
if os.path.exists(filepath.replace(houzhui, subname)): # 字幕移动 if os.path.exists(filepath.replace(houzhui, subname)): # 字幕移动
@@ -671,6 +675,9 @@ def paste_file_to_folder_mode2(filepath, path, multi_part, number, part, leak_wo
except PermissionError: except PermissionError:
print('[-]Error! Please run as administrator!') print('[-]Error! Please run as administrator!')
return return
except OSError as oserr:
print('[-]OS Error errno ' + oserr.errno)
return
def get_part(filepath, failed_folder): def get_part(filepath, failed_folder):
try: try:
@@ -742,8 +749,8 @@ def core_main(file_path, number_th, conf: config.Config):
uncensored = 1 uncensored = 1
else: else:
uncensored = 0 uncensored = 0
if '流出' in filepath or 'uncensored' in filepath: if '流出' in filepath or 'uncensored' in filepath:
liuchu = '流出' liuchu = '流出'
leak = 1 leak = 1
@@ -795,7 +802,7 @@ def core_main(file_path, number_th, conf: config.Config):
# 移动文件 # 移动文件
paste_file_to_folder(filepath, path, number, leak_word, c_word, conf) paste_file_to_folder(filepath, path, number, leak_word, c_word, conf)
poster_path = path + '/' + number + leak_word + c_word + '-poster.jpg' poster_path = path + '/' + number + leak_word + c_word + '-poster.jpg'
thumb_path = path + '/' + number + leak_word + c_word + '-thumb.jpg' thumb_path = path + '/' + number + leak_word + c_word + '-thumb.jpg'
if conf.is_watermark(): if conf.is_watermark():