try fix issue #751
This commit is contained in:
@@ -381,7 +381,7 @@ def load_cookies(cookie_json_filename: str):
|
||||
break
|
||||
if not cookies_filename:
|
||||
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:
|
||||
return None, None
|
||||
|
||||
@@ -519,14 +519,13 @@ def download_one_file(args) -> str:
|
||||
wrapped for map function
|
||||
"""
|
||||
|
||||
def _inner(url: str, save_path: Path):
|
||||
(url, save_path) = args
|
||||
filebytes = get_html(url, return_type='content')
|
||||
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 _inner(*args)
|
||||
|
||||
|
||||
def parallel_download_files(dn_list: typing.Iterable[typing.Sequence], parallel: int = 0):
|
||||
"""
|
||||
|
||||
@@ -248,8 +248,8 @@ def get_data_from_json(file_number, oCC):
|
||||
if json_data[translate_value] == "":
|
||||
continue
|
||||
if translate_value == "title":
|
||||
title_dict = json.load(
|
||||
open(str(Path.home() / '.local' / 'share' / 'mdc' / 'c_number.json'), 'r', encoding="utf-8"))
|
||||
title_dict = json.loads(
|
||||
(Path.home() / '.local' / 'share' / 'mdc' / 'c_number.json').read_text(encoding="utf-8"))
|
||||
try:
|
||||
json_data[translate_value] = title_dict[number]
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user