Skip to content
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

Open
Naivc opened this issue Dec 20, 2024 · 3 comments
Open

如何下载单个文件夹里的字幕? #102

Naivc opened this issue Dec 20, 2024 · 3 comments

Comments

@Naivc
Copy link

Naivc commented Dec 20, 2024

No description provided.

@foxofice
Copy link
Owner

用TortoiseGit看看

@RiderLty
Copy link

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按钮,然后粘贴

@dyphire
Copy link
Collaborator

dyphire commented Jan 18, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants