From 4cc36cac1a0f0dfb09412715d168ea251505c182 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 20 May 2011 10:23:16 -0600 Subject: [PATCH] Filter audio books from amazon metadata download results --- src/calibre/ebooks/metadata/sources/amazon.py | 3 ++- src/calibre/ebooks/metadata/sources/base.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/metadata/sources/amazon.py b/src/calibre/ebooks/metadata/sources/amazon.py index b9c27b8fac..f291959475 100644 --- a/src/calibre/ebooks/metadata/sources/amazon.py +++ b/src/calibre/ebooks/metadata/sources/amazon.py @@ -549,7 +549,8 @@ class Amazon(Source): r'//div[@id="Results"]/descendant::td[starts-with(@id, "search:Td:")]'): for a in td.xpath(r'descendant::td[@class="dataColumn"]/descendant::a[@href]/span[@class="srTitle"]/..'): title = tostring(a, method='text', encoding=unicode).lower() - if 'bulk pack' not in title: + if ('bulk pack' not in title and '[audiobook]' not in + title and '[audio cd]' not in title): matches.append(a.get('href')) break diff --git a/src/calibre/ebooks/metadata/sources/base.py b/src/calibre/ebooks/metadata/sources/base.py index 889132a484..0c318727e0 100644 --- a/src/calibre/ebooks/metadata/sources/base.py +++ b/src/calibre/ebooks/metadata/sources/base.py @@ -313,7 +313,7 @@ class Source(Plugin): title_patterns = [(re.compile(pat, re.IGNORECASE), repl) for pat, repl in [ # Remove things like: (2010) (Omnibus) etc. - (r'(?i)[({\[](\d{4}|omnibus|anthology|hardcover|paperback|turtleback|mass\s*market|edition|ed\.)[\])}]', ''), + (r'(?i)[({\[](\d{4}|omnibus|anthology|hardcover|audiobook|audio\scd|paperback|turtleback|mass\s*market|edition|ed\.)[\])}]', ''), # Remove any strings that contain the substring edition inside # parentheses (r'(?i)[({\[].*?(edition|ed.).*?[\]})]', ''),