Created
November 17, 2014 02:22
-
-
Save philgruneich/9450299366c67b608fb8 to your computer and use it in GitHub Desktop.
Send entire feed to Pinboard
This file contains 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
#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