Created
July 24, 2014 05:46
-
-
Save waiting-for-dev/96d88816ba6aff2af3f1 to your computer and use it in GitHub Desktop.
Read Your Newsbeuter Feeds in Epub Format - http://waiting-for-dev.github.io/blog/2014/07/20/read-your-newsbeuter-feeds-in-epub-format/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function epub() { | |
tags="$@" | |
if [ x = x${tags} ]; then | |
filename=$(date -I)_feeds | |
else | |
filename=$(date -I)_${tags// /_}_feeds | |
fi | |
ebook-convert ~/projects/recipes/newsbeuter/newsbeuter.recipe $filename.epub --tags="${tags// /,}" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim:fileencoding=utf-8 | |
from calibre.web.feeds.news import BasicNewsRecipe | |
from os.path import expanduser | |
import urllib | |
import re | |
class NewsbeuterRecipe (BasicNewsRecipe): | |
__author__ = 'Marc Busqué <[email protected]>' | |
__url__ = 'http://www.lamarciana.com' | |
__version__ = '1.0.4' | |
__license__ = 'GPL v3' | |
__copyright__ = '2014, Marc Busqué <[email protected]>' | |
title = u'Newsbeuter feeds' | |
description = u"Dynamic recipe which is created from all feeds listed in newsbeuter url file (~/.newsbeuter/urls). Lines of that file must be in the format 'http://address_to_the_feed.com \"~Feed name\" tags'. It can filter by tags using the following from the command line: `ebook-convert newsbeuter.recipe .epub --tags=\"english,newspaper\"`. More information at: http://waiting-for-dev.github.io/blog/2014/07/20/read-your-newsbeuter-feeds-in-epub-format/" | |
tags = 'newsbeuter' | |
oldest_article = 10 | |
max_articles_per_feed = 20 | |
remove_empty_feeds = True | |
no_stylesheets = True | |
extra_css = urllib.urlopen('https://raw.githubusercontent.com/laMarciana/gutenweb/master/dist/gutenweb.css').read().replace('@charset "UTF-8";', '') | |
newsbeuter_url = expanduser('~')+'/.newsbeuter/urls' | |
def __init__(self, options, *args, **kwargs): | |
BasicNewsRecipe.__init__(self, options, *args, **kwargs) | |
if options.tags: | |
self.newsbeuter_tags = options.tags.strip().split(',') | |
NewsbeuterRecipe.title = 'Feeds: '+', '.join(self.newsbeuter_tags) | |
else: | |
self.newsbeuter_tags = [] | |
NewsbeuterRecipe.title = 'Feeds' | |
def get_feeds(self): | |
feeds = [] | |
with open(self.newsbeuter_url) as f: | |
for line in f: | |
matches = re.compile('(.*)\s"~(.*)"\s(.*)').match(line) | |
url = unicode(matches.group(1)) | |
title = unicode(matches.group(2)) | |
matched_tags = matches.group(3).split(' ') | |
if self.newsbeuter_tags: | |
if set(self.newsbeuter_tags).issubset(set(matched_tags)): | |
feeds.append([title, url]) | |
else: | |
feeds.append([title, url]) | |
return feeds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment