-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassDownload.py
More file actions
23 lines (21 loc) · 808 Bytes
/
Copy pathassDownload.py
File metadata and controls
23 lines (21 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import json
import requests
os.makedirs("字幕下载",exist_ok=True)
url = f"https://api.github.com/repos/foxofice/sub_share/contents/{input('path:')}"
keyword = input("关键字(可为空):")
response = requests.get(url)
if response.status_code == 200:
# print(json.dumps(response.json(), indent=4, ensure_ascii=False))
for file in response.json():
if file["type"] == "file" and keyword in file["name"]:
resp = requests.get(file["download_url"])
if resp.ok:
with open(os.path.join("字幕下载",file["name"]) , 'wb') as f:
f.write(resp.content)
print(f'{file["name"]} 已下载')
else:
print(f'{file["name"]} 下载失败')
else:
print(response.text)
print("完成")