From eb9cffbd7ac9976acb11c877aa76df5e0aa8b545 Mon Sep 17 00:00:00 2001 From: Alpha <43486986+sudoAlphaX@users.noreply.github.com> Date: Sun, 16 Mar 2025 16:06:46 +0530 Subject: [PATCH] feat: hide next episode button on reaching last episode Hides the next episode button if the currently completed episode is the last available episode on the server. Also affects auto-next feature, where it returns to media actions menu on completion of last episode. --- .../cli/interfaces/anilist_interfaces.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/fastanime/cli/interfaces/anilist_interfaces.py b/fastanime/cli/interfaces/anilist_interfaces.py index d7ebdbd..fdb977a 100644 --- a/fastanime/cli/interfaces/anilist_interfaces.py +++ b/fastanime/cli/interfaces/anilist_interfaces.py @@ -329,8 +329,14 @@ def media_player_controls( media_player_controls(config, fastanime_runtime_state) icons = config.icons - options = { - f"{'⏭ ' if icons else ''}Next Episode": _next_episode, + options = {} + + # Only show Next Episode option if the current episode is not the last one + current_index = available_episodes.index(current_episode_number) + if current_index < len(available_episodes) - 1: + options[f"{'⏭ ' if icons else ''}Next Episode"] = _next_episode + + options.update({ f"{'🔂 ' if icons else ''}Replay": _replay, f"{'⏮ ' if icons else ''}Previous Episode": _previous_episode, f"{'🗃️ ' if icons else ''}Episodes": _episodes, @@ -347,12 +353,15 @@ def media_player_controls( config, fastanime_runtime_state ), f"{'❌ ' if icons else ''}Exit": exit_app, - } + }) if config.auto_next: - print("Auto selecting next episode") - _next_episode() - return + if current_index < len(available_episodes) - 1: + print("Auto selecting next episode") + _next_episode() + return + else: + print("Last episode reached") choices = list(options.keys()) if config.use_fzf: