Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def search(cls, query, collection=None, fields=None, sorts=None, *args, **kwargs):
"""Search Internet Archive items.
:param fields: Retrieve these metadata fields for each item. List of
fields: https://archive.org/services/search/v1/fields
By default, 'title', 'publidate', and 'identifier' are retrieved.
:param sorts: A list of fields to use as sort order. Add
" asc" or " desc" to the name of the field to specify
ascending or descending order.
"""
fields = fields or []
for mandatory in ['title', 'publicdate']:
if not mandatory in fields:
fields.append(mandatory)
query = cls.modified_query(query, collection)
search = ia.search.Search(
cls.session(), query, *args, fields=fields, sorts=sorts,
**kwargs
)
for i in search.iter_as_results():
yield cls(i)
def _search(cls, query, *args, **kwargs):
"""Search Internet Archive items."""
fields = cls.FIELDS
sorts = ["date asc"]
query = query + " and mediatype:texts"
search = ia.search.Search(
cls.session(), query, *args, fields=fields, sorts=sorts,
params=dict(count=100, page=1),
**kwargs
)
try:
for i in search.iter_as_results():
yield i
except Exception as e:
print(e)
return
def search(cls, query, *args, **kwargs):
"""Search Internet Archive items."""
fields = cls.FIELDS
sorts = ["date asc"]
query = query + " and mediatype:texts"
search = ia.search.Search(
cls.session(), query, *args, fields=fields, sorts=sorts,
params=dict(count=10000),
**kwargs
)
for i in search.iter_as_results():
yield i