Fix #779994 (Metadata download API priority only partially considered)

This commit is contained in:
Kovid Goyal 2011-05-12 10:38:07 -06:00
parent 16c92f3d23
commit a204568f2e

View File

@ -372,6 +372,18 @@ def identify(log, abort, # {{{
longest, lp = -1, '' longest, lp = -1, ''
for plugin, presults in results.iteritems(): for plugin, presults in results.iteritems():
presults.sort(key=plugin.identify_results_keygen(**sort_kwargs)) presults.sort(key=plugin.identify_results_keygen(**sort_kwargs))
# Throw away lower priority results from the same source that have exactly the same
# title and authors as a higher priority result
filter_results = set()
filtered_results = []
for r in presults:
key = (r.title, tuple(r.authors))
if key not in filter_results:
filtered_results.append(r)
filter_results.add(key)
presults = filtered_results
plog = logs[plugin].getvalue().strip() plog = logs[plugin].getvalue().strip()
log('\n'+'*'*30, plugin.name, '*'*30) log('\n'+'*'*30, plugin.name, '*'*30)
log('Request extra headers:', plugin.browser.addheaders) log('Request extra headers:', plugin.browser.addheaders)
@ -479,7 +491,7 @@ if __name__ == '__main__': # tests {{{
( (
{'title':'Magykal Papers', {'title':'Magykal Papers',
'authors':['Sage']}, 'authors':['Sage']},
[title_test('The Magykal Papers', exact=True)], [title_test('Septimus Heap: The Magykal Papers', exact=True)],
), ),
@ -506,12 +518,6 @@ if __name__ == '__main__': # tests {{{
exact=True), authors_test(['Dan Brown'])] exact=True), authors_test(['Dan Brown'])]
), ),
( # No ISBN
{'title':'Justine', 'authors':['Durrel']},
[title_test('Justine', exact=True),
authors_test(['Lawrence Durrel'])]
),
( # A newer book ( # A newer book
{'identifiers':{'isbn': '9780316044981'}}, {'identifiers':{'isbn': '9780316044981'}},
[title_test('The Heroes', exact=True), [title_test('The Heroes', exact=True),