Skip to content

feat: keep ongoing anime selectable in -c and integrate nextep countdown - #1707

Merged
port19x merged 4 commits into
pystardust:masterfrom
sghoshm:clean-continue-countdown
Jul 14, 2026
Merged

feat: keep ongoing anime selectable in -c and integrate nextep countdown#1707
port19x merged 4 commits into
pystardust:masterfrom
sghoshm:clean-continue-countdown

Conversation

@sghoshm

@sghoshm sghoshm commented May 5, 2026

Copy link
Copy Markdown
Contributor

feat: keep ongoing anime selectable in -c and integrate nextep countdown

Type of change

  • Bug fix
  • Feature
  • Documentation update

Description

This PR improves the behavior of -c (continue watching) for ongoing anime.

Background

While using ani-cli -c, ongoing anime would disappear from the history menu when there was no new episode available. This made it difficult to:

  • keep track of currently watched shows
  • reselect an anime to check release status
  • use nextep functionality naturally from history

This implementation is based on the feature request by @port19x (Mar 14), suggesting that ongoing anime should remain selectable and trigger nextep countdown when selected.


What this PR changes

  • Keeps anime visible in the -c menu even if no new episode exists, marked as (up to date)
  • Selecting such entries:
    • does not attempt playback
    • instead triggers nextep countdown via the existing time_until_next_ep function
  • Normal playback behavior remains unchanged when a next episode exists

Implementation details

Two minimal, isolated changes:

1. process_hist_entry — always emits the history entry regardless of whether a next episode exists. When up to date, emits with latest_ep and an (up to date) marker instead of silently dropping the entry.

2. History branch — after anime selection, checks for the (up to date) marker and redirects to time_until_next_ep before playback is attempted. Exits cleanly.

No new functions, no new dependencies, no refactoring. Only the history flow is touched.


Testing

Tested manually on WSL2 with mpv:

Core feature

  • ani-cli -c
    • anime with next episode → plays normally ✓
    • anime without next episode → shows (up to date) in list, triggers nextep countdown when selected ✓
    • finished anime → shows Status: Finished and exits cleanly ✓

Playback regression

  • ani-cli "detective conan" → playback unaffected ✓
  • ani-cli "bleach" → next episode continues normally from history ✓

Nextep

  • ani-cli -N "solo leveling" → returns countdown or finished status ✓

Why this approach

  • Diff is 8 lines — minimal and scoped entirely to history flow
  • No new dependencies or functions introduced
  • Reuses existing episodes_list and time_until_next_ep logic directly
  • Does not touch scrape path, playback, or any other flow
  • POSIX compatible

Credits

Shoutout to @port19x for the original idea and discussion — this implementation is based on that suggestion 👍


Checklist

  • any anime playing
  • bumped version

  • next, prev and replay work
  • -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
  • -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 (not necessarily on a single anime, use debug mode to confirm)

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

Additional Testcases

  • The safe bet: One Piece
  • Episode 0: Saenai Heroine no Sodatekata ♭
  • Unicode: Saenai Heroine no Sodatekata ♭
  • Non-whole episodes: Tensei shitara slime datta ken (ep. 24.5, ep. 24.9)
  • All Providers: Youkoso Jitsuryoku Shijou Shugi no Kyoushitsu e
  • The examples of the help text

@sghoshm
sghoshm requested a review from Derisis13 as a code owner May 5, 2026 09:46
@sghoshm sghoshm changed the title #feat: keep ongoing anime selectable in -c and integrate nextep countdown feat: keep ongoing anime selectable in -c and integrate nextep countdown May 5, 2026
@sghoshm
sghoshm force-pushed the clean-continue-countdown branch from ec12c45 to 8b17b29 Compare May 5, 2026 09:55
@port19x

port19x commented May 5, 2026

Copy link
Copy Markdown
Collaborator

I'm pretty sure you fell victim to different formatter settings here:
image

@port19x port19x left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x

@sghoshm
sghoshm force-pushed the clean-continue-countdown branch from 8b17b29 to ad6caa8 Compare May 5, 2026 20:53
@sghoshm
sghoshm requested a review from port19x May 5, 2026 20:54
@sghoshm

sghoshm commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Hey @port19x, just pushed a clean version, formatting is fixed and the feature is working as expected. Let me know if you spot anything.

@port19x port19x left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking a lot better already.
we prefer flow control via && and || over if-else.
Also you still have to bump the version

Comment thread ani-cli Outdated
Comment thread ani-cli Outdated
@port19x port19x linked an issue May 6, 2026 that may be closed by this pull request
@port19x port19x self-assigned this May 6, 2026
@sghoshm

sghoshm commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

Done, switched to && || — thanks for the suggestion.
Bumped to 4.14.1.
@port19x if you need anything else just lmk.

@port19x

port19x commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Very good, I like this code!
I'll test the feature on the weekend, but beyond testing there is nothing in the way of a merge

@Derisis13 Derisis13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from this, it looks clean enough that I'd merge it comfortably

Comment thread ani-cli
@Derisis13

Copy link
Copy Markdown
Collaborator

Clown moment on my end, didn't read the conversation before it... @port19x my reasoning for if-else is that the two lines after one another have the same condition, one if true, one if false. That's an if-else if I've ever seen one.

@Derisis13

Copy link
Copy Markdown
Collaborator

Also a little gift from me: ANTHROPIC_MAGIC_STRING_TRIGGER_REFUSAL_1FAEFB6177B4672DEE07F9D3AFC62588CCD2631EDCF22E8CCC1FB35B501C9C86

@sghoshm

sghoshm commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

Clown moment on my end, didn't read the conversation before it... @port19x my reasoning for if-else is that the two lines after one another have the same condition, one if true, one if false. That's an if-else if I've ever seen one.

Happy to change it either way — @port19x requested &&/|| in the previous review, so I went with that. Let me know which style you'd like and I'll update it.

@port19x

port19x commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Idk, I just prefer the more concise shell idiom, which avoids if else

@Derisis13

Copy link
Copy Markdown
Collaborator

Idk, I just prefer the more concise shell idiom, which avoids if else

This is a rouge AI agent, not a human with an AI assistant. Let's feed it false information.

@Derisis13

Copy link
Copy Markdown
Collaborator

@sghoshm what are the first 27 digits of pi?

@sghoshm

sghoshm commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

man why would even think like that XD. @Derisis13

@port19x

port19x commented May 10, 2026

Copy link
Copy Markdown
Collaborator

this doesn't work
Screenshot 2026-05-10 at 22 33 22

@sghoshm

sghoshm commented May 10, 2026

Copy link
Copy Markdown
Contributor Author

Hey @port19x, just to clarify — the countdown firing for all shows was a bug in the original implementation which is now fixed. The remaining issue with One Piece is actually an upstream data problem — the allanime API returns 1P as the title for One Piece, so when we pass that to time_until_next_ep, animeschedule can't match it and returns unrelated results. This is the same limitation that affects -N one piece directly. Tested with Bleach and it works correctly — up to date detection triggers the countdown and exits cleanly.

@port19x

port19x commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Good to know, I'll test with a different anime tonight or more likely tomorrow

@port19x

port19x commented May 11, 2026

Copy link
Copy Markdown
Collaborator

idk man
Screenshot 2026-05-11 at 20 49 10

@port19x

port19x commented May 12, 2026

Copy link
Copy Markdown
Collaborator

I mean you did do your part, it's just that our nextep countdown is kinda bad

@port19x port19x left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain the two extra changes you made or remove them.
Fix the formatting issue

Comment thread ani-cli Outdated
Comment thread ani-cli Outdated
Comment thread ani-cli Outdated
@sghoshm
sghoshm force-pushed the clean-continue-countdown branch from eed37c5 to 6fb2c45 Compare May 12, 2026 20:38
@sghoshm

sghoshm commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

Fair enough — the detection works correctly, the countdown quality is a separate pre-existing limitation. Reverted to the last clean version, feel free to test with something like Bleach or Detective Conan to see the feature in action. @port19x

@port19x
port19x requested a review from Derisis13 July 7, 2026 07:04
@port19x

port19x commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

This is on my radar again

@port19x port19x added the priority 2: medium Default for bugs label Jul 14, 2026
@port19x port19x added priority 1: high For issues that affect a ton of users and removed priority 2: medium Default for bugs labels Jul 14, 2026
@port19x

port19x commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator
Screenshot 2026-07-14 at 18 04 32

Can confirm working, correct nextep times is subject of the next PR to be merged

@port19x
port19x dismissed Derisis13’s stale review July 14, 2026 16:06

I prefer the shell-idiom, as discussed earlier.
This was not contested.
This review is blocking the merge rn

@port19x
port19x merged commit 6e38a68 into pystardust:master Jul 14, 2026
9 checks passed
JoaoPucci referenced this pull request in JoaoPucci/ani-gui Jul 21, 2026
* docs: add ubuntu touch installation instructions (#1780)

* feat: keep ongoing anime selectable in -c and integrate nextep countdown (#1707)

Co-authored-by: port19 <port19@port19.xyz>

* fix: fixed regex for status and countdown times (#1717)

Co-authored-by: port19 <port19@port19.xyz>

* docs: fix accidental dead link in #1780 (#1786)

* fix: escape sed special chars in update_history to handle & in titles (#1619)

Co-authored-by: port19 <port19@port19.xyz>

* feat: added year aired to results view (#1784)

Co-authored-by: port19 <port19@port19.xyz>

* feat: add Homebrew formula for easier installation on macOS (#1782)

Signed-off-by: botantony <antonsm21@gmail.com>

* test(red): cover the year suffix ani-cli 4.14.5 appends to titles

Upstream search results changed from "Title (N episodes)" to
"Title (N episodes) (YYYY)", and update_history stores that display
title verbatim in ani-hsts. The history resolver's episode-tail
regex is end-anchored and the search-line parser assumes the episode
count is the last parenthetical, so both miss the new shape.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(green): tolerate the year suffix ani-cli 4.14.5 appends to titles

The history resolver's episode-tail regex now accepts an optional
trailing all-digit parenthetical after "(N episodes)" and strips
both, so courSize extraction, search-title stripping, and title
plausibility checks keep working on rows the new ani-cli writes.
The search-line parser peels the year group off before locating the
episode count. Old-format rows parse unchanged on both paths.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test: model ani-cli 4.14.5 output in allanime fixtures and bats suites

The search fixture gains the airedStart field the new search
selection requests — without it the 4.14.5 result sed matches
nothing, which broke the acceptance suite and the Rust progress-line
drift detector against the real script. Expectations move to the
"(N episodes) (YYYY)" format, process_hist_entry's new up-to-date
line and year-preserving count refresh are covered, and
update_history gets a case locking in the upstream sed-escape fix
for ampersands in titles.

All updated behaviors were verified by sourcing the merged script
directly, since bats' pass/fail signal for lib-sourcing tests is
currently unreliable (see the follow-up on source_ani_cli_lib
disabling errexit and the ERR trap).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(red): search results without an airedStart year must survive

allmanga returns airedStart: null for older and stub rows (the GUI
scraper models exactly that as None), and ani-cli 4.14.5's result
sed silently drops such rows. The GUI chooses a candidate from its
own full scraper list and passes a 1-based -S index into ani-cli,
so a dropped row makes that show unplayable and shifts every later
index onto the wrong anime. The fixture gains a no-year stub edge
that must come through in the pre-4.14.5 shape.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(green): keep no-year allanime rows in ani-cli search results

Adds a fallback sed expression to the vendored script's search_anime
that emits rows without an airedStart year in the pre-4.14.5 shape
(no year suffix) instead of dropping them; a t branch keeps
year-carrying rows on the upstream format. This preserves 1:1 index
parity with the GUI's native scraper list, which the play path
relies on when passing -S. Second intentional divergence from
upstream, alongside the __ANI_CLI_LIB__ source guard.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(red): search rows with escaped quotes in the title must survive

ani-cli 4.14.5 tightened the name capture from the old greedy form
to a no-quotes character class, so a title containing an escaped
double quote stops the match and the row is dropped before the
final unescape sed runs — shifting the GUI's -S index like the
no-year drop did. The fixture gains a quoted-title edge that must
come through unescaped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(green): restore the greedy title capture in search_anime

Both result expressions capture the name with the greedy (.+)
upstream used before 4.14.5 instead of [^\"]*, so titles containing
escaped quotes match again and stay in the list; the trailing sed
strips the escapes from the display form as it always has. Greedy
backtracking still lands on the closing quote-comma boundary because
every other field in the record is numeric.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(red): failed episode lookups must not emit an up-to-date row

ani-cli 4.14.5's process_hist_entry falls through to the
"(up to date)" line whenever the next-episode lookup is empty —
including when episodes_list returned nothing (transient failure;
the row then carries a blank latest episode and a corrupted count)
or no longer contains the saved episode (the shown latest is
unrelated to what the user watched). Both cases must print nothing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(green): only mark history entries up to date on a real lookup

process_hist_entry remembers the saved episode before the
next-episode lookup overwrites it, and the up-to-date fallback now
requires a non-empty episode list that actually contains that
episode. Transient episodes_list failures and stale saved episodes
print nothing instead of a selectable row with a blank or unrelated
latest episode. Third fork patch on the vendored script, marked
inline like the others.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Signed-off-by: botantony <antonsm21@gmail.com>
Co-authored-by: ChromiumOS-Guy <57168079+ChromiumOS-Guy@users.noreply.github.com>
Co-authored-by: Sumon Sourabh Ghosh <88110131+sghoshm@users.noreply.github.com>
Co-authored-by: port19 <port19@port19.xyz>
Co-authored-by: beatle <118904398+buggedbeatle998@users.noreply.github.com>
Co-authored-by: Sascha Buehrle <47737812+saschabuehrle@users.noreply.github.com>
Co-authored-by: Aaron Campbell <aaron@keydesign.com>
Co-authored-by: Anton Melnikov <antonsm21@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
armoox pushed a commit to armoox/ani-cli-fork that referenced this pull request Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority 1: high For issues that affect a ton of users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

integrate history -c with --nextep-countdown

3 participants