Repository navigation
Add search paging, mode, category, and free filters (M-Team) - #30
Merged
Merged
Conversation
site search read only the first 50 results in normal mode. A new optional port, site.OptionTorrentSearcher, takes site.SearchOptions (page, mode, category IDs, free-only), and site search exposes it as --page, --mode, --category, and --free. The CLI validates options with the adapter before the credential is read; a site without the port refuses the flags, so TJUPT is unchanged. M-Team sends them in its one search request as pageNumber, mode, categories, and discount FREE, and drops any returned row whose download is counted. Without options the request body is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
site searchused to return only the first page of 50 results, in normal mode. This adds four options:--page N: the page to read (M-Team accepts 1–1000).--mode normal|adult: the site's search area.--category ID: category IDs. The flag can be repeated or take a comma-separated list, up to 32 IDs.--free: only torrents whose download is not counted.Design
A new optional port,
site.OptionTorrentSearcher, sits next toTorrentSearcher. It has two methods:ValidateSearchOptions(site.SearchOptions)SearchWithOptions(ctx, credential, query, site.SearchOptions)The CLI asks the adapter to validate the options before the credential is read, and turns any refusal into a usage error (exit 2). Nothing is read from stdin and no request is sent. A site without the port refuses the flags, so TJUPT and the test fakes are unchanged.
The flags are defined only for
site search.site status,site accountandsite bonus-catalogreject them as undefined flags.M-Team mapping
Everything is still sent in one
POST /api/torrent/search:--pagepageNumber--modemode--categorycategories--freediscount: "FREE"With
--free, the adapter also drops any returned row whose download factor is not 0, so a filtered page can hold fewer than 50 rows.Without options, the request body is byte-for-byte the same as before.
Compatibility
pt help.--page must be 1 or moresite %q does not support --page, --mode, --category, or --freeTests
--freesendsdiscountand drops counted rows; invalid options make no request.Live check (M-Team)
I ran three read-only searches against M-Team, spaced about 6 s apart, with a throwaway HOME:
--page 2 ubuntureturned an empty page; the query has only 11 results.--free 1080preturned 50 rows, all with download factor 0.--free --page 2 1080preturned 50 new rows, none overlapping page 1, all free.The API key appeared in no output, and the temp HOME was deleted.
Docs
docs/MTEAM_ADAPTER.md: an options table.docs/guide/sites.mddocs/ADDING_A_SITE.md: the optional port.🤖 Generated with Claude Code