Skip to content

Instantly share code, notes, and snippets.

@james-see
Forked from macolyte/pinboard_reading_list.py
Last active November 18, 2023 00:03
Show Gist options
  • Save james-see/fd8fdab4fbe9a40bf037 to your computer and use it in GitHub Desktop.
Save james-see/fd8fdab4fbe9a40bf037 to your computer and use it in GitHub Desktop.
import os
import markdown
import requests
import webbrowser
pinToken = 'Put your Pinboard API token here'
pinAPI = 'api.pinboard.in/v1/'
pinGet = 'posts/all'
pinURL = 'https://' + pinAPI + pinGet + '?auth_token=' + pinToken + '&toread=yes&format=json'
def main():
j = requests.get(pinURL).json
s = ""
for article in j:
outstring = "* [%s](%s)\n" % (article['description'], article['href'])
s += outstring
md = markdown.Markdown()
contents = md.convert(s)
with open('reading_list.html', 'w') as f:
f.write(contents)
pth = "file:///" + os.path.join(os.path.dirname(os.path.abspath(__file__)), "reading_list.html")
webbrowser.open(pth)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment