From e3fa34c0a2b64adc59398fc60619ac51aa294df7 Mon Sep 17 00:00:00 2001 From: Lee Date: Sat, 23 Apr 2011 17:27:53 +0800 Subject: [PATCH] Overdrive: handle unspecified author with exact title match --- src/calibre/ebooks/metadata/sources/overdrive.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/metadata/sources/overdrive.py b/src/calibre/ebooks/metadata/sources/overdrive.py index 94dd61fd9c..759da45610 100755 --- a/src/calibre/ebooks/metadata/sources/overdrive.py +++ b/src/calibre/ebooks/metadata/sources/overdrive.py @@ -206,6 +206,7 @@ class OverDrive(Source): xref_q = '+'.join(title_tokens) #log.error('Initial query is %s'%initial_q) #log.error('Cross reference query is %s'%xref_q) + q_xref = q+'SearchResults.svc/GetResults?iDisplayLength=50&sSearch='+xref_q query = '{"szKeyword":"'+initial_q+'"}' @@ -233,8 +234,10 @@ class OverDrive(Source): if xref_q.find('+') != -1: xref_tokens = xref_q.split('+') xref_q = xref_tokens[0] + #log.error('xref_q is '+xref_q) else: xref_q = '' + xref_q = '' q_xref = q+'SearchResults.svc/GetResults?iDisplayLength=50&sSearch='+xref_q elif int(m.group('totalrecords')) == 0: return '' @@ -259,9 +262,10 @@ class OverDrive(Source): return self.format_results(reserveid, od_title, subtitle, series, publisher, creators, thumbimage, worldcatlink, formatid) else: - creators = creators.split(', ') + if creators: + creators = creators.split(', ') # if an exact match in a preferred format occurs - if (author and creators[0] == author[0]) and od_title == title and int(formatid) in [1, 50, 410, 900] and thumbimage: + if ((author and creators[0] == author[0]) or (not author and not creators)) and od_title.lower() == title.lower() and int(formatid) in [1, 50, 410, 900] and thumbimage: return self.format_results(reserveid, od_title, subtitle, series, publisher, creators, thumbimage, worldcatlink, formatid) else: