Skip to content

Commit

Permalink
Merge pull request #665 from jjjake/num_found_search_bug
Browse files Browse the repository at this point in the history
Advanced Seach num_found bug fix
  • Loading branch information
jjjake authored Nov 15, 2024
2 parents 4f0dadd + 469ca7a commit 22b6f66
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Release History
**Bugfixes**

- Fixed bug where some error messages mentioned the wrong arg in the message.
- Fixed bug where Scrape API was being used for num-found,
even if Advanced Search was triggered via page/rows params.

5.0.3 (2024-11-12)
++++++++++++++++++
Expand Down
2 changes: 1 addition & 1 deletion internetarchive/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '5.0.4.dev1'
__version__ = '5.0.4.dev2'
13 changes: 12 additions & 1 deletion internetarchive/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,18 @@ def _user_aggs(self):
@property
def num_found(self):
if not self._num_found:
if not self.fts:
if not self.fts and 'page' in self.params:
p = self.params.copy()
p['output'] = 'json'
r = self.session.get(self.search_url,
params=p,
auth=self.auth,
**self.request_kwargs)
j = r.json()
num_found = int(j.get('response', {}).get('numFound', 0))
if not self._num_found:
self._num_found = num_found
elif not self.fts:
p = self.params.copy()
p['total_only'] = 'true'
r = self.session.post(self.scrape_url,
Expand Down

0 comments on commit 22b6f66

Please sign in to comment.