Skip to content

Instantly share code, notes, and snippets.

@FiloSottile
Last active February 28, 2019 07:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save FiloSottile/5487468 to your computer and use it in GitHub Desktop.
Save FiloSottile/5487468 to your computer and use it in GitHub Desktop.
Before GitHub implemented Stars I used to bookmark interesting repos on Pinboard with a 'github-repo' tag. This script leverages GH and Pinboard APIs to star the bookmarked repo, and if the bookmark only had that tag and the star action succeeded deletes the bookmark.
# depends on python-pinboard and github3.py
import pinboard
from getpass import getpass
import re
from github3 import login
p = pinboard.PinboardAccount(token="FiloSottile:REDACTED")
user = 'FiloSottile'
password = ''
while not password:
password = getpass('Password for {0}: '.format(user))
gh = login(user, password=password)
l = p.posts(tag="github-repo", count=500)
for pin in l:
url = pin['href']
tags = pin['tags']
match = re.match(r'https://github\.com/([^/]+)/([^/]+)', url, re.IGNORECASE)
if not match:
print(url)
continue
user, repo = match.groups()
print(user, repo)
if tags == [u'github-repo'] and \
(gh.is_starred(user, repo) or gh.star(user, repo)):
p.delete(url)
print('Done.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment