From 7eee5a96b794562277ab9c1c2ce91e37469aed0b Mon Sep 17 00:00:00 2001 From: DuncanDHall Date: Wed, 23 Aug 2023 12:53:27 -0400 Subject: [PATCH] Patch search error Currently key error is thrown when elastic search returns no 'response' key in its json when we try to grab the num_found. --- internetarchive/search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internetarchive/search.py b/internetarchive/search.py index 34791467..0205d691 100644 --- a/internetarchive/search.py +++ b/internetarchive/search.py @@ -130,7 +130,7 @@ def _advanced_search(self): auth=self.auth, **self.request_kwargs) j = r.json() - num_found = int(j['response']['numFound']) + num_found = int(j.get('response', {}).get('numFound', 0)) if not self._num_found: self._num_found = num_found if j.get('error'):