-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如何下载单个文件夹里的字幕? #102
Comments
用TortoiseGit看看 |
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("完成") 点开github上对应文件夹后,点路径旁边的copy path按钮,然后粘贴 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: