mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #855109 (mobileread-store: error with umlaut in filename)
This commit is contained in:
commit
42254a6f64
@ -16,6 +16,7 @@ from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.gui2 import Dispatcher
|
||||
from calibre.gui2.threaded_jobs import ThreadedJob
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
|
||||
class EbookDownload(object):
|
||||
|
||||
@ -45,6 +46,9 @@ class EbookDownload(object):
|
||||
|
||||
if not filename:
|
||||
filename = get_download_filename(url, cookie_file)
|
||||
filename, ext = os.path.splitext(filename)
|
||||
filename = filename[:60] + ext
|
||||
filename = ascii_filename(filename)
|
||||
|
||||
br = browser()
|
||||
if cookie_file:
|
||||
@ -84,7 +88,7 @@ class EbookDownload(object):
|
||||
gui_ebook_download = EbookDownload()
|
||||
|
||||
def start_ebook_download(callback, job_manager, gui, cookie_file=None, url='', filename='', save_loc='', add_to_lib=True, tags=[]):
|
||||
description = _('Downloading %s') % filename if filename else url
|
||||
description = _('Downloading %s') % filename.decode('utf-8', 'ignore') if filename else url.decode('utf-8', 'ignore')
|
||||
job = ThreadedJob('ebook_download', description, gui_ebook_download, (gui, cookie_file, url, filename, save_loc, add_to_lib, tags), {}, callback, max_concurrent_count=2, killable=False)
|
||||
job_manager.run_threaded_job(job)
|
||||
|
||||
@ -96,7 +100,7 @@ class EbookDownloadMixin(object):
|
||||
if isinstance(tags, basestring):
|
||||
tags = tags.split(',')
|
||||
start_ebook_download(Dispatcher(self.downloaded_ebook), self.job_manager, self, cookie_file, url, filename, save_loc, add_to_lib, tags)
|
||||
self.status_bar.show_message(_('Downloading') + ' ' + filename if filename else url, 3000)
|
||||
self.status_bar.show_message(_('Downloading') + ' ' + filename.decode('utf-8', 'ignore') if filename else url.decode('utf-8', 'ignore'), 3000)
|
||||
|
||||
def downloaded_ebook(self, job):
|
||||
if job.failed:
|
||||
|
@ -350,7 +350,7 @@ class SearchDialog(QDialog, Ui_Dialog):
|
||||
d = ChooseFormatDialog(self, _('Choose format to download to your library.'), result.downloads.keys())
|
||||
if d.exec_() == d.Accepted:
|
||||
ext = d.format()
|
||||
fname = result.title + '.' + ext.lower()
|
||||
fname = result.title[:60] + '.' + ext.lower()
|
||||
fname = ascii_filename(fname)
|
||||
self.gui.download_ebook(result.downloads[ext], filename=fname)
|
||||
|
||||
|
@ -44,9 +44,12 @@ class MobileReadStore(BasicStoreConfig, StorePlugin):
|
||||
|
||||
def search(self, query, max_results=10, timeout=60):
|
||||
books = self.get_book_list()
|
||||
|
||||
if not books:
|
||||
return
|
||||
|
||||
sf = SearchFilter(books)
|
||||
matches = sf.parse(query)
|
||||
matches = sf.parse(query.decode('utf-8', 'replace'))
|
||||
|
||||
for book in matches:
|
||||
book.price = '$0.00'
|
||||
|
@ -15,6 +15,7 @@ from PyQt4.QtWebKit import QWebView, QWebPage
|
||||
from calibre import USER_AGENT, get_proxies, get_download_filename
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
|
||||
class NPWebView(QWebView):
|
||||
|
||||
@ -67,6 +68,7 @@ class NPWebView(QWebView):
|
||||
|
||||
filename = get_download_filename(url, cf)
|
||||
ext = os.path.splitext(filename)[1][1:].lower()
|
||||
filename = ascii_filename(filename[:60] + '.' + ext)
|
||||
if ext not in BOOK_EXTENSIONS:
|
||||
if ext == 'acsm':
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
|
Loading…
x
Reference in New Issue
Block a user