mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update content.py
remove the '!' character from file name when try to download a kepub file from kobo browser since kepub file with a '!' in name doesn't work on a kobo device(at least on my kobo forma)
This commit is contained in:
parent
1578573a7b
commit
d1b303fad3
@ -160,8 +160,6 @@ def book_filename(rd, book_id, mi, fmt, as_encoded_unicode=False):
|
|||||||
au = authors_to_string(mi.authors or [_('Unknown')])
|
au = authors_to_string(mi.authors or [_('Unknown')])
|
||||||
title = mi.title or _('Unknown')
|
title = mi.title or _('Unknown')
|
||||||
ext = (fmt or '').lower()
|
ext = (fmt or '').lower()
|
||||||
if ext == 'kepub' and 'Kobo Touch' in rd.inheaders.get('User-Agent', ''):
|
|
||||||
ext = 'kepub.epub'
|
|
||||||
fname = '%s - %s_%s.%s' % (title[:30], au[:30], book_id, ext)
|
fname = '%s - %s_%s.%s' % (title[:30], au[:30], book_id, ext)
|
||||||
if as_encoded_unicode:
|
if as_encoded_unicode:
|
||||||
# See https://tools.ietf.org/html/rfc6266
|
# See https://tools.ietf.org/html/rfc6266
|
||||||
@ -169,6 +167,9 @@ def book_filename(rd, book_id, mi, fmt, as_encoded_unicode=False):
|
|||||||
fname = unicode_type(quote(fname))
|
fname = unicode_type(quote(fname))
|
||||||
else:
|
else:
|
||||||
fname = ascii_filename(fname).replace('"', '_')
|
fname = ascii_filename(fname).replace('"', '_')
|
||||||
|
if ext == 'kepub' and 'Kobo Touch' in rd.inheaders.get('User-Agent', ''):
|
||||||
|
fname = fname.replace('!', '')
|
||||||
|
fname += '.epub'
|
||||||
return fname
|
return fname
|
||||||
|
|
||||||
|
|
||||||
@ -228,7 +229,7 @@ def static(ctx, rd, what):
|
|||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
raise HTTPNotFound()
|
raise HTTPNotFound()
|
||||||
|
|
||||||
|
kepub
|
||||||
@endpoint('/favicon.png', auth_required=False, cache_control=24)
|
@endpoint('/favicon.png', auth_required=False, cache_control=24)
|
||||||
def favicon(ctx, rd):
|
def favicon(ctx, rd):
|
||||||
return share_open(I('lt.png'), 'rb')
|
return share_open(I('lt.png'), 'rb')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user