优化番号处理逻辑,添加对MetaTube的支持

优化番号处理逻辑,添加对MetaTube的支持
This commit is contained in:
truewhile
2026-08-21 00:06:49 +08:00
parent aa15cfe1f1
commit 65d1ad5ae5
25 changed files with 2283 additions and 83 deletions
+22 -4
View File
@@ -85,11 +85,26 @@ func applyRemoteImageHeaders(req *http.Request, host string) {
req.Header.Set("Accept-Language", "zh-CN,zh;q=0.9,ja;q=0.8,en;q=0.7")
req.Header.Set("Cache-Control", "no-cache")
req.Header.Set("Pragma", "no-cache")
if cookie := remoteImageCookie(host); cookie != "" {
req.Header.Set("Cookie", cookie)
}
if referer := remoteImageReferer(host); referer != "" {
req.Header.Set("Referer", referer)
}
}
func remoteImageCookie(host string) string {
h := strings.ToLower(strings.TrimSpace(host))
switch {
case strings.Contains(h, "javbus") || strings.Contains(h, "busjav") || strings.Contains(h, "dmmbus") || strings.Contains(h, "javsee") || strings.Contains(h, "cdnbus"):
return "age=verified; existmag=all"
case strings.Contains(h, "javdb") || strings.Contains(h, "jdbstatic"):
return "over18=1"
default:
return ""
}
}
func remoteImageReferer(host string) string {
h := strings.ToLower(strings.TrimSpace(host))
switch {
@@ -143,10 +158,13 @@ func fetchRemoteImageWithCurl(ctx context.Context, raw, host string) ([]byte, st
"--header", "Cache-Control: no-cache",
"--header", "Pragma: no-cache",
}
if referer := remoteImageReferer(host); referer != "" {
args = append(args, "--referer", referer)
}
args = append(args, "--", raw)
if referer := remoteImageReferer(host); referer != "" {
args = append(args, "--referer", referer)
}
if cookie := remoteImageCookie(host); cookie != "" {
args = append(args, "--cookie", cookie)
}
args = append(args, "--", raw)
cmd := exec.CommandContext(curlCtx, bin, args...) // #nosec G204 -- bin is resolved by LookPath and args are not shell-expanded.
stderr := bytes.Buffer{}