mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix epub output for Time magazine. Fix epub output for ScienceDaily on windows
This commit is contained in:
parent
f7ff8dd854
commit
11201a5d7d
@ -379,6 +379,12 @@ def strftime(fmt, t=time.localtime()):
|
|||||||
return plugins['winutil'][0].strftime(fmt, t)
|
return plugins['winutil'][0].strftime(fmt, t)
|
||||||
return time.strftime(fmt, t).decode(preferred_encoding, 'replace')
|
return time.strftime(fmt, t).decode(preferred_encoding, 'replace')
|
||||||
|
|
||||||
|
def my_unichr(num):
|
||||||
|
try:
|
||||||
|
unichr(num)
|
||||||
|
except ValueError:
|
||||||
|
return u'?'
|
||||||
|
|
||||||
def entity_to_unicode(match, exceptions=[], encoding='cp1252'):
|
def entity_to_unicode(match, exceptions=[], encoding='cp1252'):
|
||||||
'''
|
'''
|
||||||
@param match: A match object such that '&'+match.group(1)';' is the entity.
|
@param match: A match object such that '&'+match.group(1)';' is the entity.
|
||||||
@ -394,7 +400,7 @@ def entity_to_unicode(match, exceptions=[], encoding='cp1252'):
|
|||||||
if ent.startswith(u'#x'):
|
if ent.startswith(u'#x'):
|
||||||
num = int(ent[2:], 16)
|
num = int(ent[2:], 16)
|
||||||
if encoding is None or num > 255:
|
if encoding is None or num > 255:
|
||||||
return unichr(num)
|
return my_unichr(num)
|
||||||
return chr(num).decode(encoding)
|
return chr(num).decode(encoding)
|
||||||
if ent.startswith(u'#'):
|
if ent.startswith(u'#'):
|
||||||
try:
|
try:
|
||||||
@ -402,13 +408,13 @@ def entity_to_unicode(match, exceptions=[], encoding='cp1252'):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
return '&'+ent+';'
|
return '&'+ent+';'
|
||||||
if encoding is None or num > 255:
|
if encoding is None or num > 255:
|
||||||
return unichr(num)
|
return my_unichr(num)
|
||||||
try:
|
try:
|
||||||
return chr(num).decode(encoding)
|
return chr(num).decode(encoding)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
return unichr(num)
|
return my_unichr(num)
|
||||||
try:
|
try:
|
||||||
return unichr(name2codepoint[ent])
|
return my_unichr(name2codepoint[ent])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return '&'+ent+';'
|
return '&'+ent+';'
|
||||||
|
|
||||||
|
@ -15,12 +15,13 @@ class Time(BasicNewsRecipe):
|
|||||||
description = 'Weekly magazine'
|
description = 'Weekly magazine'
|
||||||
oldest_article = 7
|
oldest_article = 7
|
||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 100
|
||||||
no_stylesheets = False
|
no_stylesheets = True
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
|
|
||||||
#cover_url = 'http://img.timeinc.net/time/rd/trunk/www/web/feds/i/logo_time_home.gif'
|
#cover_url = 'http://img.timeinc.net/time/rd/trunk/www/web/feds/i/logo_time_home.gif'
|
||||||
|
|
||||||
keep_only_tags = [dict(name='div', attrs={'class':'tout1'})]
|
keep_only_tags = [dict(name='div', attrs={'class':'tout1'})]
|
||||||
|
remove_tags = [dict(name='ul', attrs={'class':['button', 'find']})]
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
(u'Top Stories', u'http://feedproxy.google.com/time/topstories')
|
(u'Top Stories', u'http://feedproxy.google.com/time/topstories')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user