py2 compat in amazon metadata plugin for ancient calibre

This commit is contained in:
Kovid Goyal 2022-04-26 08:33:46 +05:30
parent d766adc463
commit bc91a6bed6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -4,6 +4,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals
import re
import string
import socket
import time
from functools import partial
@ -511,7 +512,10 @@ class Worker(Thread): # Get details {{{
def totext(self, elem, only_printable=False):
res = self.tostring(elem, encoding='unicode', method='text')
if only_printable:
filtered_characters = list(s for s in res if s.isprintable())
try:
filtered_characters = list(s for s in res if s.isprintable())
except AttributeError:
filtered_characters = list(s for s in res if s in string.printable)
res = ''.join(filtered_characters).strip()
return res
@ -971,7 +975,7 @@ class Worker(Thread): # Get details {{{
class Amazon(Source):
name = 'Amazon.com'
version = (1, 2, 25)
version = (1, 2, 26)
minimum_calibre_version = (2, 82, 0)
description = _('Downloads metadata and covers from Amazon')