Send entire feed to Pinboard
#coding: utf-8 | |
import feedparser | |
import urllib | |
import bs4 | |
import keychain | |
import console | |
import pickle | |
# Get your token at: | |
# http://pinboard.in/settings/password | |
token = keychain.get_password('pinboardapitoken','pinboard') | |
if token is not None: | |
token = pickle.loads(token) | |
else: | |
token = pickle.dumps(console.input_alert('Pinboard API Token')) | |
keychain.set_password('pinboardapitoken', 'pinboard', token) | |
# Add the link for the RSS you'd like to send to Pinboard | |
rss = console.input_alert('RSS feed URL') | |
print 'Loading feed...' | |
feed = feedparser.parse(rss) | |
entries = feed['entries'] | |
#replace the ‘starred’ with other tag you want. | |
tags = urllib.quote('starred') | |
for entry in entries: | |
query = 'https://api.pinboard.in/v1/posts/add?auth_token=' + token + '&url=' + urllib.quote(entry['link']) + '&description=' + urllib.quote(entry['title'].encode('utf-8')) + '&tags=' + tags | |
pinboard = bs4.BeautifulSoup(urllib.urlopen(query)) | |
print 'Added to Pinboard: ' + entry['title'] | |
print 'Success! Added all available feed articles!' | |
console.hide_output() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment