mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
On second thoughts enable the ISBNDB plugin by default
This commit is contained in:
parent
cf675d79d8
commit
ec583f232d
@ -625,8 +625,9 @@ if test_eight_code:
|
|||||||
from calibre.ebooks.metadata.sources.google import GoogleBooks
|
from calibre.ebooks.metadata.sources.google import GoogleBooks
|
||||||
from calibre.ebooks.metadata.sources.amazon import Amazon
|
from calibre.ebooks.metadata.sources.amazon import Amazon
|
||||||
from calibre.ebooks.metadata.sources.openlibrary import OpenLibrary
|
from calibre.ebooks.metadata.sources.openlibrary import OpenLibrary
|
||||||
|
from calibre.ebooks.metadata.sources.isbndb import ISBNDB
|
||||||
|
|
||||||
plugins += [GoogleBooks, Amazon, OpenLibrary]
|
plugins += [GoogleBooks, Amazon, OpenLibrary, ISBNDB]
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
else:
|
else:
|
||||||
|
@ -123,22 +123,21 @@ class ISBNDB(Source):
|
|||||||
return etree.tostring(x, method='text', encoding=unicode).strip()
|
return etree.tostring(x, method='text', encoding=unicode).strip()
|
||||||
|
|
||||||
orig_isbn = identifiers.get('isbn', None)
|
orig_isbn = identifiers.get('isbn', None)
|
||||||
title_tokens = self.get_title_tokens(orig_title)
|
title_tokens = list(self.get_title_tokens(orig_title))
|
||||||
author_tokens = self.get_author_tokens(orig_authors)
|
author_tokens = list(self.get_author_tokens(orig_authors))
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
def ismatch(title, authors):
|
def ismatch(title, authors):
|
||||||
authors = lower(' '.join(authors))
|
authors = lower(' '.join(authors))
|
||||||
title = lower(title)
|
title = lower(title)
|
||||||
match = False
|
match = not title_tokens
|
||||||
for t in title_tokens:
|
for t in title_tokens:
|
||||||
if lower(t) in title:
|
if lower(t) in title:
|
||||||
match = True
|
match = True
|
||||||
break
|
break
|
||||||
if not title_tokens: match = True
|
amatch = not author_tokens
|
||||||
amatch = False
|
|
||||||
for a in author_tokens:
|
for a in author_tokens:
|
||||||
if a in authors:
|
if lower(a) in authors:
|
||||||
amatch = True
|
amatch = True
|
||||||
break
|
break
|
||||||
if not author_tokens: amatch = True
|
if not author_tokens: amatch = True
|
||||||
@ -182,6 +181,8 @@ class ISBNDB(Source):
|
|||||||
continue
|
continue
|
||||||
publisher = tostring(bd.find('PublisherText'))
|
publisher = tostring(bd.find('PublisherText'))
|
||||||
if not publisher: publisher = None
|
if not publisher: publisher = None
|
||||||
|
if publisher and 'audio' in publisher.lower():
|
||||||
|
continue
|
||||||
mi = Metadata(title, authors)
|
mi = Metadata(title, authors)
|
||||||
mi.isbn = isbn
|
mi.isbn = isbn
|
||||||
mi.publisher = publisher
|
mi.publisher = publisher
|
||||||
@ -208,16 +209,32 @@ class ISBNDB(Source):
|
|||||||
total, found, results = self.parse_feed(
|
total, found, results = self.parse_feed(
|
||||||
feed, seen, title, authors, identifiers)
|
feed, seen, title, authors, identifiers)
|
||||||
total_found += found
|
total_found += found
|
||||||
if results or total_found >= total:
|
candidates += results
|
||||||
candidates += results
|
if total_found >= total or len(candidates) > 9:
|
||||||
break
|
break
|
||||||
|
|
||||||
return candidates
|
return candidates
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from threading import Event
|
# To run these test use:
|
||||||
s = ISBNDB(None)
|
# calibre-debug -e src/calibre/ebooks/metadata/sources/isbndb.py
|
||||||
t, a = 'great gatsby', ['fitzgerald']
|
from calibre.ebooks.metadata.sources.test import (test_identify_plugin,
|
||||||
q = s.create_query(title=t, authors=a)
|
title_test, authors_test)
|
||||||
s.make_query(q, Event(), title=t, authors=a)
|
test_identify_plugin(ISBNDB.name,
|
||||||
|
[
|
||||||
|
|
||||||
|
|
||||||
|
(
|
||||||
|
{'title':'Great Gatsby',
|
||||||
|
'authors':['Fitzgerald']},
|
||||||
|
[title_test('The great gatsby', exact=True),
|
||||||
|
authors_test(['F. Scott Fitzgerald'])]
|
||||||
|
),
|
||||||
|
|
||||||
|
(
|
||||||
|
{'title': 'Flatland', 'authors':['Abbott']},
|
||||||
|
[title_test('Flatland', exact=False)]
|
||||||
|
),
|
||||||
|
])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user