Skip to content

feat: add config file support, search pagination, and retry logic#1591

Closed
s1vrn wants to merge 3 commits intopystardust:masterfrom
s1vrn:master
Closed

feat: add config file support, search pagination, and retry logic#1591
s1vrn wants to merge 3 commits intopystardust:masterfrom
s1vrn:master

Conversation

@s1vrn
Copy link
Copy Markdown

@s1vrn s1vrn commented Jan 8, 2026

Feature request

Type of change

  • Bug fix
  • Feature
  • Documentation update

Description

Currently, ani-cli has several usability limitations that this PR addresses:

  1. Search Results: Limited to a hardcoded 40 results.
  2. Search Experience: Typos cause immediate script exit.
  3. Filler/Range Management: No support for non-contiguous episode selection (e.g., skips).

Solutions Implemented:

  1. Search Pagination: Introduced a "Next page" option in the interactive menu. If the API has more results, users can cycle through pages without re-searching.
  2. Retry Logic: Wrapped the interactive search in a loop. If a query returns no results, the user is prompted: Search again? [Y/n]. Note: This includes a [ -t 0 ] check to ensure it never hangs in non-interactive/scripted environments.
  3. Multi-Range Support: Refactored argument parsing and the play() function to allow multiple ranges. Users can now skip filler episodes using a command like ./ani-cli -e 1-5 -e 10-15 naruto.

Alternatives Considered

  • Sequential processing: Kept logic POSIX-compliant rather than adding heavy dependencies like GNU Parallel.
  • Simple limit increase: Pagination was chosen over just increasing the limit to 100 to keep the initial response fast and provide a better UX for very common search terms.

Additional context

  • sh -n ani-cli passes (Appeased the linter).
  • ani-cli -h updated with multi-range examples.
  • Multi-range logic verified using debug player on large series like "Naruto Shippuden" and "One Piece".
  • Non-interactive safety verified: Prompts are guarded by TTY checks to prevent hanging in headless scripts.

Checklist

  • any anime playing
  • bumped version

  • next, prev and replay work (verified via logic flow)
  • -c history and continue work
  • -d downloads work
  • -s syncplay works
  • -q quality works
  • -v vlc works
  • -e (select episode) aka -r (range selection) works (now supports multiple ranges)
  • -S select index works
  • --skip ani-skip works
  • --skip-title ani-skip title argument works
  • --no-detach no detach works
  • --exit-after-play auto exit after playing works
  • --nextep-countdown countdown to next ep works
  • --dub and regular (sub) mode both work
  • all providers return links (verified via dry-run)

  • -h help info is up to date
  • Readme is up to date
  • Man page is up to date

Additional Testcases

  • Multi-Range Selection: ./ani-cli -e 1-2 -e 5-6 "Naruto" -> Successfully skipped eps 3-4.
  • Empty Search: Searching for asdfghjkl -> Correctly show error and retry prompt (interactive) or exit (non-interactive).
  • Pagination: Searching for One Piece -> Correctly showed "Next page" at index 41.
  • Scripted Usage: echo "1" | ./ani-cli -e 1 "Naruto" -> Verified it selects result 1 and plays without prompting "Search again?".

@s1vrn s1vrn requested a review from Derisis13 as a code owner January 8, 2026 22:22
@Derisis13
Copy link
Copy Markdown
Collaborator

  • Config file: rejected. It's a command line app, use your *shrc to export env vars if you wish (but it's a nice implementation, just redundant)
  • pagination and search looping: how does this affect non-interactive usage? I know for a fact we used to ask for an input in a loop (v2/v3 did that IIRC), and I don't remember why it changed, but it did have a reason
  • more complex ranges: the only situation I can see this being useful is on a very slow internet connection where downloading is necessary and you can't delete the filler afterwards

All in all I'm split on the features, they aren't outright bad. There are a lot of changes (considering the size of the script), so we have to thread carefully as to not accidentally break existing workflows/functionality

@s1vrn
Copy link
Copy Markdown
Author

s1vrn commented Jan 10, 2026

Thanks for the detailed feedback! I’ve updated the code and force-pushed to address these points:

  • Config File: Removed entirely. I agree that keeping the script stateless and relying on shell environment variables is cleaner for this project.
  • Non-interactive Usage: I’ve added [ -t 0 ] checks to the search retry prompts. This ensures the script never hangs in scripted or headless environments. If it's not a real terminal, it exits on a failed search just like any other CLI tool.
  • Complex Ranges: While specific, this is a standard feature in many media CLIs (like yt-dlp). It avoids multiple script runs when grabbing specific arcs of long-running series. I’ve kept the implementation strictly POSIX-compliant to avoid any overhead.

I've also updated the help information to reflect these changes. Let me know if everything looks good on your end now!

@port19x port19x closed this Feb 28, 2026
@port19x
Copy link
Copy Markdown
Collaborator

port19x commented Feb 28, 2026

Unsalvagable imo, sorry

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.

3 participants