mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Amazon metadata: Fix failure to get published date from audible book pages. Fixes #1849400 [traceback when searching amazon.com](https://bugs.launchpad.net/calibre/+bug/1849400)
This commit is contained in:
parent
c162c24b87
commit
a3dfc924e2
@ -254,6 +254,10 @@ class Worker(Thread): # Get details {{{
|
|||||||
starts-with(text(), "Uitgever:") or \
|
starts-with(text(), "Uitgever:") or \
|
||||||
starts-with(text(), "出版社:")]
|
starts-with(text(), "出版社:")]
|
||||||
'''
|
'''
|
||||||
|
self.pubdate_xpath = '''
|
||||||
|
descendant::*[starts-with(text(), "Publication Date:") or \
|
||||||
|
starts-with(text(), "Audible.com Release Date:")]
|
||||||
|
'''
|
||||||
self.publisher_names = {'Publisher', 'Uitgever', 'Verlag',
|
self.publisher_names = {'Publisher', 'Uitgever', 'Verlag',
|
||||||
'Editore', 'Editeur', 'Editor', 'Editora', '出版社'}
|
'Editore', 'Editeur', 'Editor', 'Editora', '出版社'}
|
||||||
|
|
||||||
@ -839,13 +843,24 @@ class Worker(Thread): # Get details {{{
|
|||||||
return ans.partition('(')[0].strip()
|
return ans.partition('(')[0].strip()
|
||||||
|
|
||||||
def parse_pubdate(self, pd):
|
def parse_pubdate(self, pd):
|
||||||
|
from calibre.utils.date import parse_only_date
|
||||||
|
for x in reversed(pd.xpath(self.pubdate_xpath)):
|
||||||
|
if x.tail:
|
||||||
|
date = x.tail.strip()
|
||||||
|
date = self.delocalize_datestr(date)
|
||||||
|
try:
|
||||||
|
return parse_only_date(date, assume_utc=True)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
for x in reversed(pd.xpath(self.publisher_xpath)):
|
for x in reversed(pd.xpath(self.publisher_xpath)):
|
||||||
if x.tail:
|
if x.tail:
|
||||||
from calibre.utils.date import parse_only_date
|
|
||||||
ans = x.tail
|
ans = x.tail
|
||||||
date = ans.rpartition('(')[-1].replace(')', '').strip()
|
date = ans.rpartition('(')[-1].replace(')', '').strip()
|
||||||
date = self.delocalize_datestr(date)
|
date = self.delocalize_datestr(date)
|
||||||
return parse_only_date(date, assume_utc=True)
|
try:
|
||||||
|
return parse_only_date(date, assume_utc=True)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
def parse_language(self, pd):
|
def parse_language(self, pd):
|
||||||
for x in reversed(pd.xpath(self.language_xpath)):
|
for x in reversed(pd.xpath(self.language_xpath)):
|
||||||
@ -863,7 +878,7 @@ class Worker(Thread): # Get details {{{
|
|||||||
class Amazon(Source):
|
class Amazon(Source):
|
||||||
|
|
||||||
name = 'Amazon.com'
|
name = 'Amazon.com'
|
||||||
version = (1, 2, 10)
|
version = (1, 2, 11)
|
||||||
minimum_calibre_version = (2, 82, 0)
|
minimum_calibre_version = (2, 82, 0)
|
||||||
description = _('Downloads metadata and covers from Amazon')
|
description = _('Downloads metadata and covers from Amazon')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user