Fix crash caused by custom site

This commit is contained in:
yoshiko2
2021-07-10 15:01:56 +08:00
parent 80b973ef59
commit 5a80f13bec

50
core.py
View File

@@ -71,35 +71,35 @@ def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON
# default fetch order list, from the beginning to the end # default fetch order list, from the beginning to the end
sources = conf.sources().split(',') sources = conf.sources().split(',')
if not len(conf.sources()) > 60:
# if the input file name matches certain rules, # if the input file name matches certain rules,
# move some web service to the beginning of the list # move some web service to the beginning of the list
lo_file_number = file_number.lower() lo_file_number = file_number.lower()
if "carib" in sources and (re.match(r"^\d{6}-\d{3}", file_number) if "carib" in sources and (re.match(r"^\d{6}-\d{3}", file_number)
): ):
sources.insert(0, sources.pop(sources.index("carib"))) sources.insert(0, sources.pop(sources.index("carib")))
elif "avsox" in sources and (re.match(r"^\d{5,}", file_number) or elif "avsox" in sources and (re.match(r"^\d{5,}", file_number) or
"heyzo" in lo_file_number "heyzo" in lo_file_number
): ):
sources.insert(0, sources.pop(sources.index("javdb"))) sources.insert(0, sources.pop(sources.index("javdb")))
sources.insert(1, sources.pop(sources.index("avsox"))) sources.insert(1, sources.pop(sources.index("avsox")))
elif "mgstage" in sources and (re.match(r"\d+\D+", file_number) or elif "mgstage" in sources and (re.match(r"\d+\D+", file_number) or
"siro" in lo_file_number "siro" in lo_file_number
): ):
sources.insert(0, sources.pop(sources.index("mgstage"))) sources.insert(0, sources.pop(sources.index("mgstage")))
elif "fc2" in sources and ("fc2" in lo_file_number elif "fc2" in sources and ("fc2" in lo_file_number
): ):
sources.insert(0, sources.pop(sources.index("javdb"))) sources.insert(0, sources.pop(sources.index("javdb")))
sources.insert(1, sources.pop(sources.index("fc2"))) sources.insert(1, sources.pop(sources.index("fc2")))
elif "dlsite" in sources and ( elif "dlsite" in sources and (
"rj" in lo_file_number or "vj" in lo_file_number "rj" in lo_file_number or "vj" in lo_file_number
): ):
sources.insert(0, sources.pop(sources.index("dlsite"))) sources.insert(0, sources.pop(sources.index("dlsite")))
json_data = {} json_data = {}
if conf.multi_threading(): if conf.multi_threading():
pool = ThreadPool(processes=11) pool = ThreadPool(processes=len(conf.sources().split(',')))
# Set the priority of multi-thread crawling and join the multi-thread queue # Set the priority of multi-thread crawling and join the multi-thread queue
for source in sources: for source in sources: