Created
March 13, 2022 08:12
-
-
Save Vostbur/3c8da88bab79cc85d4a9fe61fb9421f1 to your computer and use it in GitHub Desktop.
Backup (clone) all your own gists
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 -B | |
# pip install PyGithub | |
from github import Github | |
import pathlib | |
import json | |
import os | |
gists = [] | |
g = Github(open(pathlib.Path.home() / ".github_access_token").read()) | |
for gist in g.get_user().get_gists(): | |
gists.append({ | |
"id": gist.id, | |
"description": gist.description, | |
"public": gist.public, | |
"clone": gist.git_pull_url, | |
"updated": gist.updated_at.isoformat(), | |
"url": gist.url, | |
}) | |
os.system("git clone {0} repos/{1}".format(gist.git_pull_url, gist.id)) | |
with open("index.json", "w") as f: | |
f.write(json.dumps(gists, indent=4) + "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment