try fix issue #751

This commit is contained in:
lededev
2022-04-06 12:08:51 +08:00
parent b251a127c8
commit 580139c626
2 changed files with 8 additions and 9 deletions

View File

@@ -381,7 +381,7 @@ def load_cookies(cookie_json_filename: str):
break break
if not cookies_filename: if not cookies_filename:
return None, None return None, None
return json.load(open(cookies_filename)), cookies_filename return json.loads(Path(cookies_filename).read_text(encoding='utf-8')), cookies_filename
except: except:
return None, None return None, None
@@ -519,14 +519,13 @@ def download_one_file(args) -> str:
wrapped for map function wrapped for map function
""" """
def _inner(url: str, save_path: Path): (url, save_path) = args
filebytes = get_html(url, return_type='content') filebytes = get_html(url, return_type='content')
if isinstance(filebytes, bytes) and len(filebytes): if isinstance(filebytes, bytes) and len(filebytes):
if len(filebytes) == save_path.open('wb').write(filebytes): with save_path.open('wb') as fpbyte:
if len(filebytes) == fpbyte.write(filebytes):
return str(save_path) return str(save_path)
return _inner(*args)
def parallel_download_files(dn_list: typing.Iterable[typing.Sequence], parallel: int = 0): def parallel_download_files(dn_list: typing.Iterable[typing.Sequence], parallel: int = 0):
""" """

View File

@@ -248,8 +248,8 @@ def get_data_from_json(file_number, oCC):
if json_data[translate_value] == "": if json_data[translate_value] == "":
continue continue
if translate_value == "title": if translate_value == "title":
title_dict = json.load( title_dict = json.loads(
open(str(Path.home() / '.local' / 'share' / 'mdc' / 'c_number.json'), 'r', encoding="utf-8")) (Path.home() / '.local' / 'share' / 'mdc' / 'c_number.json').read_text(encoding="utf-8"))
try: try:
json_data[translate_value] = title_dict[number] json_data[translate_value] = title_dict[number]
continue continue