Fix epub output for Time magazine. Fix epub output for ScienceDaily on windows

This commit is contained in:
Kovid Goyal 2008-12-29 21:21:39 -08:00
parent f7ff8dd854
commit 11201a5d7d
2 changed files with 13 additions and 6 deletions

View File

@ -379,6 +379,12 @@ def strftime(fmt, t=time.localtime()):
return plugins['winutil'][0].strftime(fmt, t)
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'):
'''
@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'):
num = int(ent[2:], 16)
if encoding is None or num > 255:
return unichr(num)
return my_unichr(num)
return chr(num).decode(encoding)
if ent.startswith(u'#'):
try:
@ -402,13 +408,13 @@ def entity_to_unicode(match, exceptions=[], encoding='cp1252'):
except ValueError:
return '&'+ent+';'
if encoding is None or num > 255:
return unichr(num)
return my_unichr(num)
try:
return chr(num).decode(encoding)
except UnicodeDecodeError:
return unichr(num)
return my_unichr(num)
try:
return unichr(name2codepoint[ent])
return my_unichr(name2codepoint[ent])
except KeyError:
return '&'+ent+';'

View File

@ -15,12 +15,13 @@ class Time(BasicNewsRecipe):
description = 'Weekly magazine'
oldest_article = 7
max_articles_per_feed = 100
no_stylesheets = False
no_stylesheets = True
use_embedded_content = False
#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'})]
remove_tags = [dict(name='ul', attrs={'class':['button', 'find']})]
feeds = [
(u'Top Stories', u'http://feedproxy.google.com/time/topstories')