Skip to content

Commit

Permalink
Streamlined season selection process
Browse files Browse the repository at this point in the history
  • Loading branch information
Waterboy1602 committed Oct 16, 2024
1 parent f1d7fa4 commit f805734
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 39 deletions.
49 changes: 28 additions & 21 deletions src/addarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import logging
import re


from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
import telegram
from telegram.constants import ParseMode
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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 = []
Expand All @@ -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 = []
Expand Down
5 changes: 3 additions & 2 deletions translations/addarr.de-de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
5 changes: 3 additions & 2 deletions translations/addarr.en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
5 changes: 3 additions & 2 deletions translations/addarr.es-es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
5 changes: 3 additions & 2 deletions translations/addarr.fr-fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
5 changes: 3 additions & 2 deletions translations/addarr.it-it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
5 changes: 3 additions & 2 deletions translations/addarr.nl-be.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
5 changes: 3 additions & 2 deletions translations/addarr.pl-pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
5 changes: 3 additions & 2 deletions translations/addarr.pt-pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
5 changes: 3 additions & 2 deletions translations/addarr.ru-ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "Этот чат успешно добавлен в список разрешенных чатов. Теперь вы можете начать пользоваться этим ботом."
Expand Down

0 comments on commit f805734

Please sign in to comment.