Skip to content

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

Open
sghoshm wants to merge 2 commits into
pystardust:masterfrom
sghoshm:clean-continue-countdown
Open

feat: keep ongoing anime selectable in -c and integrate nextep countdown#1707
sghoshm wants to merge 2 commits into
pystardust:masterfrom
sghoshm:clean-continue-countdown

Conversation

@sghoshm
Copy link
Copy Markdown

@sghoshm sghoshm commented May 5, 2026

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
Copy link
Copy Markdown
Collaborator

port19x commented May 5, 2026

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

Copy link
Copy Markdown
Collaborator

@port19x port19x left a comment

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
Copy link
Copy Markdown
Author

sghoshm commented May 5, 2026

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

Copy link
Copy Markdown
Collaborator

@port19x port19x left a comment

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
Copy link
Copy Markdown
Author

sghoshm commented May 6, 2026

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

@port19x
Copy link
Copy Markdown
Collaborator

port19x commented May 7, 2026

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

Copy link
Copy Markdown
Collaborator

@Derisis13 Derisis13 left a comment

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
title=$(printf "%s\n" "$title" | sed "s|[0-9]\+ episodes|${latest_ep} episodes|")
ep_no=$(printf "%s" "$ep_list" | sed -n "/^${ep_no}$/{n;p;}") 2>/dev/null
[ -n "$ep_no" ] && printf "%s\t%s - episode %s\n" "$id" "$title" "$ep_no"
[ -n "$ep_no" ] || printf "%s\t%s - episode %s (up to date)\n" "$id" "$title" "$latest_ep"
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.

If-else is preferred in this case, easier to see what's executed and when

@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
Copy link
Copy Markdown
Author

sghoshm commented May 7, 2026

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
Copy link
Copy Markdown
Collaborator

port19x commented May 7, 2026

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
Copy link
Copy Markdown
Author

sghoshm commented May 7, 2026

man why would even think like that XD. @Derisis13

@port19x
Copy link
Copy Markdown
Collaborator

port19x commented May 10, 2026

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

@sghoshm
Copy link
Copy Markdown
Author

sghoshm commented May 10, 2026

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
Copy link
Copy Markdown
Collaborator

port19x commented May 11, 2026

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

@port19x
Copy link
Copy Markdown
Collaborator

port19x commented May 11, 2026

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

@port19x
Copy link
Copy Markdown
Collaborator

port19x commented May 12, 2026

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

Copy link
Copy Markdown
Collaborator

@port19x port19x left a comment

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
ep_list=$(episodes_list "$id")
ep_no=$(printf "%s" "$anime_list" | grep "$id" | cut -f2 | sed -nE 's/.*- episode (.+)$/\1/p')
allanime_title="$(printf "%s" "$title" | cut -d'(' -f1 | tr -d '[:punct:]')"
printf "%s" "$anime_list" | grep -F "$id" | grep -q " uptodate$" && time_until_next_ep "$(printf "%s" "$title" | cut -d'(' -f1 | sed 's/ *$//')"
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.

the formatter complains about this line

@sghoshm sghoshm force-pushed the clean-continue-countdown branch from eed37c5 to 6fb2c45 Compare May 12, 2026 20:38
@sghoshm
Copy link
Copy Markdown
Author

sghoshm commented May 12, 2026

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

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.

integrate history -c with --nextep-countdown

3 participants