From 36e347ed34c04352a591daf1ef35c74d6430fa35 Mon Sep 17 00:00:00 2001 From: mukkino <25956452+fabiolichinchi@users.noreply.github.com> Date: Fri, 14 Oct 2022 00:59:46 +0000 Subject: [PATCH] utf-8 issues while writing logs fixed an error related to the logs output charmap --- pinterest-downloader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pinterest-downloader.py b/pinterest-downloader.py index fae08ab..3c5f903 100755 --- a/pinterest-downloader.py +++ b/pinterest-downloader.py @@ -1036,7 +1036,7 @@ def write_log(arg_timestamp_log, url_path, shortform # Don't want combine with old log or else you need open the file to see got title/desc or not even though no content. log_url_path = os.path.join(save_dir, 'urls-pinterest-downloader.urls') - with open(log_url_path, 'w') as f: + with open(log_url_path, 'w', encoding="utf-8") as f: f.write('Pinterest Downloader: Version ' + str(__version__) + '\n\n') # Easy to recognize if future want to change something # Ensure -ua same parsing format f.write('Input URL: https://www.pinterest.com/' + url_path.rstrip('/') + '/\n') # Reuse/refer when want to update @@ -1050,7 +1050,7 @@ def write_log(arg_timestamp_log, url_path, shortform if break_from_latest_pin and not arg_timestamp_log: try: - with open(log_path) as f: + with open(log_path, encoding="utf-8") as f: index_line = [l for l in f.readlines() if l.startswith('[ ')] index_last_tmp = index_line[-1].split('[ ')[1].split(' ]')[0] if index_last_tmp.isdigit():