From 8bb88658b10ec230df7697b22b68f0fd8fc52fa3 Mon Sep 17 00:00:00 2001 From: Quick <31828688+Quick104@users.noreply.github.com> Date: Sun, 5 Jul 2026 13:21:43 -0400 Subject: [PATCH] fix(historyimport): use a discover-safe page size for the Plex watchlist The discover API rejects the PMS page size (500) with 400 "Invalid value provided for x-plex-container-size!"; page the watchlist at 100 instead. Part of #245 Co-Authored-By: Claude Fable 5 --- internal/historyimport/plex_client.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/historyimport/plex_client.go b/internal/historyimport/plex_client.go index 43b339a3..98850f00 100644 --- a/internal/historyimport/plex_client.go +++ b/internal/historyimport/plex_client.go @@ -21,6 +21,10 @@ const ( // watchlist), which lives on plex.tv infrastructure rather than the PMS. plexDiscoverBaseURL = "https://discover.provider.plex.tv" plexPageSize = 500 + // plexWatchlistPageSize is deliberately smaller: the discover API + // rejects the PMS page size with 400 "Invalid value provided for + // x-plex-container-size!". + plexWatchlistPageSize = 100 ) type PlexClient struct { @@ -297,7 +301,7 @@ func (c *PlexClient) FetchWatchlist(ctx context.Context, accountToken string) ([ query := url.Values{} query.Set("includeGuids", "1") query.Set("X-Plex-Container-Start", strconv.Itoa(offset)) - query.Set("X-Plex-Container-Size", strconv.Itoa(plexPageSize)) + query.Set("X-Plex-Container-Size", strconv.Itoa(plexWatchlistPageSize)) reqURL := fmt.Sprintf("%s/library/sections/watchlist/all?%s", base, query.Encode()) req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, nil) if err != nil {