From 8a4db3775177173eedd73d94c2300021ed790892 Mon Sep 17 00:00:00 2001 From: nianeyna Date: Sat, 20 Jan 2024 18:39:31 -0800 Subject: [PATCH] Add trycatch when writing links to file - fixes #110 - h/t github user Kyther's friend for suggesting the fix which I (perhaps lazily) implemented exactly as written --- ao3downloader/actions/getlinks.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ao3downloader/actions/getlinks.py b/ao3downloader/actions/getlinks.py index c118247..10ef1f7 100644 --- a/ao3downloader/actions/getlinks.py +++ b/ao3downloader/actions/getlinks.py @@ -33,7 +33,10 @@ def action(): writer = csv.DictWriter(f, fieldnames=keys) writer.writeheader() for item in flattened: - writer.writerow(item) + try: + writer.writerow(item) + except ValueError: + fileops.write_log(item) else: filename = f'links_{datetime.datetime.now().strftime("%m%d%Y%H%M%S")}.txt' with open(os.path.join(strings.DOWNLOAD_FOLDER_NAME, filename), 'w') as f: