Last active
May 30, 2018 20:02
-
-
Save steeve85/7860263 to your computer and use it in GitHub Desktop.
Simple script to git clone each GitHub project starred by a user.
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/bin/env python | |
import urllib2, json, os, subprocess | |
# Simple script to git clone each project starred by a user. | |
# /!\ There is an API rate limit. To increase it, authenticated actions are needed -_- | |
# http://developer.github.com/v3/#rate-limiting | |
user = "steeve85" | |
i = 1 | |
json_data = None | |
while json_data != []: | |
json_data = json.loads(urllib2.urlopen("https://api.github.com/users/%s/starred?page=%i" % (user, i)).read()) | |
for j in range(30): | |
try: | |
print "Cloning %s" % json_data[j]["full_name"] | |
print "\t\t %s" % json_data[j]["description"] | |
if os.path.exists(json_data[j]["name"]): | |
subprocess.call('cd %s; git pull --recurse-submodules; cd -' % json_data[j]["name"], shell=True) | |
else: | |
subprocess.call(['git', 'clone', '--recurse-submodules', json_data[j]["clone_url"]]) | |
except IndexError: | |
print "End of starred projects" | |
exit(0) | |
i+=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment