Last active
May 8, 2020 05:56
-
-
Save philgruneich/b17732fe8eb828be8328 to your computer and use it in GitHub Desktop.
Fetches Pinboard for unread bookmarks and stores them in a JSON file.
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
#!/usr/local/bin/python3 | |
import requests | |
import json | |
# User Configuration | |
PB_USERNAME = "your Pinboard username" | |
PB_PASSWORD = "your Pinboard password" | |
PB_PATH = "/absolute/path/to/file/PinboardUnread.json" | |
# End Configuration | |
PB_URL = "https://api.pinboard.in/v1/posts/all?format=json" | |
r = requests.get(PB_URL, auth=((PB_USERNAME, PB_PASSWORD))) | |
data = json.loads(r.text) | |
toread = [{"title": i["description"], "subtitle": i["extended"], "url": i["href"], "actionArgument": {"shared": i["shared"], "tags": i["tags"]}, "action": "markAsRead.py", "actionRunsInBackground": bool("true")} for i in data if i["toread"] == "yes"] | |
with open(PB_PATH, "w+") as the_file: | |
print(json.dumps(toread), file=the_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment