mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Updated HackerNews
This commit is contained in:
parent
cfc5618ff8
commit
959306e466
@ -9,9 +9,9 @@ from calibre.ptempfile import PersistentTemporaryFile
|
|||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
import re
|
import re
|
||||||
|
|
||||||
class HackerNews(BasicNewsRecipe):
|
class HNWithCommentsLink(BasicNewsRecipe):
|
||||||
title = 'Hacker News'
|
title = 'HN With Comments Link'
|
||||||
__author__ = 'Tom Scholl'
|
__author__ = 'Tom Scholl & David Kerschner'
|
||||||
description = u'Hacker News, run by Y Combinator. Anything that good hackers would find interesting, with a focus on programming and startups.'
|
description = u'Hacker News, run by Y Combinator. Anything that good hackers would find interesting, with a focus on programming and startups.'
|
||||||
publisher = 'Y Combinator'
|
publisher = 'Y Combinator'
|
||||||
category = 'news, programming, it, technology'
|
category = 'news, programming, it, technology'
|
||||||
@ -80,6 +80,11 @@ class HackerNews(BasicNewsRecipe):
|
|||||||
body = body + comments
|
body = body + comments
|
||||||
return u'<html><title>' + title + u'</title><body>' + body + '</body></html>'
|
return u'<html><title>' + title + u'</title><body>' + body + '</body></html>'
|
||||||
|
|
||||||
|
def parse_feeds(self):
|
||||||
|
a = super(HNWithCommentsLink, self).parse_feeds()
|
||||||
|
self.hn_articles = a[0].articles
|
||||||
|
return a
|
||||||
|
|
||||||
def get_obfuscated_article(self, url):
|
def get_obfuscated_article(self, url):
|
||||||
if url.startswith('http://news.ycombinator.com'):
|
if url.startswith('http://news.ycombinator.com'):
|
||||||
content = self.get_hn_content(url)
|
content = self.get_hn_content(url)
|
||||||
@ -97,6 +102,13 @@ class HackerNews(BasicNewsRecipe):
|
|||||||
else:
|
else:
|
||||||
content = self.get_readable_content(url)
|
content = self.get_readable_content(url)
|
||||||
|
|
||||||
|
article = 0
|
||||||
|
for a in self.hn_articles:
|
||||||
|
if a.url == url:
|
||||||
|
article = a
|
||||||
|
|
||||||
|
content = re.sub(r'</body>\s*</html>\s*$', '', content) + article.summary + '</body></html>'
|
||||||
|
|
||||||
self.temp_files.append(PersistentTemporaryFile('_fa.html'))
|
self.temp_files.append(PersistentTemporaryFile('_fa.html'))
|
||||||
self.temp_files[-1].write(content)
|
self.temp_files[-1].write(content)
|
||||||
self.temp_files[-1].close()
|
self.temp_files[-1].close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user