Skip to content

Add search paging, mode, category, and free filters (M-Team) - #30

Merged
tonycoder-hub merged 1 commit into
mainfrom
feat/mteam-search-options
Oct 16, 2026
Merged

tonycoder-hub merged 1 commit into
mainfrom
feat/mteam-search-options

Conversation

@tonycoder-hub

Copy link
Copy Markdown
Owner

Summary

site search used 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 to TorrentSearcher. 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 account and site bonus-catalog reject them as undefined flags.

M-Team mapping

Everything is still sent in one POST /api/torrent/search:

Option Request field
--page pageNumber
--mode mode
--category categories
--free discount: "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

  • New flags, and a new usage line in pt help.
  • New usage errors:
    • --page must be 1 or more
    • site %q does not support --page, --mode, --category, or --free
    • the adapter's validation messages
  • JSON, the table layout, exit codes, route IDs and origins are unchanged.

Tests

  • Adapter: the options are sent in one request; --free sends discount and drops counted rows; invalid options make no request.
  • CLI:
    • options reach the port, and the plain search runs when no options are given;
    • refusals happen before stdin is read;
    • the flags are rejected on non-search commands.

Live check (M-Team)

I ran three read-only searches against M-Team, spaced about 6 s apart, with a throwaway HOME:

  • --page 2 ubuntu returned an empty page; the query has only 11 results.
  • --free 1080p returned 50 rows, all with download factor 0.
  • --free --page 2 1080p returned 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.md
  • docs/ADDING_A_SITE.md: the optional port.

🤖 Generated with Claude Code

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>
@tonycoder-hub
tonycoder-hub merged commit f8f6f9d into main Oct 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant