Last active
February 28, 2019 07:07
-
-
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.
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
# 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