refactor(seerrclient): isolate generated API quirks behind an internal client layer#90
Merged
electather merged 5 commits intomainfrom Mar 16, 2026
Merged
Conversation
- Add genre, studio/network, language, sortBy, date range, vote average, and runtime filters to search_discover_movies and search_discover_tv - Fix report_issue prompt to remove non-existent mediaType arg on issue_create - Fix issue_create tool description to list all 5 issue types correctly - Add search_company and search_keyword tools - Add movies_ratings_combined tool - Add settings_jobs_cancel and settings_jobs_schedule tools - Remove orphaned WatchProviders resource handlers that were never registered - Add inventory.go with MCPToolCount/MCPResourceCount/MCPPromptCount constants - Update serve.go log lines to use inventory constants instead of stale literals - Update README tool count (43 -> 52) and add missing tools and resources table
…I quirks Introduce internal/seerrclient with a concrete Client type that wraps the auto-generated pkg/api client and hides three generated-code quirks: - float32 IDs: MovieGet/Recommendations/Similar/Ratings methods accept int and convert internally so callers never see float32 casts. - Union-type unmarshal bug: SearchMulti and Discover* use RawGet to bypass the generated client, which deserialises TV results as PersonResult. - URL encoding: an encodingRoundTripper on the client replaces + with %20 for generated-client calls (company/keyword queries); RawGet already handles this for raw requests. - Trending defaults: DiscoverTrending strips mediaType=all and timeWindow=day before sending to avoid HTTP 400 on some server versions. Migrate cmd/search, cmd/movies, and cmd/mcp to use the new client. Delete the now-redundant encodingRoundTripper and newAPIClient from cmd/search/search.go. Add tests/seerrclient_test.go covering all five new behaviours (TDD).
6 tasks
…generated docs (#91)
…lectather/seerr-cli into refactor/internal-seerr-client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #84
Introduces
internal/seerrclient— a concreteClienttype that wraps the auto-generatedpkg/apiclient and hides three categories of generated-code quirks so that feature code never has to deal with them directly:float32for all numeric IDs (movie IDs, page numbers). Wrapper methods (MovieGet,MovieRecommendations, etc.) acceptintand convert internally.SearchMultiand all Discover methods useRawGetto bypass the generated client's broken deserialisation where TV results becomePersonResult.%20for spaces, not+. AnencodingRoundTripperon everyClienthandles this for generated-client calls;RawGetalready handles it for raw requests.DiscoverTrendingstripsmediaType=allandtimeWindow=daybefore sending, since some server versions reject them with HTTP 400.Changes
internal/seerrclient/client.go—Clientstruct,New(),NewWithKey(),RawGet(),Unwrap(),encodingRoundTripperinternal/seerrclient/search.go—SearchMulti,DiscoverMovies,DiscoverTV,DiscoverTrending(with default-stripping)internal/seerrclient/movies.go—MovieGet,MovieRecommendations,MovieSimilar,MovieRatings,MovieRatingsCombinedcmd/search/search.go— deletedencodingRoundTripperandnewAPIClient(); subcommands now useseerrclient.New()cmd/search/{multi,movies,tv,trending,company,keyword}.go— migrated to seerrclientcmd/movies/{get,recommendations,similar,ratings,ratings_combined}.go— migrated to seerrclientcmd/mcp/tools_search.go— replacedapiutil.RawGetcalls with seerrclient methodscmd/mcp/tools_movies.go— replacedfloat32casts with seerrclient movie methodstests/seerrclient_test.go— 5 new tests (TDD)Test plan
go test -v ./...passesgo fmt ./...produces no diffgo buildsucceedsTests written before implementation (TDD):
TestClientRawGetSpaceEncoding— spaces encoded as%20not+TestClientSearchMultiPreservesAllMediaTypes— movie + tv + person all returnedTestClientDiscoverTrendingStripsDefaultParams—mediaType=allandtimeWindow=daystrippedTestClientDiscoverTrendingPassesThroughExplicitParams— explicitpage=2passes throughTestClientMovieGetPassesIntID— int ID550reaches path/api/v1/movie/550Checklist
--help, comments)