mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3 compat for hacker news recipe
This commit is contained in:
parent
65293190f0
commit
38cc111d46
@ -19,8 +19,6 @@ class HNWithCommentsLink(BasicNewsRecipe):
|
|||||||
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'
|
||||||
masthead_url = 'http://img585.imageshack.us/img585/5011/hnle.png'
|
|
||||||
cover_url = 'http://img585.imageshack.us/img585/5011/hnle.png'
|
|
||||||
delay = 1
|
delay = 1
|
||||||
max_articles_per_feed = 30
|
max_articles_per_feed = 30
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
@ -30,7 +28,7 @@ class HNWithCommentsLink(BasicNewsRecipe):
|
|||||||
requires_version = (0, 8, 16)
|
requires_version = (0, 8, 16)
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
(u'Hacker News', 'http://news.ycombinator.com/rss')
|
(u'Hacker News', 'https://news.ycombinator.com/rss')
|
||||||
]
|
]
|
||||||
|
|
||||||
temp_files = []
|
temp_files = []
|
||||||
@ -53,7 +51,7 @@ class HNWithCommentsLink(BasicNewsRecipe):
|
|||||||
title = self.tag_to_string(main.find('td', 'title'))
|
title = self.tag_to_string(main.find('td', 'title'))
|
||||||
link = main.find('td', 'title').find('a')['href']
|
link = main.find('td', 'title').find('a')['href']
|
||||||
if link.startswith('item?'):
|
if link.startswith('item?'):
|
||||||
link = 'http://news.ycombinator.com/' + link
|
link = 'https://news.ycombinator.com/' + link
|
||||||
readable_link = link.rpartition('http://')[2].rpartition('https://')[2]
|
readable_link = link.rpartition('http://')[2].rpartition('https://')[2]
|
||||||
subtext = self.tag_to_string(main.find('td', 'subtext'))
|
subtext = self.tag_to_string(main.find('td', 'subtext'))
|
||||||
|
|
||||||
@ -94,7 +92,7 @@ class HNWithCommentsLink(BasicNewsRecipe):
|
|||||||
return a
|
return a
|
||||||
|
|
||||||
def get_obfuscated_article(self, url):
|
def get_obfuscated_article(self, url):
|
||||||
if url.startswith('http://news.ycombinator.com'):
|
if url.startswith('https://news.ycombinator.com'):
|
||||||
content = self.get_hn_content(url)
|
content = self.get_hn_content(url)
|
||||||
else:
|
else:
|
||||||
# TODO: use content-type header instead of url
|
# TODO: use content-type header instead of url
|
||||||
@ -118,6 +116,8 @@ class HNWithCommentsLink(BasicNewsRecipe):
|
|||||||
content = re.sub(r'</body>\s*</html>\s*$', '', content) + \
|
content = re.sub(r'</body>\s*</html>\s*$', '', content) + \
|
||||||
article.summary + '</body></html>'
|
article.summary + '</body></html>'
|
||||||
|
|
||||||
|
if not isinstance(content, bytes):
|
||||||
|
content = content.encode('utf-8')
|
||||||
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()
|
||||||
@ -137,5 +137,5 @@ class HNWithCommentsLink(BasicNewsRecipe):
|
|||||||
|
|
||||||
# def parse_index(self):
|
# def parse_index(self):
|
||||||
# feeds = []
|
# feeds = []
|
||||||
# feeds.append((u'Hacker News',[{'title': 'Testing', 'url': 'http://news.ycombinator.com/item?id=2935944'}]))
|
# feeds.append((u'Hacker News',[{'title': 'Testing', 'url': 'https://news.ycombinator.com/item?id=2935944'}]))
|
||||||
# return feeds
|
# return feeds
|
||||||
|
Loading…
x
Reference in New Issue
Block a user