Fix local adult metadata and watch history removal

This commit is contained in:
ShukeBta
2026-05-28 14:52:20 +08:00
parent 352edd86ed
commit 32ccb33fed
95 changed files with 6589 additions and 1307 deletions
+14 -15
View File
@@ -156,22 +156,21 @@ func (s *ApiConfigService) testTMDb(cfg *model.ApiConfig) (string, error) {
return "error", errors.New("API key is required")
}
testURL := "https://api.themoviedb.org/3/configuration?api_key=" + cfg.APIKey
resp, err := http.Get(testURL)
baseURL := strings.TrimRight(cfg.BaseURL, "/")
if baseURL == "" {
baseURL = strings.TrimRight(s.cfg.Secrets.TMDbAPIProxy, "/")
}
if baseURL == "" {
baseURL = "https://api.themoviedb.org/3"
}
testURL := baseURL + "/configuration?api_key=" + url.QueryEscape(cfg.APIKey)
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, testURL, nil)
if err != nil {
return "error", err
}
client := NewExternalHTTPClient(10 * time.Second)
resp, err := client.Do(req)
if err != nil {
// 如果配置了代理,使用代理
if s.cfg.Secrets.TMDbAPIProxy != "" {
proxyURL := s.cfg.Secrets.TMDbAPIProxy + "?api_key=" + cfg.APIKey
resp, err = http.Get(proxyURL)
if err != nil {
return "error", fmt.Errorf("TMDb connection failed: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
return "success", nil
}
return "error", fmt.Errorf("TMDb API returned status %d", resp.StatusCode)
}
return "error", fmt.Errorf("TMDb connection failed: %w", err)
}
defer resp.Body.Close()