From f80573453f8c11100d770be83a3e1090ebec871b Mon Sep 17 00:00:00 2001 From: Wannes Date: Wed, 16 Oct 2024 15:06:10 +0200 Subject: [PATCH] Streamlined season selection process --- src/addarr.py | 49 ++++++++++++++++++++--------------- translations/addarr.de-de.yml | 5 ++-- translations/addarr.en-us.yml | 5 ++-- translations/addarr.es-es.yml | 5 ++-- translations/addarr.fr-fr.yml | 5 ++-- translations/addarr.it-it.yml | 5 ++-- translations/addarr.nl-be.yml | 5 ++-- translations/addarr.pl-pl.yml | 5 ++-- translations/addarr.pt-pt.yml | 5 ++-- translations/addarr.ru-ru.yml | 5 ++-- 10 files changed, 55 insertions(+), 39 deletions(-) diff --git a/src/addarr.py b/src/addarr.py index ffee0ba..a0ee1a3 100644 --- a/src/addarr.py +++ b/src/addarr.py @@ -3,7 +3,6 @@ import logging import re - from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update import telegram from telegram.constants import ParseMode @@ -688,19 +687,24 @@ async def selectSeasons(update, context): seasons = service.getSeasons(idnumber) seasonNumbers = [s["seasonNumber"] for s in seasons] context.user_data["seasons"] = seasonNumbers - - keyboard = [[InlineKeyboardButton(i18n.t("addarr.Future and Selected seasons"),callback_data="Season: Future and Selected")]] + selectedSeasons = [] + + keyboard = [[InlineKeyboardButton('\U0001F5D3 ' + i18n.t("addarr.Selected and future seasons"),callback_data="Season: Future and selected")]] for s in seasonNumbers: keyboard += [[ InlineKeyboardButton( - f"{i18n.t('addarr.Season')} {s}", + "\U00002705 " + f"{i18n.t('addarr.Season')} {s}", callback_data=f"Season: {s}" ), ]] - keyboard += [[InlineKeyboardButton(i18n.t("addarr.Mark all seasons"),callback_data=f"Season: All")]] + selectedSeasons.append(int(s)) + + keyboard += [[InlineKeyboardButton(i18n.t("addarr.Deselect all seasons"),callback_data=f"Season: None")]] markup = InlineKeyboardMarkup(keyboard) + context.user_data["selectedSeasons"] = selectedSeasons + await context.bot.edit_message_text( message_id=context.user_data["update_msg"], chat_id=update.effective_message.chat_id, @@ -710,25 +714,16 @@ async def selectSeasons(update, context): return SELECT_SEASONS async def checkSeasons(update, context): - - position = context.user_data["position"] choice = context.user_data["choice"] - selection_finished = False - idnumber = context.user_data["output"][position]["id"] - - service = getService(context) seasons = context.user_data["seasons"] selectedSeasons = [] if "selectedSeasons" in context.user_data: selectedSeasons = context.user_data["selectedSeasons"] if choice == i18n.t("addarr.Series"): - - # Season selection should be in the update message - if update.callback_query is not None: insertSeason = update.callback_query.data.replace("Season: ", "").strip() - if insertSeason == "Future and Selected": + if insertSeason == "Future and selected": seasonsSelected = [] for s in seasons: monitored = False @@ -750,23 +745,35 @@ async def checkSeasons(update, context): for s in seasons: if s not in selectedSeasons: selectedSeasons.append(s) + elif insertSeason == "None": + for s in seasons: + if s in selectedSeasons: + selectedSeasons.remove(s) elif int(insertSeason) not in selectedSeasons: selectedSeasons.append(int(insertSeason)) else: selectedSeasons.remove(int(insertSeason)) context.user_data["selectedSeasons"] = selectedSeasons - keyboard = [[InlineKeyboardButton(i18n.t("addarr.Future and Selected seasons"),callback_data="Season: Future and Selected")]] + keyboard = [[InlineKeyboardButton('\U0001F5D3 ' + i18n.t("addarr.Selected and future seasons"),callback_data="Season: Future and selected")]] for s in seasons: - selected = str(s) - if s in selectedSeasons: selected = str(s) + " ✅" + if s in selectedSeasons: + season = "\U00002705 " + f"{i18n.t('addarr.Season')} {s}" + else: + season = "\U00002B1C " + f"{i18n.t('addarr.Season')} {s}" + keyboard.append([ InlineKeyboardButton( - f"{i18n.t('addarr.Season')} {selected}", + season, callback_data=f"Season: {s}" ) ]) - keyboard += [[InlineKeyboardButton(i18n.t("addarr.Mark all seasons"),callback_data=f"Season: All")]] + + if len(selectedSeasons) == len(seasons): + keyboard += [[InlineKeyboardButton(i18n.t("addarr.Deselect all seasons"),callback_data=f"Season: None")]] + else: + keyboard += [[InlineKeyboardButton(i18n.t("addarr.Select all seasons"),callback_data=f"Season: All")]] + markup = InlineKeyboardMarkup(keyboard) await context.bot.edit_message_text( @@ -791,7 +798,6 @@ async def addSerieMovie(update, context): service = getService(context) if choice == i18n.t("addarr.Series"): - seasons = context.user_data["seasons"] selectedSeasons = context.user_data["selectedSeasons"] seasonsSelected = [] @@ -809,6 +815,7 @@ async def addSerieMovie(update, context): logger.debug(f"Seasons {seasonsSelected} have been selected.") qualityProfile = context.user_data["qualityProfile"] + #Add tag for user #TODO (creation does not work right now, creation should be manual) tags = [] diff --git a/translations/addarr.de-de.yml b/translations/addarr.de-de.yml index 9ab6e6e..108316a 100644 --- a/translations/addarr.de-de.yml +++ b/translations/addarr.de-de.yml @@ -19,9 +19,10 @@ de-de: Select a path: Bitte wähle ein Pfad für die Serie oder den Film Select a quality: Bitte wählen Sie ein Qualitätsprofil für den Film oder die Serie Select from which season: Seit welcher Saison? - Future and Selected seasons: Zukünftige und ausgewählte Staffeln + Selected and future seasons: Ausgewählte und zukünftige Staffeln Season: Staffel - Mark all seasons: Wähle alle Staffeln aus + Select all seasons: Alle Staffeln auswählen + Deselect all seasons: Alle Staffeln abwählen Authorize: Dieser Chat muss noch autorisiert werden. Was ist dein Passwort? Wrong password: Das Password ist nicht korrekt. Probiere es erneut... Chatid added: "Dieser Chat würde zur autorisierten liste hinzugefügt. Nun kannst du den Bot benutzen. \befehle müssen erneut ausgeführt werden." diff --git a/translations/addarr.en-us.yml b/translations/addarr.en-us.yml index 09dbb90..dd7c521 100644 --- a/translations/addarr.en-us.yml +++ b/translations/addarr.en-us.yml @@ -19,9 +19,10 @@ en-us: Select a path: Please select a path for the movie or series Select a quality: Please select a quality profile for the movie or series Select from which season: From which season? - Future and Selected seasons: Future and Selected seasons + Selected and future seasons: Selected and future seasons Season: Season - Mark all seasons: Mark all seasons + Select all seasons: Select all seasons + Deselect all seasons: Deselect all seasons Authorize: You first need to authorize this chat. What is the password? Wrong password: You entered the wrong password. Try again... Chatid added: "This chat is successfully added to the list of allowed chats. Now you can start using this bot. \nIf you entered a command, you need to execute it again." diff --git a/translations/addarr.es-es.yml b/translations/addarr.es-es.yml index b997c56..02d299b 100644 --- a/translations/addarr.es-es.yml +++ b/translations/addarr.es-es.yml @@ -19,9 +19,10 @@ es-es: Select a path: Por favor elige una ruta donde guardar Select a quality: Por favor, seleccione la calidad para la pelicula o serie Select from which season: Desde que temporada? - Future and Selected seasons: Temporadas futuras y seleccionadas + Selected and future seasons: Temporadas seleccionadas y futuras Season: Temporada - Mark all seasons: Selecciona todas las temporadas + Select all seasons: Seleccionar todas las temporadas + Deselect all seasons: Deseleccionar todas las temporadas Authorize: Necesitas autorizar este chat primero. ¿Cuál es la contraseña? Wrong password: Contraseña incorrecta. Prueba otra vez... Chatid added: "Este chat ha sido autorizado correctamente. Ya puedes utilizar el bot." diff --git a/translations/addarr.fr-fr.yml b/translations/addarr.fr-fr.yml index 74755bc..40f97cb 100644 --- a/translations/addarr.fr-fr.yml +++ b/translations/addarr.fr-fr.yml @@ -19,9 +19,10 @@ fr-fr: Select a path: Veuillez sélectionner un chemin d'accès pour le film ou la série Select a quality: Veuillez sélectionner un profil de qualité pour le film ou la série Select from which season: De quelle saison ? - Future and Selected seasons: Saisons futures et sélectionnées + Selected and future seasons: Saisons sélectionnées et futures Season: Saison - Mark all seasons: Marquer toutes les saisons + Select all seasons: Sélectionner toutes les saisons + Deselect all seasons: Désélectionner toutes les saisons Authorize: Vous devez d'abord autoriser ce chat. Quel est le mot de passe? Wrong password: Vous avez entré le mauvais mot de passe. Réessayer... Chatid added: "Ce chat a été ajouté avec succès à la liste des chats autorisés. Vous pouvez maintenant commencer à utiliser ce bot. \nSi vous avez entré une commande, vous devez l'exécuter à nouveau." diff --git a/translations/addarr.it-it.yml b/translations/addarr.it-it.yml index 0edb408..1d27e85 100644 --- a/translations/addarr.it-it.yml +++ b/translations/addarr.it-it.yml @@ -19,9 +19,10 @@ it-it: Select a path: Per favore scegli una cartella per il film o per la serie Select a quality: Per favore seleziona un profilo di qualità per il film o la serie Select from which season: Da quale stagione? - Future and Selected seasons: Stagioni future e selezionate + Selected and future seasons: Stagioni selezionate e future Season: Stagione - Mark all seasons: Seleziona tutte le stagioni + Select all seasons: Seleziona tutte le stagioni + Deselect all seasons: Deseleziona tutte le stagioni Authorize: Devi prima autenticare questa chat. Qual'è la password? Wrong password: La password è sbagliata. Riprova... Chatid added: "Questa chat è stata aggiunta alla lista delle chat autorizzate. Ora puoi utilizzare il bot. \nSe avevi inviato un comando, dovrai inviarlo di nuovo." diff --git a/translations/addarr.nl-be.yml b/translations/addarr.nl-be.yml index 3998ab3..15cc9f6 100644 --- a/translations/addarr.nl-be.yml +++ b/translations/addarr.nl-be.yml @@ -19,9 +19,10 @@ nl-be: Select a path: Kies een pad voor deze film of serie Select a quality: Kies een kwaliteitsprofiel voor de film of serie Select from which season: Vanaf welk seizoen? - Future and Selected seasons: Toekomstige en geselecteerde seizoenen + Selected and future seasons: Geselecteerde en toekomstige seizoenen Season: Seizoen - Mark all seasons: Selecteer alle seizoenen + Select all seasons: Selecteer alle seizoenen + Deselect all seasons: Deselecteer alle seizoenen Authorize: Je moet eerst deze chat toestemming geven. Wat is het wachtwoord? Wrong password: Het wachtwoord is verkeerd. Probeer opnieuw... Chatid added: "Deze chat is succesvol toegevoegd aan de lijst met toegestane chats. Nu kan je deze bot gebruiken. \nAls je een commando had ingegeven, moet je deze opnieuw uitvoeren." diff --git a/translations/addarr.pl-pl.yml b/translations/addarr.pl-pl.yml index 9f7bcaa..cbb0608 100644 --- a/translations/addarr.pl-pl.yml +++ b/translations/addarr.pl-pl.yml @@ -19,9 +19,10 @@ pl-pl: Select a path: Wybierz ścieżkę dla filmu lub serialu Select a quality: Proszę wybrać profil jakościowy dla filmu lub serialu Select from which season: Od którego sezonu? - Future and Selected seasons: Przyszłe i wybrane sezony + Selected and future seasons: Wybrane i przyszłe sezony Season: Sezon - Mark all seasons: Zaznacz wszystkie sezony + Select all seasons: Wybierz wszystkie sezony + Deselect all seasons: Odznacz wszystkie sezony Authorize: Musisz zautoryzować ten czat. Jakie jest hasło? Wrong password: Hasło nieprawidłowe. Spróbuj ponownie... Chatid added: "Ten czat został dodany do whitelisty. Teraz możesz używać tego bota." diff --git a/translations/addarr.pt-pt.yml b/translations/addarr.pt-pt.yml index b2db959..0a9b73f 100644 --- a/translations/addarr.pt-pt.yml +++ b/translations/addarr.pt-pt.yml @@ -19,9 +19,10 @@ pt-pt: Select a path: Seleccione um caminho para o filme ou série Select a quality: Por favor, seleccione um perfil de qualidade para o filme ou série Select from which season: A partir de que temporada? - Future and Selected seasons: Temporadas futuras e seleccionadas + Selected and future seasons: emporadas selecionadas e futuras Season: Temporada - Mark all seasons: Marque todas as temporadas + Select all seasons: Selecionar todas as temporadas + Deselect all seasons: Deselecionar todas as temporadas Authorize: Primeiro tem de autorizar este chat. Indique a password Wrong password: Introduziu a password errada. Tente novamente Chatid added: "Este chat foi adicionado à lista de chats autorizados. Pode agora utilizar este bot.\nSe introduziu um comando, deverá executá-lo novamente." diff --git a/translations/addarr.ru-ru.yml b/translations/addarr.ru-ru.yml index 88719fd..a760b2b 100644 --- a/translations/addarr.ru-ru.yml +++ b/translations/addarr.ru-ru.yml @@ -19,9 +19,10 @@ ru-ru: Select a path: Выбери путь для сохранения фильма или сериала Select a quality: Пожалуйста, выберите профиль качества для фильма или сериала Select from which season: Какой сезон? - Future and Selected seasons: Будущие и выбранные сезоны + Selected and future seasons: Выбранные и будущие сезоны Season: Сезон - Mark all seasons: Отметить все сезоны + Select all seasons: Выбрать все сезоны + Deselect all seasons: Снять выбор со всех сезонов Authorize: Сначала вам нужно авторизоваться. Какой пароль? Wrong password: Вы ввели неверный пароль. Попробуйте снова... Chatid added: "Этот чат успешно добавлен в список разрешенных чатов. Теперь вы можете начать пользоваться этим ботом."