mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
News download: Fix bug that could break some downloads in non ASCII locales
This commit is contained in:
parent
80c976e0f2
commit
de6aadee76
@ -24,18 +24,18 @@ class XkcdCom(BasicNewsRecipe):
|
|||||||
(re.compile(r'(<img.*title=")([^"]+)(".*>)'),
|
(re.compile(r'(<img.*title=")([^"]+)(".*>)'),
|
||||||
lambda m: '%s%s<p>%s</p>' % (m.group(1), m.group(3), m.group(2)))
|
lambda m: '%s%s<p>%s</p>' % (m.group(1), m.group(3), m.group(2)))
|
||||||
]
|
]
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
INDEX = 'http://xkcd.com/archive/'
|
INDEX = 'http://xkcd.com/archive/'
|
||||||
|
|
||||||
soup = self.index_to_soup(INDEX)
|
soup = self.index_to_soup(INDEX)
|
||||||
articles = []
|
articles = []
|
||||||
for item in soup.findAll('a', title=True):
|
for item in soup.findAll('a', title=True):
|
||||||
articles.append({
|
articles.append({
|
||||||
'date': item['title'],
|
'date': item['title'],
|
||||||
'timestamp': time.mktime(time.strptime(item['title'], '%Y-%m-%d'))+1,
|
'timestamp': time.mktime(time.strptime(item['title'], '%Y-%m-%d'))+1,
|
||||||
'url': 'http://xkcd.com' + item['href'],
|
'url': 'http://xkcd.com' + item['href'],
|
||||||
'title': self.tag_to_string(item).encode('UTF-8'),
|
'title': self.tag_to_string(item),
|
||||||
'description': '',
|
'description': '',
|
||||||
'content': '',
|
'content': '',
|
||||||
})
|
})
|
||||||
|
@ -165,7 +165,9 @@ class Feed(object):
|
|||||||
if delta.days*24*3600 + delta.seconds <= 24*3600*self.oldest_article:
|
if delta.days*24*3600 + delta.seconds <= 24*3600*self.oldest_article:
|
||||||
self.articles.append(article)
|
self.articles.append(article)
|
||||||
else:
|
else:
|
||||||
self.logger.debug('Skipping article %s (%s) from feed %s as it is too old.'%(title, article.localtime.strftime('%a, %d %b, %Y %H:%M'), self.title))
|
t = strftime(u'%a, %d %b, %Y %H:%M', article.localtime.timetuple())
|
||||||
|
self.logger.debug('Skipping article %s (%s) from feed %s as it is too old.'%
|
||||||
|
(title, t, self.title))
|
||||||
d = item.get('date', '')
|
d = item.get('date', '')
|
||||||
article.formatted_date = d
|
article.formatted_date = d
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user