-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpull_github_repos.py
37 lines (32 loc) · 1.05 KB
/
pull_github_repos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Pulls all of my public github repos,
including their tags and README files,
and writes them into markdown files in
my obsidian vault (in the /github_repos folder)
"""
import time
from typing import Final
import requests
from tqdm import tqdm
repos_data: list[dict] = []
GITHUB_USERNAME: Final[str] = "J-sephB-lt-n"
N_RESULTS_PER_PAGE: Final[int] = 50
page_num: int = 1
response = requests.get(
url=f"https://api.github.com/users/{GITHUB_USERNAME}/repos",
params={
"per_page": N_RESULTS_PER_PAGE,
"page": page_num,
},
)
for repo_info in tqdm(response.json()):
# readme_metadata_response = requests.get(
# url=f"https://api.github.com/repos/{GITHUB_USERNAME}/{repo_info['name']}/readme"
# )
readme_contents_response = requests.get(
url=f"https://raw.githubusercontent.com/{GITHUB_USERNAME}/{repo_info['name']}/main/README.md"
)
print(readme_contents_response.text)
time.sleep(0.5)
repos_data.append(
{k: v for k, v in repo_info.items() if k in ("name", "description", "html_url")}
)