Skip to content

Commit

Permalink
Catch and log archive.org key errors
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Sep 14, 2024
1 parent e985488 commit 54940df
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion netkan/netkan/download_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ def get_result(self, counts: Optional[Dict[str, int]] = None) -> Dict[str, int]:
result = requests.get(self.IARCHIVE_API + ','.join(self.ids.values()),
timeout=60).json()
for ckan_ident, ia_ident in self.ids.items():
counts[ckan_ident] = counts.get(ckan_ident, 0) + result[ia_ident]['all_time']
try:
counts[ckan_ident] = counts.get(ckan_ident, 0) + result[ia_ident]['all_time']
except KeyError as exc:
logging.error('InternetArchive id not found in downloads result: %s',
ia_ident, exc_info=exc)
return counts


Expand Down

0 comments on commit 54940df

Please sign in to comment.