Skip to content

Commit

Permalink
fixing getids
Browse files Browse the repository at this point in the history
  • Loading branch information
mekarpeles authored and Mek committed Sep 26, 2024
1 parent 28ffe1f commit 7685d02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
7 changes: 4 additions & 3 deletions iiify/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ def mainentry():
@app.route('/iiif/')
def index():
"""Lists all available book and image items on Archive.org"""
cursor = request.args.get('cursor', '')
q = request.args.get('q', '')
return jsonify(getids(q, cursor=cursor))

fields = request.args.get('fields', '')
sorts = request.args.get('sorts', '')
cursor = request.args.get('cursor', '')
return jsonify(getids(q, cursor=cursor, fields=fields, sorts=sorts))


@app.route('/iiif/collection.json')
Expand Down
14 changes: 3 additions & 11 deletions iiify/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,13 @@ def purify_domain(domain):
domain = re.sub('^http:\/\/', "https://", domain)
return domain if domain.endswith('/iiif/') else domain + 'iiif/'

def getids(q, limit=1000, cursor='', page=1):
q = request.args.get('q', '')
def getids(q, limit=1000, cursor='', sorts='', fields=''):
query = "(mediatype:(texts) OR mediatype:(image))" + \
((" AND %s" % q) if q else "")
fields = request.args.get('fields', '')
sorts = request.args.get('sorts', '')
cursor = request.args.get('cursor', '')
version = 'v2'

# 'all:1' also works
q = "NOT identifier:..*" + (" AND (%s)" % query if query else "")
if version == 'v2':
return scrape(query=q, fields=fields, sorts=sorts, count=limit,
cursor=cursor)
return search(q, page=page, limit=limit)
return scrape(query=q, fields=fields, sorts=sorts, count=limit, cursor=cursor)


def scrape(query, fields="", sorts="", count=100, cursor="", security=True):
"""
Expand Down

0 comments on commit 7685d02

Please sign in to comment.