feat(tmdb): add with_companies and with_networks to discover params

This commit is contained in:
Silo Server Migration
2026-05-24 18:31:33 -04:00
parent 1a313f4003
commit 7397fa8141
3 changed files with 36 additions and 0 deletions
+6
View File
@@ -520,6 +520,12 @@ func buildDiscoverQuery(mediaType string, params DiscoverParams) string {
if without := joinIntSlice(params.WithoutGenres, ","); without != "" {
values.Set("without_genres", without)
}
if companies := joinIntSlice(params.WithCompanies, ","); companies != "" {
values.Set("with_companies", companies)
}
if networks := joinIntSlice(params.WithNetworks, ","); networks != "" {
values.Set("with_networks", networks)
}
if params.VoteCountGte > 0 {
values.Set("vote_count.gte", strconv.Itoa(params.VoteCountGte))
}
+28
View File
@@ -204,6 +204,34 @@ func TestDiscoverTVUsesFirstAirDate(t *testing.T) {
}
}
func TestDiscoverIncludesCompaniesAndNetworks(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
if got := q.Get("with_companies"); got != "420,2" {
t.Errorf("with_companies = %q, want 420,2", got)
}
if got := q.Get("with_networks"); got != "213,49" {
t.Errorf("with_networks = %q, want 213,49", got)
}
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(`{"page":1,"total_pages":1,"total_results":0,"results":[]}`))
}))
defer server.Close()
client := NewClient("test-key", 1000)
client.SetBaseURL(server.URL)
_, err := client.Discover(context.Background(), "movie", DiscoverParams{
SortBy: "popularity.desc",
WithCompanies: []int{420, 2},
WithNetworks: []int{213, 49},
Limit: 5,
})
if err != nil {
t.Fatalf("Discover returned error: %v", err)
}
}
func TestDiscoverRejectsInvalidMediaType(t *testing.T) {
client := NewClient("test-key", 1000)
_, err := client.Discover(context.Background(), "all", DiscoverParams{SortBy: "popularity.desc"})
+2
View File
@@ -65,6 +65,8 @@ type MediaPage struct {
type DiscoverParams struct {
WithGenres []int
WithoutGenres []int
WithCompanies []int
WithNetworks []int
SortBy string
VoteCountGte int
VoteAverageGte float64