Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

是否有对 releases api 的支持 #19

Open
soiamsoNG opened this issue May 14, 2021 · 7 comments
Open

是否有对 releases api 的支持 #19

soiamsoNG opened this issue May 14, 2021 · 7 comments

Comments

@soiamsoNG
Copy link

https://docs.github.com/en/rest/reference/repos#releases

改写assets 中的 browser_download_url 到使用 download.fastgit.org 域

@KevinZonda
Copy link
Member

每个字都认识
连起来就颇有难度

@KevinZonda
Copy link
Member

所以是说 api.github.com 的代理吗

@soiamsoNG
Copy link
Author

所以是说 api.github.com 的代理吗

是的,但是改写里面的部分内容

@KevinZonda
Copy link
Member

我们正在考虑是否支持 API 以及如何支持

@soiamsoNG
Copy link
Author

我们正在考虑是否支持 API 以及如何支持

下面是我想到的一个用法,希望有帮助

#!/usr/bin/env python3

import os
import requests
import json
import subprocess

releasesInfo = requests.get(
    'https://api.github.com/repos/haskell/haskell-language-server/releases').content

g = json.loads(releasesInfo)

for i in range(0, len(g[0]['assets'])-1):
    g[0]['assets'][i]['browser_download_url'] = (
        g[0]['assets'][i]['browser_download_url'].replace(
            'https://github.com',
            'https://download.fastgit.org'
        )
    )

# dump json onto the _base_path
with open('releasesInfo.json', 'w') as releasesInfoFile:
    json.dump(g, releasesInfoFile, indent=4)

@KevinZonda
Copy link
Member

感觉不需要做太多替换,可以看看

# releases download
location ~ ^/[^/]+/[^/]+/releases/download/ {
return 301 https://download.fastgit.org$request_uri;
}
# archive download
location ~ ^/[^/]+/[^/]+/archive/ {
return 301 https://archive.fastgit.org$request_uri;
}

@KevinZonda KevinZonda transferred this issue from FastGitORG/discussion May 14, 2021
@KevinZonda
Copy link
Member

Transferred to nginx-conf

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

No branches or pull requests

2 participants