From 58e933f39465bc05efdae12f6f7d4fbadfb2ce67 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 7 Mar 2013 15:06:43 +0530 Subject: [PATCH] Amazon metadata download: Update plugin to handle changes to Amazon site that could cause some covers to not be downloaded. Also fix finding metadata for books with + in their titles. --- src/calibre/ebooks/metadata/sources/amazon.py | 9 ++++++++- src/calibre/ebooks/metadata/sources/base.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/metadata/sources/amazon.py b/src/calibre/ebooks/metadata/sources/amazon.py index 7df57a5586..9024a7f49f 100644 --- a/src/calibre/ebooks/metadata/sources/amazon.py +++ b/src/calibre/ebooks/metadata/sources/amazon.py @@ -452,7 +452,7 @@ class Worker(Thread): # Get details {{{ def parse_cover(self, root): - imgs = root.xpath('//img[(@id="prodImage" or @id="original-main-image") and @src]') + imgs = root.xpath('//img[(@id="prodImage" or @id="original-main-image" or @id="main-image") and @src]') if imgs: src = imgs[0].get('src') if '/no-image-avail' not in src: @@ -895,6 +895,13 @@ if __name__ == '__main__': # tests {{{ isbn_test, title_test, authors_test, comments_test, series_test) com_tests = [ # {{{ + ( # + in title and uses id="main-image" for cover + {'title':'C++ Concurrency in Action'}, + [title_test('C++ Concurrency in Action: Practical Multithreading', + exact=True), + ] + ), + ( # Series {'identifiers':{'amazon':'0756407117'}}, [title_test( diff --git a/src/calibre/ebooks/metadata/sources/base.py b/src/calibre/ebooks/metadata/sources/base.py index 6ae4e540c5..e15d11c3c1 100644 --- a/src/calibre/ebooks/metadata/sources/base.py +++ b/src/calibre/ebooks/metadata/sources/base.py @@ -373,7 +373,7 @@ class Source(Plugin): # Remove single quotes not followed by 's' (r"'(?!s)", ''), # Replace other special chars with a space - (r'''[:,;+!@$%^&*(){}.`~"\s\[\]/]''', ' '), + (r'''[:,;!@$%^&*(){}.`~"\s\[\]/]''', ' '), ]] for pat, repl in title_patterns: