mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
6091edca84
commit
4e428219c9
@ -24,9 +24,9 @@ cover_url_cache = {}
|
||||
cache_lock = RLock()
|
||||
base_url = 'http://search.overdrive.com/'
|
||||
|
||||
class ContentReserve(Source):
|
||||
|
||||
def create_query(self, title=None, authors=None, identifiers={}):
|
||||
|
||||
def create_query(self, title=None, authors=None, identifiers={}):
|
||||
q = ''
|
||||
if title or authors:
|
||||
def build_term(prefix, parts):
|
||||
@ -46,9 +46,6 @@ class ContentReserve(Source):
|
||||
return None
|
||||
return BASE_URL+urlencode({
|
||||
'q':q,
|
||||
'max-results':20,
|
||||
'start-index':1,
|
||||
'min-viewability':'none',
|
||||
})
|
||||
|
||||
|
||||
@ -82,9 +79,20 @@ def format_results(reserveid, od_title, subtitle, series, publisher, creators, t
|
||||
def overdrive_search(br, q, title, author):
|
||||
q_query = q+'default.aspx/SearchByKeyword'
|
||||
q_init_search = q+'SearchResults.aspx'
|
||||
|
||||
# get first author as string - convert this to a proper cleanup function later
|
||||
s = Source(None)
|
||||
print "printing list with string:"
|
||||
print list(s.get_author_tokens(['J. R. R. Tolkien']))
|
||||
print "printing list with author "+str(author)+":"
|
||||
print list(s.get_author_tokens(author))
|
||||
author = list(s.get_author_tokens(author))
|
||||
for token in author:
|
||||
print "cleaned up author is: "+str(token)
|
||||
author_q = '+'.join(author)
|
||||
#author_q = separator.join(for x in author)
|
||||
# query terms
|
||||
author_q = re.sub('\s', '+', author)
|
||||
#author_q = re.sub('\s', '+', author_q)
|
||||
print "final author query is "+str(author_q)
|
||||
q_xref = q+'SearchResults.svc/GetResults?iDisplayLength=10&sSearch='+author_q
|
||||
query = '{"szKeyword":"'+title+'"}'
|
||||
|
||||
@ -231,9 +239,6 @@ def get_cover_url(isbn, title, author, br):
|
||||
print "isbn is "+str(isbn)
|
||||
print "title is "+str(title)
|
||||
print "author is "+str(author[0])
|
||||
cleanup = ContentReserve()
|
||||
query = cleanup.create_query(author, title)
|
||||
print "cleansed query is "+str(author)
|
||||
|
||||
with cache_lock:
|
||||
ans = cover_url_cache.get(isbn, None)
|
||||
@ -386,8 +391,8 @@ def main(args=sys.argv):
|
||||
for isbn, title, author in [
|
||||
#('0899661343', 'On the Road', ['Jack Kerouac']), # basic test, no series, single author
|
||||
#('9780061952838', 'The Fellowship of the Ring', ['J. R. R. Tolkien']), # Series test, multi-author
|
||||
#('9780061952838', 'The Two Towers', ['J. R. R. Tolkien']), # Series test, book 2
|
||||
('9780345505057', 'Deluge', ['Anne McCaffrey']) # Multiple authors
|
||||
('9780061952838', 'The Two Towers', ['J. R. R. Tolkien']), # Series test, book 2
|
||||
#('9780345505057', 'Deluge', ['Anne McCaffrey']) # Multiple authors
|
||||
#('', 'Deluge', ['Anne McCaffrey']) # Empty ISBN
|
||||
#(None, 'On the Road', ['Jack Kerouac']) # Nonetype ISBN
|
||||
]:
|
||||
|
Loading…
x
Reference in New Issue
Block a user