refactor search logic
This commit is contained in:
parent
690557f878
commit
a4c8bcf2b4
66
core.py
66
core.py
@ -12,7 +12,7 @@ from configparser import ConfigParser
|
|||||||
import argparse
|
import argparse
|
||||||
# =========website========
|
# =========website========
|
||||||
import fc2fans_club
|
import fc2fans_club
|
||||||
import siro
|
import mgstage
|
||||||
import avsox
|
import avsox
|
||||||
import javbus
|
import javbus
|
||||||
import javdb
|
import javdb
|
||||||
@ -46,38 +46,40 @@ def CreatFailedFolder(failed_folder):
|
|||||||
|
|
||||||
|
|
||||||
def getDataFromJSON(file_number, filepath, failed_folder): # 从JSON返回元数据
|
def getDataFromJSON(file_number, filepath, failed_folder): # 从JSON返回元数据
|
||||||
# ================================================网站规则添加开始================================================
|
"""
|
||||||
|
iterate through all services and fetch the data
|
||||||
|
"""
|
||||||
|
|
||||||
if re.match('^\d{5,}', file_number):
|
func_mapping = {
|
||||||
json_data = json.loads(avsox.main(file_number))
|
"avsox": avsox.main,
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
"fc2": fc2fans_club.main,
|
||||||
json_data = json.loads(javdb.main(file_number))
|
"fanza": fanza.main,
|
||||||
# ==
|
"javdb": javdb.main,
|
||||||
elif re.match('\d+\D+', file_number):
|
"javbus": javbus.main,
|
||||||
json_data = json.loads(siro.main(file_number))
|
"mgstage": mgstage.main,
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
}
|
||||||
json_data = json.loads(javbus.main(file_number))
|
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
# default fetch order list, from the begining to the end
|
||||||
json_data = json.loads(javdb.main(file_number))
|
sources = ["fanza", "mgstage", "fc2", "javbus", "avsox", "javdb"]
|
||||||
# ==
|
|
||||||
elif 'fc2' in file_number or 'FC2' in file_number:
|
# if the input file name matches centain rules,
|
||||||
json_data = json.loads(fc2fans_club.main(
|
# move some web service to the begining of the list
|
||||||
file_number.replace('fc2-', '').replace('fc2_', '').replace('FC2-', '').replace('fc2_', '')))
|
if re.match(r"^\d{5,}", file_number) or (
|
||||||
# ==
|
"HEYZO" in file_number or "heyzo" in file_number or "Heyzo" in file_number
|
||||||
elif 'HEYZO' in file_number or 'heyzo' in file_number or 'Heyzo' in file_number:
|
):
|
||||||
json_data = json.loads(avsox.main(file_number))
|
sources.insert(0, sources.pop(sources.index("avsox")))
|
||||||
# ==
|
elif re.match(r"\d+\D+", file_number) or (
|
||||||
elif 'siro' in file_number or 'SIRO' in file_number or 'Siro' in file_number:
|
"siro" in file_number or "SIRO" in file_number or "Siro" in file_number
|
||||||
json_data = json.loads(siro.main(file_number))
|
):
|
||||||
# ==
|
sources.insert(0, sources.pop(sources.index("mgstage")))
|
||||||
else:
|
elif "fc2" in file_number or "FC2" in file_number:
|
||||||
json_data = json.loads(fanza.main(file_number))
|
sources.insert(0, sources.pop(sources.index("fc2")))
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
|
||||||
json_data = json.loads(javbus.main(file_number))
|
for source in sources:
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
json_data = json.loads(func_mapping[source](file_number))
|
||||||
json_data = json.loads(avsox.main(file_number))
|
# if any service return a valid return, break
|
||||||
if getDataState(json_data) == 0: # 如果元数据获取失败,请求番号至其他网站抓取
|
if getDataState(json_data) != 0:
|
||||||
json_data = json.loads(javdb.main(file_number))
|
break
|
||||||
|
|
||||||
# ================================================网站规则添加结束================================================
|
# ================================================网站规则添加结束================================================
|
||||||
|
|
||||||
|
@ -100,9 +100,9 @@ def main(number2):
|
|||||||
'year': getYear(getRelease(a)), # str(re.search('\d{4}',getRelease(a)).group()),
|
'year': getYear(getRelease(a)), # str(re.search('\d{4}',getRelease(a)).group()),
|
||||||
'actor_photo': '',
|
'actor_photo': '',
|
||||||
'website':'https://www.mgstage.com/product/product_detail/'+str(number)+'/',
|
'website':'https://www.mgstage.com/product/product_detail/'+str(number)+'/',
|
||||||
'source': 'siro.py',
|
'source': 'mgstage.py',
|
||||||
}
|
}
|
||||||
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
|
||||||
|
|
||||||
#print(main('SIRO-3607'))
|
#print(main('SIRO-3607'))
|
Loading…
Reference in New Issue
Block a user