Update Ozon.ru metadata plugin for website changes. Fixes #1715347 [Crash getting metadata from Ozon.ru](https://bugs.launchpad.net/calibre/+bug/1715347)

This commit is contained in:
Kovid Goyal 2017-09-06 15:54:39 +05:30
parent fcd533a21c
commit 788d2d6611
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -23,7 +23,7 @@ from calibre.ebooks.metadata.book.base import Metadata
class Ozon(Source): class Ozon(Source):
name = 'OZON.ru' name = 'OZON.ru'
minimum_calibre_version = (2, 80, 0) minimum_calibre_version = (2, 80, 0)
version = (1, 0, 0) version = (1, 1, 0)
description = _('Downloads metadata and covers from OZON.ru (updated)') description = _('Downloads metadata and covers from OZON.ru (updated)')
capabilities = frozenset(['identify', 'cover']) capabilities = frozenset(['identify', 'cover'])
@ -152,6 +152,10 @@ class Ozon(Source):
json_pat = re.compile(u'dataLayer\s*=\s*(.+)?;') json_pat = re.compile(u'dataLayer\s*=\s*(.+)?;')
json_info = re.search(json_pat, entry_string) json_info = re.search(json_pat, entry_string)
jsondata = json_info.group(1) if json_info else None jsondata = json_info.group(1) if json_info else None
if jsondata:
idx = jsondata.rfind('}]')
if idx > 0:
jsondata = jsondata[:idx + 2]
# log.debug(u'jsondata: %s' % jsondata) # log.debug(u'jsondata: %s' % jsondata)
dataLayer = json.loads(jsondata) if jsondata else None dataLayer = json.loads(jsondata) if jsondata else None