Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dlo9 committed Jul 26, 2019
0 parents commit 93397f7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.epub
38 changes: 38 additions & 0 deletions PocketRSS.recipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
from calibre.web.feeds.news import BasicNewsRecipe

class PocketRSS(BasicNewsRecipe):
title = 'PocketRSS'
__author__ = 'David Orchard'
description = 'Fetches private RSS feeds from getpocket.com'

oldest_article = 7
max_articles_per_feed = 100
auto_cleanup = True
needs_subscription = True
feeds = ['Unread']

base_url = 'https://getpocket.com'

def get_rss_tuple(self, feed_name):
return (feed_name, '{}/users/{}/feed/{}'.format(self.base_url, self.username, feed_name.lower()))

# This can't be done during class construction because self.username isn't set yet
def resolve_feeds(self):
self.feeds = list(map(self.get_rss_tuple, self.feeds))

def get_browser(self, *args, **kwargs):
self.resolve_feeds()
br = BasicNewsRecipe.get_browser(self)
if self.username is None or self.password is None:
# Currently (3.44.0) calibre fails silently when a username/password is missing, but this branch should stay
# here in case that bug is ever fixed
self.abort_recipe_processing("Please enter a username and password under Fetch news > Schedule news download")

# Authenticate with each feed
for feed in self.feeds:
br.add_password(feed[1], self.username, self.password)

return br
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# cablire-recipes

A set of custom recipes for automatic news fetching in [Calibre](https://calibre-ebook.com)

# Debugging
* Do a test run: `ebook-convert PocketRSS.recipe .epub --dont-download-recipe --test --password <password> --username <username> -vvv`
* Enable browser debugging:
```
import sys, logging
def enable_logging(br):
logger = logging.getLogger("mechanize")
logger.addHandler(logging.StreamHandler(sys.stdout))
logger.setLevel(logging.DEBUG)
br.set_debug_http(True)
br.set_debug_responses(True)
br.set_debug_redirects(True)
```

0 comments on commit 93397f7

Please sign in to comment.