diff --git a/mvw-dl.py b/mvw-dl.py index 5e279d8..2bf2639 100644 --- a/mvw-dl.py +++ b/mvw-dl.py @@ -475,7 +475,7 @@ def state_file_none_or_valid_json( if os.path.exists(state_file_abs_path): if os.path.getsize(state_file_abs_path) > 0: - with open(state_file_abs_path, "r") as state_file: + with open(state_file_abs_path, "r", encoding="utf-8") as state_file: try: json.loads(state_file.read()) return True @@ -535,7 +535,7 @@ def log_successful_download( with lock: state_file_none_or_valid_json(state_file_abs_path) - with open(state_file_abs_path, "r+") as state_file: + with open(state_file_abs_path, "r+", encoding="utf-8") as state_file: try: json_state = json.load(state_file) except json.JSONDecodeError: @@ -544,12 +544,12 @@ def log_successful_download( json_state = [] log.debug(f"{shorthand_uuid} Writing log entry to '{state_file_abs_path}' ...") - with open(state_file_abs_path, "w") as state_file: + with open(state_file_abs_path, "w", encoding="utf-8") as state_file: json_state.append(state_entry) max_log_entries = config_obj.getint(section_name, "state_file_retention") if len(json_state) > max_log_entries: json_state = truncate_log(json_state, max_log_entries) - json.dump(json_state, state_file, indent=4, sort_keys=True) + json.dump(json_state, state_file, indent=4, sort_keys=True, ensure_ascii=False) def copy_url(