mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Store: Download, ensure download filename is ascii.
This commit is contained in:
parent
64729ef1ab
commit
7a75239843
@ -17,6 +17,7 @@ from calibre.constants import (iswindows, isosx, islinux, isfrozen,
|
|||||||
win32event, win32api, winerror, fcntl,
|
win32event, win32api, winerror, fcntl,
|
||||||
filesystem_encoding, plugins, config_dir)
|
filesystem_encoding, plugins, config_dir)
|
||||||
from calibre.startup import winutil, winutilerror
|
from calibre.startup import winutil, winutilerror
|
||||||
|
from calibre.utils.filenames import ascii_filename
|
||||||
|
|
||||||
if False and islinux and not getattr(sys, 'frozen', False):
|
if False and islinux and not getattr(sys, 'frozen', False):
|
||||||
# Imported before PyQt4 to workaround PyQt4 util-linux conflict discovered on gentoo
|
# Imported before PyQt4 to workaround PyQt4 util-linux conflict discovered on gentoo
|
||||||
@ -648,7 +649,10 @@ def get_download_filename(url, cookie_file=None):
|
|||||||
if not filename:
|
if not filename:
|
||||||
filename = last_part_name
|
filename = last_part_name
|
||||||
|
|
||||||
return filename
|
filename, ext = os.path.splitext(filename)
|
||||||
|
filename = filename[:60] + ext
|
||||||
|
|
||||||
|
return ascii_filename(filename)
|
||||||
|
|
||||||
def human_readable(size):
|
def human_readable(size):
|
||||||
""" Convert a size in bytes into a human readable form """
|
""" Convert a size in bytes into a human readable form """
|
||||||
|
@ -44,7 +44,7 @@ class EbookDownload(object):
|
|||||||
return dfilename
|
return dfilename
|
||||||
|
|
||||||
if not filename:
|
if not filename:
|
||||||
filename = get_download_filename(url, cookie_file)[:60]
|
filename = get_download_filename(url, cookie_file)
|
||||||
|
|
||||||
br = browser()
|
br = browser()
|
||||||
if cookie_file:
|
if cookie_file:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user