mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix a regression that broke downloading certain periodicals for the Kindle. Fixes #875595 (Calibre- Unable to download news - UnicodeEncodeError)
This commit is contained in:
parent
12fffc051e
commit
557f46fd47
@ -212,7 +212,11 @@ class Serializer(object):
|
||||
if tocref.klass == "periodical":
|
||||
buf.write('<div> <div height="1em"></div>')
|
||||
else:
|
||||
buf.write('<div></div> <div> <h2 height="1em"><font size="+2"><b>'+tocref.title+'</b></font></h2> <div height="1em"></div>')
|
||||
t = tocref.title
|
||||
if isinstance(t, unicode):
|
||||
t = t.encode('utf-8')
|
||||
buf.write('<div></div> <div> <h2 height="1em"><font size="+2"><b>'
|
||||
+t+'</b></font></h2> <div height="1em"></div>')
|
||||
|
||||
buf.write('<ul>')
|
||||
|
||||
@ -221,14 +225,17 @@ class Serializer(object):
|
||||
itemhref = tocitem.href
|
||||
if tocref.klass == 'periodical':
|
||||
# This is a section node.
|
||||
# For periodical toca, the section urls are like r'feed_\d+/index.html'
|
||||
# For periodical tocs, the section urls are like r'feed_\d+/index.html'
|
||||
# We dont want to point to the start of the first article
|
||||
# so we change the href.
|
||||
itemhref = re.sub(r'article_\d+/', '', itemhref)
|
||||
self.href_offsets[itemhref].append(buf.tell())
|
||||
buf.write('0000000000')
|
||||
buf.write(' ><font size="+1" color="blue"><b><u>')
|
||||
buf.write(tocitem.title)
|
||||
t = tocitem.title
|
||||
if isinstance(t, unicode):
|
||||
t = t.encode('utf-8')
|
||||
buf.write(t)
|
||||
buf.write('</u></b></font></a></li>')
|
||||
|
||||
buf.write('</ul><div height="1em"></div></div><mbp:pagebreak />')
|
||||
|
Loading…
x
Reference in New Issue
Block a user