nginx-conf icon indicating copy to clipboard operation
nginx-conf copied to clipboard

是否有对 releases api 的支持

Open soiamsoNG opened this issue 4 years ago • 7 comments

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

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

soiamsoNG avatar May 14 '21 07:05 soiamsoNG

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

KevinZonda avatar May 14 '21 08:05 KevinZonda

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

KevinZonda avatar May 14 '21 08:05 KevinZonda

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

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

soiamsoNG avatar May 14 '21 09:05 soiamsoNG

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

KevinZonda avatar May 14 '21 09:05 KevinZonda

我们正在考虑是否支持 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)

soiamsoNG avatar May 14 '21 09:05 soiamsoNG

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

https://github.com/FastGitORG/nginx-conf/blob/379fbdd49763f481d083d04f4654b326d764c759/hub.fastgit.org.conf#L40-L48

KevinZonda avatar May 14 '21 09:05 KevinZonda

Transferred to nginx-conf

KevinZonda avatar May 14 '21 09:05 KevinZonda