From 43130a2a9832c4d3861cfe8b82d392686e7c9fd6 Mon Sep 17 00:00:00 2001 From: Benex254 Date: Wed, 7 Aug 2024 18:26:58 +0300 Subject: [PATCH] feat(mpv): ensure episodes exist when changing translation type --- fastanime/cli/utils/player.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fastanime/cli/utils/player.py b/fastanime/cli/utils/player.py index fa566fa..b07798c 100644 --- a/fastanime/cli/utils/player.py +++ b/fastanime/cli/utils/player.py @@ -162,9 +162,17 @@ class MpvPlayer(object): @mpv_player.on_key_press("shift+t") def _toggle_translation_type(): - config.translation_type = ( - "sub" if config.translation_type == "dub" else "dub" + translation_type = "sub" if config.translation_type == "dub" else "dub" + anime = anime_provider.get_anime( + anilist_config._anime["id"], + anilist_config.selected_anime_anilist, ) + if not anime: + mpv_player.show_text("Failed to update translation type") + return + anilist_config.episodes = anime["availableEpisodesDetail"][translation_type] + config.translation_type = translation_type + if config.translation_type == "dub": mpv_player.show_text("Translation Type set to dub") else: