mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Changes based on pull request feedback
* removed inappropriate archive recipe * added __author__ and encoding attributes to remaining recipe
This commit is contained in:
parent
e4e3dd04ff
commit
ab65bd18c0
@ -4,27 +4,21 @@ from calibre.web.feeds.news import BasicNewsRecipe
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2015, Ned Letcher - ned@nedned.net'
|
__copyright__ = '2015, Ned Letcher <ned at nedned.net>'
|
||||||
|
|
||||||
|
|
||||||
"""A calibre custom news recipe for creating eBooks of periodic
|
"""
|
||||||
updates from the blog Slate Star Codex.
|
calibre recipe for Slate Star Codex.
|
||||||
|
|
||||||
If calibre is installed on your system you can generate an epub
|
|
||||||
of recent SSC posts from your command line like so:
|
|
||||||
|
|
||||||
$ ebook-convert slate_star_codex.recipe .epub
|
|
||||||
|
|
||||||
Author: Ned Letcher
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class SlateStarCodex(BasicNewsRecipe):
|
class SlateStarCodex(BasicNewsRecipe):
|
||||||
title = u'Slate Star Codex'
|
title = u'Slate Star Codex'
|
||||||
description = 'IN A MAD WORLD, ALL BLOGGING IS PSYCHIATRY BLOGGING'
|
description = 'IN A MAD WORLD, ALL BLOGGING IS PSYCHIATRY BLOGGING'
|
||||||
|
__author__ = 'Ned Letcher'
|
||||||
max_articles_per_feed = 20
|
max_articles_per_feed = 20
|
||||||
language = 'en'
|
language = 'en'
|
||||||
|
encoding = 'utf-8'
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
# alternative candidate for keep_only_tags:
|
# alternative candidate for keep_only_tags:
|
||||||
# [{'attrs':{'class':['pjgm-posttitle', 'pjgm-postmeta', 'pjgm-postcontent']}}]
|
# [{'attrs':{'class':['pjgm-posttitle', 'pjgm-postmeta', 'pjgm-postcontent']}}]
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
#!/usr/bin/env python2
|
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
|
||||||
import re
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
|
||||||
__copyright__ = '2015, Ned Letcher - ned@nedned.net'
|
|
||||||
|
|
||||||
|
|
||||||
"""A calibre custom news recipe for creating eBooks of *all* posts
|
|
||||||
from the blog Slate Star Codex.
|
|
||||||
|
|
||||||
If calibre is installed on your system you can generate an epub of the
|
|
||||||
entire SSC archive from your command line like so:
|
|
||||||
|
|
||||||
$ ebook-convert slate_star_codex.recipe .epub
|
|
||||||
|
|
||||||
Author: Ned Letcher
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
class SlateStarCodexArchive(BasicNewsRecipe):
|
|
||||||
title = u'Slate Star Codex (Complete Archive)'
|
|
||||||
description = 'IN A MAD WORLD, ALL BLOGGING IS PSYCHIATRY BLOGGING'
|
|
||||||
simultaneous_downloads = 10
|
|
||||||
max_articles_per_feed = 1000
|
|
||||||
reverse_article_order = True
|
|
||||||
language = 'en'
|
|
||||||
no_stylesheets = True
|
|
||||||
# alternative candidate for keep_only_tags:
|
|
||||||
# [{'attrs':{'class':['pjgm-posttitle', 'pjgm-postmeta', 'pjgm-postcontent']}}]
|
|
||||||
keep_only_tags = [dict(name='div', attrs={'class':re.compile(r'\bpost\b')})]
|
|
||||||
remove_tags = [dict(name='div', attrs={'class':re.compile(r'\bsharedaddy\b')})]
|
|
||||||
|
|
||||||
def get_archived_posts(self):
|
|
||||||
soup = self.index_to_soup('http://slatestarcodex.com/archives/')
|
|
||||||
entries = soup.findAll(attrs={'class':'sya_postcontent'})
|
|
||||||
|
|
||||||
posts = []
|
|
||||||
for entry in entries:
|
|
||||||
atag = entry.find('a')
|
|
||||||
url = atag['href']
|
|
||||||
post = {
|
|
||||||
'title' : atag.contents[0],
|
|
||||||
'url' : url,
|
|
||||||
'date' : "-".join(url.strip('/').split('/')[-4:-1]),
|
|
||||||
}
|
|
||||||
posts.append(post)
|
|
||||||
return posts
|
|
||||||
|
|
||||||
def parse_index(self):
|
|
||||||
posts = self.get_archived_posts()
|
|
||||||
return [[self.title, posts]]
|
|
Loading…
x
Reference in New Issue
Block a user