mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Allow metadata plugins to return multiple urls for a book
This commit is contained in:
parent
e377e66c20
commit
1235bc5ab2
@ -489,6 +489,16 @@ class Source(Plugin):
|
|||||||
'''
|
'''
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def get_book_urls(self, identifiers):
|
||||||
|
'''
|
||||||
|
Override this method if you would like to return multiple urls for this book.
|
||||||
|
Return a list of 3-tuples. By default this method simply calls :method:`get_book_url`.
|
||||||
|
'''
|
||||||
|
data = self.get_book_url(identifiers)
|
||||||
|
if data is None:
|
||||||
|
return ()
|
||||||
|
return (data,)
|
||||||
|
|
||||||
def get_cached_cover_url(self, identifiers):
|
def get_cached_cover_url(self, identifiers):
|
||||||
'''
|
'''
|
||||||
Return cached cover URL for the book identified by
|
Return cached cover URL for the book identified by
|
||||||
|
@ -521,8 +521,8 @@ def urls_from_identifiers(identifiers): # {{{
|
|||||||
ans = []
|
ans = []
|
||||||
for plugin in all_metadata_plugins():
|
for plugin in all_metadata_plugins():
|
||||||
try:
|
try:
|
||||||
id_type, id_val, url = plugin.get_book_url(identifiers)
|
for id_type, id_val, url in plugin.get_book_urls(identifiers):
|
||||||
ans.append((plugin.get_book_url_name(id_type, id_val, url), id_type, id_val, url))
|
ans.append((plugin.get_book_url_name(id_type, id_val, url), id_type, id_val, url))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
isbn = identifiers.get('isbn', None)
|
isbn = identifiers.get('isbn', None)
|
||||||
@ -546,7 +546,6 @@ def urls_from_identifiers(identifiers): # {{{
|
|||||||
ans.append((issn, 'issn', issn,
|
ans.append((issn, 'issn', issn,
|
||||||
'http://www.worldcat.org/issn/'+issn))
|
'http://www.worldcat.org/issn/'+issn))
|
||||||
for k, url in identifiers.iteritems():
|
for k, url in identifiers.iteritems():
|
||||||
print (k, url)
|
|
||||||
if url and re.match(r'ur[il]\d*$', k) is not None and url.startswith('http'):
|
if url and re.match(r'ur[il]\d*$', k) is not None and url.startswith('http'):
|
||||||
url = url[:8].replace('|', ':') + url[8:].replace('|', ',')
|
url = url[:8].replace('|', ':') + url[8:].replace('|', ',')
|
||||||
parts = urlparse(url)
|
parts = urlparse(url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user