From 121c4496a4226405aea5e34902d5807f5dfaa880 Mon Sep 17 00:00:00 2001 From: DuncanDHall Date: Mon, 3 Apr 2023 10:54:41 -0400 Subject: [PATCH] Fix TypeError when iterating over 0 search results Scrape can result in `j` where `count: 0, total: None` resulting in: `TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'` --- internetarchive/search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internetarchive/search.py b/internetarchive/search.py index 34791467..b9168147 100644 --- a/internetarchive/search.py +++ b/internetarchive/search.py @@ -153,7 +153,7 @@ def _scrape(self): if j.get('error'): yield j if not num_found: - num_found = int(j['total']) + num_found = int(j['total'] or 0) if not self._num_found: self._num_found = num_found self._handle_scrape_error(j)