From 6dc8803ac569d739f1b53a76faaf6a510c80eb3f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 May 2011 09:21:31 -0600 Subject: [PATCH] Add uri->url identifiers mapping --- src/calibre/ebooks/metadata/sources/identify.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/calibre/ebooks/metadata/sources/identify.py b/src/calibre/ebooks/metadata/sources/identify.py index 3d4807ac02..1bd071d6f9 100644 --- a/src/calibre/ebooks/metadata/sources/identify.py +++ b/src/calibre/ebooks/metadata/sources/identify.py @@ -13,6 +13,7 @@ from Queue import Queue, Empty from threading import Thread from io import BytesIO from operator import attrgetter +from urlparse import urlparse from calibre.customize.ui import metadata_plugins, all_metadata_plugins from calibre.ebooks.metadata.sources.base import create_log, msprefs @@ -458,6 +459,14 @@ def urls_from_identifiers(identifiers): # {{{ if oclc: ans.append(('OCLC', 'oclc', oclc, 'http://www.worldcat.org/oclc/'+oclc)) + url = identifiers.get('uri', None) + if url is None: + url = identifiers.get('url', None) + if url and url.startswith('http'): + url = url[:8].replace('|', ':') + url[8:].replace('|', ',') + parts = urlparse(url) + name = parts.netloc + ans.append((name, 'url', url, url)) return ans # }}}