py3 compat: Fix #1869266 [eBook download fails with python error](https://bugs.launchpad.net/calibre/+bug/1869266)

This commit is contained in:
Kovid Goyal 2020-03-27 08:57:36 +05:30
parent 3a576238fc
commit d8b91804c2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 4 deletions

View File

@ -500,7 +500,7 @@ class CopyToLibraryAction(InterfaceAction):
'records in the target library. Click "Show ' 'records in the target library. Click "Show '
'details" to see which ones. This behavior is ' 'details" to see which ones. This behavior is '
'controlled by the Auto-merge option in ' 'controlled by the Auto-merge option in '
'Preferences->Import/export->Adding books.'), det_msg=books, 'Preferences->Import/export->Adding books->Adding actions.'), det_msg=books,
show=True) show=True)
done_ids = frozenset(self.worker.processed) - frozenset(self.worker.duplicate_ids) done_ids = frozenset(self.worker.processed) - frozenset(self.worker.duplicate_ids)
if delete_after and done_ids: if delete_after and done_ids:

View File

@ -19,7 +19,7 @@ from calibre.gui2.threaded_jobs import ThreadedJob
from calibre.ptempfile import PersistentTemporaryDirectory from calibre.ptempfile import PersistentTemporaryDirectory
from calibre.utils.filenames import ascii_filename from calibre.utils.filenames import ascii_filename
from calibre.web import get_download_filename_from_response from calibre.web import get_download_filename_from_response
from polyglot.builtins import string_or_bytes from polyglot.builtins import string_or_bytes, as_unicode
class DownloadInfo(MessageBox): class DownloadInfo(MessageBox):
@ -128,7 +128,7 @@ gui_ebook_download = EbookDownload()
def start_ebook_download(callback, job_manager, gui, cookie_file=None, url='', filename='', save_loc='', add_to_lib=True, tags=[], create_browser=None): def start_ebook_download(callback, job_manager, gui, cookie_file=None, url='', filename='', save_loc='', add_to_lib=True, tags=[], create_browser=None):
description = _('Downloading %s') % filename.decode('utf-8', 'ignore') if filename else url.decode('utf-8', 'ignore') description = _('Downloading %s') % as_unicode(filename or url, errors='replace')
job = ThreadedJob('ebook_download', description, gui_ebook_download, ( job = ThreadedJob('ebook_download', description, gui_ebook_download, (
gui, cookie_file, url, filename, save_loc, add_to_lib, tags, create_browser), {}, gui, cookie_file, url, filename, save_loc, add_to_lib, tags, create_browser), {},
callback, max_concurrent_count=2, killable=False) callback, max_concurrent_count=2, killable=False)
@ -145,7 +145,7 @@ class EbookDownloadMixin(object):
if isinstance(tags, string_or_bytes): if isinstance(tags, string_or_bytes):
tags = tags.split(',') tags = tags.split(',')
start_ebook_download(Dispatcher(self.downloaded_ebook), self.job_manager, self, cookie_file, url, filename, save_loc, add_to_lib, tags, create_browser) start_ebook_download(Dispatcher(self.downloaded_ebook), self.job_manager, self, cookie_file, url, filename, save_loc, add_to_lib, tags, create_browser)
self.status_bar.show_message(_('Downloading') + ' ' + filename.decode('utf-8', 'ignore') if filename else url.decode('utf-8', 'ignore'), 3000) self.status_bar.show_message(_('Downloading') + ' ' + as_unicode(filename or url, errors='replace'), 3000)
def downloaded_ebook(self, job): def downloaded_ebook(self, job):
if job.failed: if job.failed: