diff --git a/src/calibre/ebooks/metadata/sources/base.py b/src/calibre/ebooks/metadata/sources/base.py index 86468141e1..30b804a76e 100644 --- a/src/calibre/ebooks/metadata/sources/base.py +++ b/src/calibre/ebooks/metadata/sources/base.py @@ -17,7 +17,7 @@ from calibre.utils.config import JSONConfig from calibre.utils.titlecase import titlecase from calibre.ebooks.metadata import check_isbn -msprefs = JSONConfig('metadata_sources.json') +msprefs = JSONConfig('metadata_sources/global.json') msprefs.defaults['txt_comments'] = False msprefs.defaults['ignore_fields'] = [] msprefs.defaults['max_tags'] = 20 diff --git a/src/calibre/ebooks/metadata/sources/identify.py b/src/calibre/ebooks/metadata/sources/identify.py index 17adc6ffc6..b04a697ed8 100644 --- a/src/calibre/ebooks/metadata/sources/identify.py +++ b/src/calibre/ebooks/metadata/sources/identify.py @@ -272,6 +272,7 @@ def identify(log, abort, title=None, authors=None, identifiers={}, timeout=30): if k not in ('title', 'authors', 'identifiers'): sort_kwargs.pop(k) + longest, lp = -1, '' for plugin, presults in results.iteritems(): presults.sort(key=plugin.identify_results_keygen(**sort_kwargs)) plog = logs[plugin].getvalue().strip() @@ -281,8 +282,11 @@ def identify(log, abort, title=None, authors=None, identifiers={}, timeout=30): time_spent = getattr(plugin, 'dl_time_spent', None) if time_spent is None: log('Downloading was aborted') + longest, lp = -1, plugin.name else: log('Downloading from', plugin.name, 'took', time_spent) + if time_spent > longest: + longest, lp = time_spent, plugin.name for r in presults: log('\n\n---') log(unicode(r)) @@ -297,6 +301,7 @@ def identify(log, abort, title=None, authors=None, identifiers={}, timeout=30): result.identify_plugin = plugin log('The identify phase took %.2f seconds'%(time.time() - start_time)) + log('The longest time (%f) was taken by:'%longest, lp) log('Merging results from different sources and finding earliest', 'publication dates') start_time = time.time() diff --git a/src/calibre/ebooks/metadata/sources/isbndb.py b/src/calibre/ebooks/metadata/sources/isbndb.py new file mode 100644 index 0000000000..3cd9d96c81 --- /dev/null +++ b/src/calibre/ebooks/metadata/sources/isbndb.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai +from __future__ import (unicode_literals, division, absolute_import, + print_function) + +__license__ = 'GPL v3' +__copyright__ = '2011, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + +from calibre.ebooks.metadata.sources.base import Source + +class ISBNDB(Source): + + name = 'ISBNDB' + description = _('Downloads metadata from isbndb.com') + + capabilities = frozenset(['identify']) + touched_fields = frozenset(['title', 'authors', + 'identifier:isbn', 'comments', 'publisher']) + supports_gzip_transfer_encoding = True + + def __init__(self, *args, **kwargs): + Source.__init__(self, *args, **kwargs) + + prefs = self.prefs + prefs.defaults['key_migrated'] = False + prefs.defaults['isbndb_key'] = None + + if not prefs['key_migrated']: + prefs['key_migrated'] = True + try: + from calibre.customize.ui import config + key = config['plugin_customization']['IsbnDB'] + prefs['isbndb_key'] = key + except: + pass + + self.isbndb_key = prefs['isbndb_key'] + +