Book details panel: When displaying a link to amazon, use a country specific name like amazon.fr instead of using amazon.com for all countries

This commit is contained in:
Kovid Goyal 2012-07-19 22:43:24 +05:30
parent 029f5c68c5
commit 39a9c59bae
3 changed files with 13 additions and 2 deletions

View File

@ -573,8 +573,13 @@ class Amazon(Source):
else:
url = 'http://www.amazon.%s/dp/%s'%(domain, asin)
if url:
idtype = 'amazon' if self.domain == 'com' else 'amazon_'+self.domain
idtype = 'amazon' if domain == 'com' else 'amazon_'+domain
return (idtype, asin, url)
def get_book_url_name(self, idtype, idval, url):
if idtype == 'amazon':
return self.name
return 'A' + idtype.replace('_', '.')[1:]
# }}}
@property

View File

@ -443,6 +443,12 @@ class Source(Plugin):
'''
return None
def get_book_url_name(self, idtype, idval, url):
'''
Return a human readable name from the return value of get_book_url().
'''
return self.name
def get_cached_cover_url(self, identifiers):
'''
Return cached cover URL for the book identified by

View File

@ -517,7 +517,7 @@ def urls_from_identifiers(identifiers): # {{{
for plugin in all_metadata_plugins():
try:
id_type, id_val, url = plugin.get_book_url(identifiers)
ans.append((plugin.name, id_type, id_val, url))
ans.append((plugin.get_book_url_name(id_type, id_val, url), id_type, id_val, url))
except:
pass
isbn = identifiers.get('isbn', None)