mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Start migrating the isbndb plugin
This commit is contained in:
parent
547454c705
commit
d9cea95a71
@ -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
|
||||
|
@ -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()
|
||||
|
40
src/calibre/ebooks/metadata/sources/isbndb.py
Normal file
40
src/calibre/ebooks/metadata/sources/isbndb.py
Normal file
@ -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 <kovid@kovidgoyal.net>'
|
||||
__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']
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user