Skip to content

Commit

Permalink
Add trycatch when writing links to file
Browse files Browse the repository at this point in the history
- fixes #110
- h/t github user Kyther's friend for suggesting the fix which I (perhaps lazily) implemented exactly as written
  • Loading branch information
nianeyna committed Jan 21, 2024
1 parent a910039 commit 8a4db37
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ao3downloader/actions/getlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8a4db37

Please sign in to comment.