mirror of
https://github.com/Benexl/FastAnime.git
synced 2026-02-04 11:07:48 -08:00
Merge branch 'sudoAlphaX-main-menu-on-blacnk-search'
This commit is contained in:
@@ -329,30 +329,56 @@ def media_player_controls(
|
||||
media_player_controls(config, fastanime_runtime_state)
|
||||
|
||||
icons = config.icons
|
||||
options = {
|
||||
f"{'⏭ ' if icons else ''}Next Episode": _next_episode,
|
||||
f"{'🔂 ' if icons else ''}Replay": _replay,
|
||||
f"{'⏮ ' if icons else ''}Previous Episode": _previous_episode,
|
||||
f"{'🗃️ ' if icons else ''}Episodes": _episodes,
|
||||
f"{'📀 ' if icons else ''}Change Quality": _change_quality,
|
||||
f"{'🎧 ' if icons else ''}Change Translation Type": _change_translation_type,
|
||||
f"{'💽 ' if icons else ''}Servers": _servers,
|
||||
f"{'📱 ' if icons else ''}Main Menu": lambda: fastanime_main_menu(
|
||||
config, fastanime_runtime_state
|
||||
),
|
||||
f"{'📜 ' if icons else ''}Media Actions Menu": lambda: media_actions_menu(
|
||||
config, fastanime_runtime_state
|
||||
),
|
||||
f"{'🔎 ' if icons else ''}Anilist Results Menu": lambda: anilist_results_menu(
|
||||
config, fastanime_runtime_state
|
||||
),
|
||||
f"{'❌ ' if icons else ''}Exit": exit_app,
|
||||
}
|
||||
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
|
||||
|
||||
def _toggle_auto_next(
|
||||
config: "Config", fastanime_runtime_state: "FastAnimeRuntimeState"
|
||||
):
|
||||
"""helper function to toggle auto next
|
||||
|
||||
Args:
|
||||
config: [TODO:description]
|
||||
fastanime_runtime_state: [TODO:description]
|
||||
"""
|
||||
config.auto_next = not config.auto_next
|
||||
media_player_controls(config, fastanime_runtime_state)
|
||||
|
||||
options.update(
|
||||
{
|
||||
f"{'🔂 ' if icons else ''}Replay": _replay,
|
||||
f"{'⏮ ' if icons else ''}Previous Episode": _previous_episode,
|
||||
f"{'🗃️ ' if icons else ''}Episodes": _episodes,
|
||||
f"{'📀 ' if icons else ''}Change Quality": _change_quality,
|
||||
f"{'🎧 ' if icons else ''}Change Translation Type": _change_translation_type,
|
||||
f"{'💠 ' if icons else ''}Toggle auto next episode": lambda: _toggle_auto_next(
|
||||
config, fastanime_runtime_state
|
||||
),
|
||||
f"{'💽 ' if icons else ''}Servers": _servers,
|
||||
f"{'📱 ' if icons else ''}Main Menu": lambda: fastanime_main_menu(
|
||||
config, fastanime_runtime_state
|
||||
),
|
||||
f"{'📜 ' if icons else ''}Media Actions Menu": lambda: media_actions_menu(
|
||||
config, fastanime_runtime_state
|
||||
),
|
||||
f"{'🔎 ' if icons else ''}Anilist Results Menu": lambda: anilist_results_menu(
|
||||
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:
|
||||
@@ -1916,6 +1942,10 @@ def _anilist_search(config: "Config", page=1):
|
||||
else:
|
||||
search_term = Prompt.ask("[cyan]Search for[/]")
|
||||
|
||||
# Return to main menu if search term is empty
|
||||
if not search_term.strip():
|
||||
return False, "Search canceled - return to main menu"
|
||||
|
||||
return AniList.search(query=search_term, page=page)
|
||||
|
||||
|
||||
@@ -1989,34 +2019,22 @@ def fastanime_main_menu(
|
||||
options = {
|
||||
f"{'🔥 ' if icons else ''}Trending": AniList.get_trending,
|
||||
f"{'🎞️ ' if icons else ''}Recent": _recent,
|
||||
f"{'📺 ' if icons else ''}Watching": lambda config,
|
||||
media_list_type="Watching",
|
||||
page=1: _handle_animelist(
|
||||
f"{'📺 ' if icons else ''}Watching": lambda config, media_list_type="Watching", page=1: _handle_animelist(
|
||||
config, fastanime_runtime_state, media_list_type, page=page
|
||||
),
|
||||
f"{'⏸ ' if icons else ''}Paused": lambda config,
|
||||
media_list_type="Paused",
|
||||
page=1: _handle_animelist(
|
||||
f"{'⏸ ' if icons else ''}Paused": lambda config, media_list_type="Paused", page=1: _handle_animelist(
|
||||
config, fastanime_runtime_state, media_list_type, page=page
|
||||
),
|
||||
f"{'🚮 ' if icons else ''}Dropped": lambda config,
|
||||
media_list_type="Dropped",
|
||||
page=1: _handle_animelist(
|
||||
f"{'🚮 ' if icons else ''}Dropped": lambda config, media_list_type="Dropped", page=1: _handle_animelist(
|
||||
config, fastanime_runtime_state, media_list_type, page=page
|
||||
),
|
||||
f"{'📑 ' if icons else ''}Planned": lambda config,
|
||||
media_list_type="Planned",
|
||||
page=1: _handle_animelist(
|
||||
f"{'📑 ' if icons else ''}Planned": lambda config, media_list_type="Planned", page=1: _handle_animelist(
|
||||
config, fastanime_runtime_state, media_list_type, page=page
|
||||
),
|
||||
f"{'✅ ' if icons else ''}Completed": lambda config,
|
||||
media_list_type="Completed",
|
||||
page=1: _handle_animelist(
|
||||
f"{'✅ ' if icons else ''}Completed": lambda config, media_list_type="Completed", page=1: _handle_animelist(
|
||||
config, fastanime_runtime_state, media_list_type, page=page
|
||||
),
|
||||
f"{'🔁 ' if icons else ''}Rewatching": lambda config,
|
||||
media_list_type="Rewatching",
|
||||
page=1: _handle_animelist(
|
||||
f"{'🔁 ' if icons else ''}Rewatching": lambda config, media_list_type="Rewatching", page=1: _handle_animelist(
|
||||
config, fastanime_runtime_state, media_list_type, page=page
|
||||
),
|
||||
f"{'🔔 ' if icons else ''}Recently Updated Anime": AniList.get_most_recently_updated,
|
||||
|
||||
Reference in New Issue
Block a user