refactor: remove ext install

This commit is contained in:
lilong.129
2025-02-11 21:49:52 +08:00
parent 3b450ce97f
commit e02e889a8e
10 changed files with 10 additions and 257 deletions

View File

@@ -15,7 +15,6 @@ import (
"math/rand"
"net"
"net/http"
"net/url"
"os"
"os/exec"
"path/filepath"
@@ -383,57 +382,6 @@ func GetCurrentDay() string {
return formattedDate
}
func DownloadFile(filePath string, fileUrl string) error {
log.Info().Str("filePath", filePath).Str("url", fileUrl).Msg("download file")
parsedURL, err := url.Parse(fileUrl)
if err != nil {
return err
}
out, err := os.Create(filePath)
if err != nil {
return err
}
defer out.Close()
// 创建一个新的 HTTP 请求
req, err := http.NewRequest("GET", fileUrl, nil)
if err != nil {
return err
}
// TODO: rename token
eapiToken := os.Getenv("EAPI_TOKEN")
if eapiToken != "" {
if parsedURL.Host != "gtf-eapi-cn.bytedance.com" && parsedURL.Host != "gtf-eapi-cn.bytedance.net" {
return errors.New("invalid domain: must be gtf-eapi-cn.bytedance.com")
}
// 添加自定义头部
req.Header.Add("accessKey", "ies.vedem.video")
req.Header.Add("token", eapiToken)
}
// 创建一个 HTTP 客户端并发送请求
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("bad status: %s, download failed", resp.Status)
}
// 将响应主体写入文件
_, err = io.Copy(out, resp.Body)
if err != nil {
return err
}
return nil
}
func fileExists(filepath string) bool {
_, err := os.Stat(filepath)
if os.IsNotExist(err) {

View File

@@ -1 +1 @@
v5.0.0+2502112106
v5.0.0+2502112149