Skip to content

feat: retain anime in -c without new episodes and show nextep countdown#1705

Closed
sghoshm wants to merge 1 commit into
pystardust:masterfrom
sghoshm:feature/continue-countdown
Closed

feat: retain anime in -c without new episodes and show nextep countdown#1705
sghoshm wants to merge 1 commit into
pystardust:masterfrom
sghoshm:feature/continue-countdown

Conversation

@sghoshm
Copy link
Copy Markdown

@sghoshm sghoshm commented May 5, 2026

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, I noticed that ongoing anime disappear from the history menu when there is no new episode available. This makes it difficult to:

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

This PR 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
  • Selecting such entries:
    • does not attempt playback
    • instead runs nextep countdown
  • Normal playback behavior is unchanged when a next episode exists

Implementation details

  • Uses episodes_list to determine if a next episode exists
  • If no next episode is found:
    • redirects flow to time_until_next_ep
  • History entries are treated as persistent instead of conditional

Additional improvements:

  • Fixes race condition in history processing (removes background execution &)
  • Replaces fragile string matching with structured history lookup using awk
  • Improves time_until_next_ep():
    • avoids silent failures
    • adds fallback when API does not return countdown data
  • Ensures POSIX compatibility (no bash-specific features)

Issues faced during development

  • Race condition in history processing
    Background execution caused inconsistent and corrupted titles

  • Title parsing issues
    Re-parsing formatted strings led to broken titles (e.g. 1P)

  • Shell compatibility
    Some constructs worked in bash but failed under /bin/sh

  • API inconsistency
    animeschedule does not always return countdown data
    → handled with fallback instead of failing silently


Testing

Tested manually across multiple flows:

Core feature

  • ani-cli -c
    • anime with next episode → plays normally
    • anime without next episode → shows nextep countdown

Playback regression

  • ani-cli one piece
  • ani-cli detective conan
    → playback unaffected

Nextep

  • ani-cli -N one piece
    → returns countdown or fallback (never empty output)

Edge cases

  • Single-entry history
  • Multiple anime in history
  • Finished anime
  • Long-running anime (e.g. One Piece)

Why this approach

  • Keeps changes minimal and scoped to history flow
  • Avoids complex matching or heuristics
  • Reuses existing logic (episodes_list, nextep)
  • Does not affect existing playback or CLI behavior

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

…emoon provider (pystardust#1691)

Co-authored-by: zen <71zenith@proton.me>
Co-authored-by: PlexTDM <tengisteka0631@gmail.com>
@port19x
Copy link
Copy Markdown
Collaborator

port19x commented May 5, 2026

What happened here that this is a PR that adds a provider on top of your own feature PR?

@sghoshm
Copy link
Copy Markdown
Author

sghoshm commented May 5, 2026

Ah, good catch... that wasn’t intentional.

I created the branch on top of a commit that already included the provider changes, so it ended up in this PR as well.

I’ll clean this up and update the PR to only include the -c / nextep integration changes.

@sghoshm sghoshm closed this May 5, 2026
@sghoshm sghoshm deleted the feature/continue-countdown branch May 5, 2026 09:49
@sghoshm
Copy link
Copy Markdown
Author

sghoshm commented May 5, 2026

Closing this PR in favor of a clean version without unrelated provider changes.

New PR: #1707

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