Downloading your favourite repos from Github(Python)
This will clone all your "starred" repos from Github in the current directory.
#!/usr/bin/env python
#pip install gitpython
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])
Remember to change the username or it'll download my favourite repos.
Warning: Diy error checking.
Written by Kasisnu
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Github
Authors
projectcleverweb
289.2K
jjperezaguinaga
90.23K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#