mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
When sending by email to kindle dont include the author in the filename as amazon is currently reading the author from the file metadata but not the title. Fixes #1994136 [Send to Kindle gets wrong title](https://bugs.launchpad.net/calibre/+bug/1994136)
Roll eyes.
This commit is contained in:
parent
c143ece70c
commit
b2eb525a42
@ -147,12 +147,16 @@ class Sendmail:
|
|||||||
gui_sendmail = Sendmail()
|
gui_sendmail = Sendmail()
|
||||||
|
|
||||||
|
|
||||||
|
def is_for_kindle(to):
|
||||||
|
return isinstance(to, str) and ('@kindle.com' in to or '@kindle.cn' in to)
|
||||||
|
|
||||||
|
|
||||||
def send_mails(jobnames, callback, attachments, to_s, subjects,
|
def send_mails(jobnames, callback, attachments, to_s, subjects,
|
||||||
texts, attachment_names, job_manager):
|
texts, attachment_names, job_manager):
|
||||||
for name, attachment, to, subject, text, aname in zip(jobnames,
|
for name, attachment, to, subject, text, aname in zip(jobnames,
|
||||||
attachments, to_s, subjects, texts, attachment_names):
|
attachments, to_s, subjects, texts, attachment_names):
|
||||||
description = _('Email %(name)s to %(to)s') % dict(name=name, to=to)
|
description = _('Email %(name)s to %(to)s') % dict(name=name, to=to)
|
||||||
if isinstance(to, str) and ('@kindle.com' in to or '@kindle.cn' in to or '@pbsync.com' in to):
|
if isinstance(to, str) and (is_for_kindle(to) or '@pbsync.com' in to):
|
||||||
# The PocketBook service is a total joke. It cant handle
|
# The PocketBook service is a total joke. It cant handle
|
||||||
# non-ascii, filenames that are long enough to be split up, commas, and
|
# non-ascii, filenames that are long enough to be split up, commas, and
|
||||||
# the good lord alone knows what else. So use a random filename
|
# the good lord alone knows what else. So use a random filename
|
||||||
@ -165,7 +169,7 @@ def send_mails(jobnames, callback, attachments, to_s, subjects,
|
|||||||
# irony that they are called "tech" companies.
|
# irony that they are called "tech" companies.
|
||||||
# https://bugs.launchpad.net/calibre/+bug/1989282
|
# https://bugs.launchpad.net/calibre/+bug/1989282
|
||||||
from calibre.utils.short_uuid import uuid4
|
from calibre.utils.short_uuid import uuid4
|
||||||
if '@kindle.com' in to or '@kindle.cn' in to:
|
if is_for_kindle(to):
|
||||||
# https://www.mobileread.com/forums/showthread.php?t=349290
|
# https://www.mobileread.com/forums/showthread.php?t=349290
|
||||||
from calibre.utils.filenames import ascii_filename
|
from calibre.utils.filenames import ascii_filename
|
||||||
aname = ascii_filename(aname)
|
aname = ascii_filename(aname)
|
||||||
@ -440,7 +444,10 @@ class EmailMixin: # {{{
|
|||||||
if mi.comments and gprefs['add_comments_to_email']:
|
if mi.comments and gprefs['add_comments_to_email']:
|
||||||
from calibre.utils.html2text import html2text
|
from calibre.utils.html2text import html2text
|
||||||
texts[-1] += '\n\n' + _('About this book:') + '\n\n' + textwrap.fill(html2text(mi.comments))
|
texts[-1] += '\n\n' + _('About this book:') + '\n\n' + textwrap.fill(html2text(mi.comments))
|
||||||
prefix = f'{t} - {a}'
|
if is_for_kindle(to):
|
||||||
|
prefix = str(t)
|
||||||
|
else:
|
||||||
|
prefix = f'{t} - {a}'
|
||||||
if not isinstance(prefix, str):
|
if not isinstance(prefix, str):
|
||||||
prefix = prefix.decode(preferred_encoding, 'replace')
|
prefix = prefix.decode(preferred_encoding, 'replace')
|
||||||
attachment_names.append(prefix + os.path.splitext(f)[1])
|
attachment_names.append(prefix + os.path.splitext(f)[1])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user