Last active
May 26, 2017 15:44
-
-
Save kasisnu/14ccf1f0f2e09d600e4c to your computer and use it in GitHub Desktop.
A dirty way to download a backup of all starred repos on github.
This file contains hidden or 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 | |
| from git import Repo | |
| import requests | |
| import json | |
| import multiprocessing | |
| import os | |
| try: | |
| cpus = multiprocessing.cpu_count() | |
| except NotImplementedError: | |
| cpus = 2 | |
| starred_repos = json.loads(requests.get('https://api.github.com/users/kasisnu/starred?page=1&per_page=10000').text) | |
| def my_funky_clone(url): | |
| dir_name = url.split('/')[-1][:-4] | |
| try: | |
| os.mkdir(dir_name) | |
| Repo.clone_from(url,dir_name) | |
| except: | |
| pass | |
| pool = multiprocessing.Pool(processes=cpus) | |
| pool.map(my_funky_clone, [i['clone_url'] for i in starred_repos]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment