From dd3b1e23a662538fb2d8ffc1a1b3463c1dc173b7 Mon Sep 17 00:00:00 2001 From: todd Date: Sun, 20 Feb 2022 16:36:28 -0500 Subject: [PATCH 01/11] feat: language translations (#31) ver: 2.1-b1 --- lang/en-us.yml | 59 ++++++++ lang/pt-br.yml | 59 ++++++++ lang/ro.yml | 59 ++++++++ requirements.txt | 1 + searcharr.py | 335 ++++++++++++++++++++++++++++++++++++--------- settings-sample.py | 4 + 6 files changed, 450 insertions(+), 67 deletions(-) create mode 100644 lang/en-us.yml create mode 100644 lang/pt-br.yml create mode 100644 lang/ro.yml diff --git a/lang/en-us.yml b/lang/en-us.yml new file mode 100644 index 0000000..0e44845 --- /dev/null +++ b/lang/en-us.yml @@ -0,0 +1,59 @@ +language_ietf: en-us +language_label: English + +movie: movie +series: series +season: season +title: title +title_here: title here +password: password +admin_password: admin password +admin_auth_success: Admin authentication successful. Use {commands} for commands. +already_authenticated: You are already authenticated. Try {commands} for usage info. +auth_successful: Authentication successful. Use {commands} for commands. +incorrect_pw: Incorrect password. +auth_required: I don't seem to know you... Please authenticate with {commands} and then try again. +admin_auth_required: You do not have admin permissions... Please authenticate with {commands} and then try again. +radarr_disabled: Sorry, but movie support is disabled. +include_movie_title_in_cmd: Please include the movie title in the command, e.g. {commands} +no_matching_movies: Îmi pare rău, dar nu am găsit nicio serie potrivită. +sonarr_disabled: Sorry, but series support is disabled. +include_series_title_in_cmd: Please include the series title in the command, e.g. {commands} +no_matching_series: Sorry, but I didn't find any matching series. +no_users_found: Sorry, but I didn't find any users. That seems wrong... +convo_not_found: I received your command, but I don't recognize the conversation. Please start again. +search_canceled: Search canceled! +no_root_folders: "Error adding {kind}: no root folders enabled for {app}! Please check your Searcharr configuration and try again." +no_quality_profiles: "Error adding {kind}: no quality profiles enabled for {app}! Please check your Searcharr configuration and try again." +all_seasons: All Seasons +first_season: First Season Only +latest_season: Latest Season Only +added: Successfully added {title}! +unknown_error_adding: Unspecified error encountered while adding {kind}! +removed_user: Successfully removed all access for user id [{user}]! +unknown_error_removing_user: Unspecified error encountered while removing user id [{user}]! +added_admin_access: Added admin access for user id [{user}]! +unknown_error_adding_admin: Unspecified error encountered while adding admin access for user id [{user}]! +removed_admin_access: Removed admin access for user id [{user}]! +unknown_error_removing_admin: Unspecified error encountered while removing admin access for user id [{user}]! +prev_button: < Prev +next_button: Next > +add_tag_button: "Add Tag: {tag}" +finished_tagging_button: Finished Tagging +monitor_button: Monitor {option} +add_quality_button: "Add Quality: {quality}" +add_path_button: Add to {path} +add_button: Add {kind}! +already_added_button: Already Added! +cancel_search_button: Cancel Search +add_series_anime_button: Add Series as Anime Type! +unexpected_error: Something went wrong! +remove_user_button: Remove +make_admin_button: Make Admin +remove_admin_button: Remove Admin +done: Done +listing_users_pagination: Listing Searcharr users {page_info}. +help_sonarr: Use {series_commands} to add a series to Sonarr. +help_radarr: Use {movie_commands} to add a movie to Radarr. +no_features: Sorry, but all of my features are currently disabled. +admin_help: Since you are an admin, you can also use {commands} to manage users. \ No newline at end of file diff --git a/lang/pt-br.yml b/lang/pt-br.yml new file mode 100644 index 0000000..a9911ae --- /dev/null +++ b/lang/pt-br.yml @@ -0,0 +1,59 @@ +language_ietf: pt-br +language_label: Brazilian Portuguese + +movie: filme +series: séries +season: temporada +title: título +title_here: título aqui +password: senha +admin_password: senha de administrador +admin_auth_success: Autenticação de admin bem-sucedida. Use {commands} para comandos. +already_authenticated: Você já está autenticado. Tente {commands} para informações de uso. +auth_successful: Autenticação bem-sucedida. Use {commands} para comandos. +incorrect_pw: Senha incorreta. +auth_required: Parece que não te conheço... Por favor, autentique com {commands} e tente novamente. +admin_auth_required: Você não tem permissões de administrador... Por favor, autentique com {commands} e tente novamente. +radarr_disabled: Desculpe, mas o suporte a filmes está desativado. +include_movie_title_in_cmd: Por favor, inclua o título do filme no comando, por exemplo. {commands} +no_matching_movies: Desculpe, mas não encontrei nenhum filme correspondente. +sonarr_disabled: Desculpe, mas o suporte da série está desativado. +include_series_title_in_cmd: Por favor, inclua o título da série no comando, por exemplo. {commands} +no_matching_series: Desculpe, mas não encontrei nenhuma série correspondente. +no_users_found: Desculpe, mas não encontrei nenhum usuário. Isso parece errado... +convo_not_found: Recebi seu comando, mas não reconheço a conversa. Por favor, comece de novo. +search_canceled: Pesquisa cancelada! +no_root_folders: "Erro ao adicionar {kind}: nenhuma pasta raiz habilitada para {app}! Verifique a configuração do Searcharr e tente novamente." +no_quality_profiles: "Erro ao adicionar {kind}: nenhum perfil de qualidade habilitado para {app}! Verifique a configuração do Searcharr e tente novamente." +all_seasons: Todas temporadas +first_season: Apenas a primeira temporada +latest_season: Apenas a última temporada +added: Adicionado com sucesso {title}! +unknown_error_adding: Erro não especificado encontrado ao adicionar {kind}! +removed_user: Todos os acessos do ID de usuário foram removidos com sucesso [{user}]! +unknown_error_removing_user: Erro não especificado encontrado ao remover o ID do usuário [{user}]! +added_admin_access: Adicionado acesso de administrador para o ID do usuário [{i}]! +unknown_error_adding_admin: Erro não especificado encontrado ao adicionar acesso de administrador para o ID do usuário [{user}]! +removed_admin_access: Acesso de administrador removido para o ID do usuário [{user}]! +unknown_error_removing_admin: Erro não especificado encontrado ao remover o acesso de administrador para o ID do usuário [{user}]! +prev_button: < Voltar +next_button: Próximo > +add_tag_button: "Add Tag: {tag}" +finished_tagging_button: Marcação concluída +monitor_button: Monitorar {option} +add_quality_button: "Add Qualidade: {quality}" +add_path_button: Add para {path} +add_button: Add {kind}! +already_added_button: Já adicionado! +cancel_search_button: Cancelar Busca +add_series_anime_button: Add Séries como tipo de anime! +unexpected_error: Algo deu errado! +remove_user_button: Remover +make_admin_button: Tornar Admin +remove_admin_button: Remover Admin +done: feito +listing_users_pagination: Listando usuários do Searcharr {page_info}. +help_sonarr: Use {series_commands} para adicionar uma série ao Sonarr. +help_radarr: Use {movie_commands} para adicionar um filme ao Radarr. +no_features: Desculpe, mas todos os meus recursos estão desativados no momento. +admin_help: Como você é um administrador, você também pode usar {commands} para gerenciar usuários. \ No newline at end of file diff --git a/lang/ro.yml b/lang/ro.yml new file mode 100644 index 0000000..fe8e543 --- /dev/null +++ b/lang/ro.yml @@ -0,0 +1,59 @@ +language_ietf: ro +language_label: Romanian + +movie: film +series: serial +season: sezon +title: titlu +title_here: titlu aici +password: parola +admin_password: parola administrator +admin_auth_success: Autentificare admin reusita. Utilizati {commands} pentru comenzi. +already_authenticated: Esti deja autentificat. Incercati {commands} pentru informatii despre utilizare. +auth_successful: Autentificare reușită. Utilizați {commands} pentru comenzi. +incorrect_pw: Parola incorecta. +auth_required: Se pare că nu sunteti autentificat... Va rugam sa va autentificati cu {commands} si apoi incercati din nou. +admin_auth_required: Nu aveți permisiuni de administrator... Vă rugăm să vă autentificați cu {commands} și apoi încercați din nou. +radarr_disabled: Scuze, dar suportul pentru filme este dezactivat. +include_movie_title_in_cmd: Vă rugăm să includeți titlul filmului în comandă, e.g. {commands} +no_matching_movies: Îmi pare rău, dar nu am găsit niciun film potrivit. +sonarr_disabled: Ne pare rău, dar suportul pentru seriale este dezactivat. +include_series_title_in_cmd: Vă rugăm să includeți titlul serialului în comandă, e.g. {commands} +no_matching_series: Îmi pare rău, dar nu am găsit nici un serial cu numele acesta. +no_users_found: Îmi pare rău, dar nu am găsit nici un utilizator. Pare greșit... +convo_not_found: Am primit comanda ta, dar nu recunosc conversația. Vă rugăm să începeți din nou. +search_canceled: Căutare anulată! +no_root_folders: "Eroare la adăugare {kind}: nu sunt activate foldere rădăcină {app}! Verificați configurația Searcharr și încercați din nou." +no_quality_profiles: "Eroare la adăugare {kind}: nu sunt activate profiluri de calitate pentru {app}! Verificați configurația Searcharr și încercați din nou." +all_seasons: Toate sezoanele +first_season: Doar primul sezon +latest_season: Numai ultimul sezon +added: Adăugat cu succes {title}! +unknown_error_adding: A apărut o eroare nespecificată la adăugare {kind}! +removed_user: S-a eliminat cu succes tot accesul pentru utilizatorul [{user}]! +unknown_error_removing_user: Eroare nespecificată întâlnită la eliminarea utilizatorului [{user}]! +added_admin_access: S-a adăugat acces de administrator pentru utilizatorul [{user}]! +unknown_error_adding_admin: A apărut o eroare nespecificată la adăugarea accesului de administrator pentru utilizatorul [{user}]! +removed_admin_access: S-a eliminat accesul de administrator pentru utilizatorul [{user}]! +unknown_error_removing_admin: A apărut o eroare nespecificată la eliminarea accesului de administrator pentru utilizatorul [{user}]! +prev_button: < Anterior +next_button: Urmatorul > +add_tag_button: "Adaugă etichetă: {tag}" +finished_tagging_button: Etichetarea terminată +monitor_button: Monitorizați {option} +add_quality_button: "Adăugați calitate: {quality}" +add_path_button: Adaugă la {path} +add_button: Adauga {kind}! +already_added_button: Deja Adaugat! +cancel_search_button: Cautare anulata +add_series_anime_button: Adăugați serialul ca desene animate! +unexpected_error: Ceva n-a mers bine! +remove_user_button: Elimina +make_admin_button: Adaugati administrator +remove_admin_button: Eliminați Admin +done: Done +listing_users_pagination: Listarea utilizatorilor Searcharr {page_info}. +help_sonarr: Foloseste {series_commands} pentru a adăuga un serial la Sonarr. +help_radarr: Foloseste {movie_commands} pentru a adăuga un film la Radarr. +no_features: Ne pare rău, dar toate funcțiile mele sunt dezactivate. +admin_help: Deoarece sunteți administrator, puteți utiliza și {commands} pentru a gestiona utilizatorii. \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 548f511..a4c09bc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ argparse requests python-telegram-bot +pyyaml diff --git a/searcharr.py b/searcharr.py index f35d72a..2b50a62 100644 --- a/searcharr.py +++ b/searcharr.py @@ -7,6 +7,7 @@ import argparse import json import os +import yaml import sqlite3 from threading import Lock from urllib.parse import parse_qsl @@ -21,7 +22,7 @@ import sonarr import settings -__version__ = "2.0" +__version__ = "2.1-b1" DBPATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data") DBFILE = "searcharr.db" @@ -61,6 +62,7 @@ def __init__(self, token): self.DEV_MODE = True if args.dev_mode else False self.token = token logger.info(f"Searcharr v{__version__} - Logging started!") + self._lang = self._load_language() self.sonarr = ( sonarr.Sonarr(settings.sonarr_url, settings.sonarr_api_key, args.verbose) if settings.sonarr_enabled @@ -264,6 +266,21 @@ def __init__(self, token): logger.warning( 'Password is blank. This will allow anyone to add series/movies using your bot. If this is unexpected, set a password in settings.py (searcharr_password="your password").' ) + if not hasattr(settings, "searcharr_start_command_aliases"): + settings.searcharr_start_command_aliases = ["start"] + logger.warning( + 'No searcharr_start_command_aliases setting found. Please add searcharr_start_command_aliases to settings.py (e.g. searcharr_start_command_aliases=["start"]. Defaulting to ["start"].' + ) + if not hasattr(settings, "searcharr_help_command_aliases"): + settings.searcharr_help_command_aliases = ["help"] + logger.warning( + 'No searcharr_help_command_aliases setting found. Please add searcharr_help_command_aliases to settings.py (e.g. searcharr_help_command_aliases=["help"]. Defaulting to ["help"].' + ) + if not hasattr(settings, "searcharr_users_command_aliases"): + settings.searcharr_users_command_aliases = ["users"] + logger.warning( + 'No searcharr_users_command_aliases setting found. Please add searcharr_users_command_aliases to settings.py (e.g. searcharr_users_command_aliases=["users"]. Defaulting to ["users"].' + ) def cmd_start(self, update, context): logger.debug(f"Received start cmd from [{update.message.from_user.username}]") @@ -275,11 +292,21 @@ def cmd_start(self, update, context): admin=1, ) update.message.reply_text( - "Admin authentication successful. Use /help for commands." + self._xlate( + "admin_auth_success", + commands=" OR ".join( + [f"`/{c}`" for c in settings.searcharr_help_command_aliases] + ), + ) ) elif self._authenticated(update.message.from_user.id): update.message.reply_text( - "You are already authenticated. Try /help for usage info." + self._xlate( + "already_authenticated", + commands=" OR ".join( + [f"`/{c}`" for c in settings.searcharr_help_command_aliases] + ), + ) ) elif password == settings.searcharr_password: self._add_user( @@ -287,25 +314,47 @@ def cmd_start(self, update, context): username=str(update.message.from_user.username), ) update.message.reply_text( - "Authentication successful. Use /help for commands." + self._xlate( + "auth_successful", + commands=" OR ".join( + [f"`/{c}`" for c in settings.searcharr_help_command_aliases] + ), + ) ) else: - update.message.reply_text("Incorrect password.") + update.message.reply_text(self._xlate("incorrect_pw")) def cmd_movie(self, update, context): logger.debug(f"Received movie cmd from [{update.message.from_user.username}]") if not self._authenticated(update.message.from_user.id): update.message.reply_text( - "I don't seem to know you... Please authenticate with `/start ` and then try again." + self._xlate( + "auth_required", + commands=" OR ".join( + [ + f"`/{c} <{self._xlate('password')}>`" + for c in settings.searcharr_start_command_aliases + ] + ), + ) ) return if not settings.radarr_enabled: - update.message.reply_text("Sorry, but movie support is disabled.") + update.message.reply_text(self._xlate("radarr_disabled")) return title = self._strip_entities(update.message) if not len(title): + x_title = self._xlate("title").title() update.message.reply_text( - f'Please include the movie title in the command, e.g. {" OR ".join([f"`/{c} Title Here`" for c in settings.radarr_movie_command_aliases])}' + self._xlate( + "include_movie_title_in_cmd", + commands=" OR ".join( + [ + f"`/{c} {x_title}`" + for c in settings.radarr_movie_command_aliases + ] + ), + ) ) return results = self.radarr.lookup_movie(title) @@ -319,7 +368,7 @@ def cmd_movie(self, update, context): ) if not len(results): - update.message.reply_text("Sorry, but I didn't find any matching movies.") + update.message.reply_text(self._xlate("no_matching_movies")) else: r = results[0] reply_message, reply_markup = self._prepare_response( @@ -350,16 +399,33 @@ def cmd_series(self, update, context): logger.debug(f"Received series cmd from [{update.message.from_user.username}]") if not self._authenticated(update.message.from_user.id): update.message.reply_text( - "I don't seem to know you... Please authenticate with `/start ` and then try again." + self._xlate( + "auth_required", + commands=" OR ".join( + [ + f"`/{c} <{self._xlate('password')}>`" + for c in settings.searcharr_start_command_aliases + ] + ), + ) ) return if not settings.sonarr_enabled: - update.message.reply_text("Sorry, but series support is disabled.") + update.message.reply_text(self._xlate("sonarr_disabled")) return title = self._strip_entities(update.message) if not len(title): + x_title = self._xlate("title").title() update.message.reply_text( - f'Please include the series title in the command, e.g. {" OR ".join([f"`/{c} Title Here`" for c in settings.sonarr_series_command_aliases])}' + self._xlate( + "include_series_title_in_cmd", + commands=" OR ".join( + [ + f"`/{c} {x_title}`" + for c in settings.sonarr_series_command_aliases + ] + ), + ) ) return results = self.sonarr.lookup_series(title) @@ -373,7 +439,7 @@ def cmd_series(self, update, context): ) if not len(results): - update.message.reply_text("Sorry, but I didn't find any matching series.") + update.message.reply_text(self._xlate("no_matching_series")) else: r = results[0] reply_message, reply_markup = self._prepare_response( @@ -405,12 +471,28 @@ def cmd_users(self, update, context): auth_level = self._authenticated(update.message.from_user.id) if not auth_level: update.message.reply_text( - "I don't seem to know you... Please authenticate with `/start ` and then try again." + self._xlate( + "auth_required", + commands=" OR ".join( + [ + f"`/{c} <{self._xlate('password')}>`" + for c in settings.searcharr_start_command_aliases + ] + ), + ) ) return elif auth_level != 2: update.message.reply_text( - "You do not have admin permissions... Please authenticate with `/start ` and then try again." + self._xlate( + "admin_auth_required", + commands=" OR ".join( + [ + f"`/{c} <{self._xlate('admin_password')}>`" + for c in settings.searcharr_start_command_aliases + ] + ), + ) ) return @@ -424,9 +506,7 @@ def cmd_users(self, update, context): results=results, ) if not len(results): - update.message.reply_text( - "Sorry, but I didn't find any users. That seems wrong..." - ) + update.message.reply_text(self._xlate("no_users_found")) else: reply_message, reply_markup = self._prepare_response_users( cid, @@ -449,7 +529,15 @@ def callback(self, update, context): auth_level = self._authenticated(query.from_user.id) if not auth_level: query.message.reply_text( - "I don't seem to know you... Please authenticate with `/start ` and then try again." + self._xlate( + "auth_required", + commands=" OR ".join( + [ + f"`/{c} <{self._xlate('password')}>`" + for c in settings.searcharr_start_command_aliases + ] + ), + ) ) query.message.delete() query.answer() @@ -462,9 +550,7 @@ def callback(self, update, context): convo = self._get_conversation(query.data.split("^^^")[0]) # convo = self.conversations.get(query.data.split("^^^")[0]) if not convo: - query.message.reply_text( - "I received your command, but I don't recognize the conversation. Please start again." - ) + query.message.reply_text(self._xlate("convo_not_found")) query.message.delete() query.answer() return @@ -484,7 +570,7 @@ def callback(self, update, context): elif op == "cancel": self._delete_conversation(cid) # self.conversations.pop(cid) - query.message.reply_text("Search canceled!") + query.message.reply_text(self._xlate("search_canceled")) query.message.delete() elif op == "done": self._delete_conversation(cid) @@ -646,7 +732,11 @@ def callback(self, update, context): else: self._delete_conversation(cid) query.message.reply_text( - f"Error adding {convo['type']}: no root folders enabled for {'Sonarr' if convo['type'] == 'series' else 'Radarr'}! Please check your Searcharr configuration and try again." + self._xlate( + "no_root_folders", + kind=self._xlate(convo["type"]), + app="Sonarr" if convo["type"] == "series" else "Radarr", + ) ) query.message.delete() query.answer() @@ -724,7 +814,11 @@ def callback(self, update, context): else: self._delete_conversation(cid) query.message.reply_text( - f"Error adding {convo['type']}: no quality profiles enabled for {'Sonarr' if convo['type'] == 'series' else 'Radarr'}! Please check your Searcharr configuration and try again." + self._xlate( + "no_quality_profiles", + kind=self._xlate(convo["type"]), + app="Sonarr" if convo["type"] == "series" else "Radarr", + ) ) query.message.delete() query.answer() @@ -737,9 +831,9 @@ def callback(self, update, context): ): # m = monitor season(s) monitor_options = [ - "All Seasons", - "First Season Only", - "Latest Season Only", + self._xlate("all_seasons"), + self._xlate("first_season"), + self._xlate("latest_season"), ] # prepare response to prompt user to select quality profile, and return reply_message, reply_markup = self._prepare_response( @@ -896,16 +990,24 @@ def callback(self, update, context): logger.debug(f"Result of attempt to add {convo['type']}: {added}") if added: self._delete_conversation(cid) - query.message.reply_text(f"Successfully added {r['title']}!") + query.message.reply_text(self._xlate("added", title=r["title"])) query.message.delete() else: query.message.reply_text( - f"Unspecified error encountered while adding {convo['type']}!" + self._xlate("unknown_error_adding", kind=convo["type"]) ) elif op == "remove_user": if auth_level != 2: query.message.reply_text( - "You do not have admin permissions... Please authenticate with `/start ` and then try again." + self._xlate( + "admin_auth_required", + commands=" OR ".join( + [ + f"`/{c} <{self._xlate('admin_password')}>`" + for c in settings.searcharr_start_command_aliases + ] + ), + ) ) query.message.delete() query.answer() @@ -934,19 +1036,26 @@ def callback(self, update, context): context.bot.edit_message_text( chat_id=query.message.chat.id, message_id=query.message.message_id, - text=f"Successfully removed all access for user id [{i}]! " - + reply_message, + text=f"{self._xlate('removed_user', user=i)} {reply_message}", reply_markup=reply_markup, ) except Exception as e: logger.error(f"Error removing all access for user id [{i}]: {e}") query.message.reply_text( - f"Unspecified error encountered while removing user id [{i}]!" + self._xlate("unknown_error_removing_user", user=i) ) elif op == "make_admin": if auth_level != 2: query.message.reply_text( - "You do not have admin permissions... Please authenticate with `/start ` and then try again." + self._xlate( + "admin_auth_required", + commands=" OR ".join( + [ + f"`/{c} <{self._xlate('admin_password')}>`" + for c in settings.searcharr_start_command_aliases + ] + ), + ) ) query.message.delete() query.answer() @@ -973,18 +1082,26 @@ def callback(self, update, context): context.bot.edit_message_text( chat_id=query.message.chat.id, message_id=query.message.message_id, - text=f"Added admin access for user id [{i}]! " + reply_message, + text=f"{self._xlate('added_admin_access', user=i)} {reply_message}", reply_markup=reply_markup, ) except Exception as e: logger.error(f"Error adding admin access for user id [{i}]: {e}") query.message.reply_text( - f"Unspecified error encountered while adding admin access for user id [{i}]!" + self._xlate("unknown_error_adding_admin", user=i) ) elif op == "remove_admin": if auth_level != 2: query.message.reply_text( - "You do not have admin permissions... Please authenticate with `/start ` and then try again." + self._xlate( + "admin_auth_required", + commands=" OR ".join( + [ + f"`/{c} <{self._xlate('admin_password')}>`" + for c in settings.searcharr_start_command_aliases + ] + ), + ) ) query.message.delete() query.answer() @@ -1011,13 +1128,13 @@ def callback(self, update, context): context.bot.edit_message_text( chat_id=query.message.chat.id, message_id=query.message.message_id, - text=f"Removed admin access for user id [{i}]! " + reply_message, + text=f"{self._xlate('removed_admin_access', user=i)} {reply_message}", reply_markup=reply_markup, ) except Exception as e: logger.error(f"Error removing admin access for user id [{i}]: {e}") query.message.reply_text( - f"Unspecified error encountered while removing admin access for user id [{i}]!" + self._xlate("unknown_error_removing_admin", user=i) ) query.answer() @@ -1039,7 +1156,9 @@ def _prepare_response( keyboardNavRow = [] if i > 0: keyboardNavRow.append( - InlineKeyboardButton("< Prev", callback_data=f"{cid}^^^{i}^^^prev") + InlineKeyboardButton( + self._xlate("prev_button"), callback_data=f"{cid}^^^{i}^^^prev" + ) ) if kind == "series" and r["tvdbId"]: keyboardNavRow.append( @@ -1061,7 +1180,9 @@ def _prepare_response( ) if total_results > 1 and i < total_results - 1: keyboardNavRow.append( - InlineKeyboardButton("Next >", callback_data=f"{cid}^^^{i}^^^next") + InlineKeyboardButton( + self._xlate("next_button"), callback_data=f"{cid}^^^{i}^^^next" + ) ) keyboard.append(keyboardNavRow) @@ -1071,7 +1192,7 @@ def _prepare_response( keyboard.append( [ InlineKeyboardButton( - f"Add Tag: {tag['label']}", + self._xlate("add_tag_button", tag=tag["label"]), callback_data=f"{cid}^^^{i}^^^add^^tt={tag['id']}", ) ], @@ -1079,7 +1200,7 @@ def _prepare_response( keyboard.append( [ InlineKeyboardButton( - "Finished Tagging", + self._xlate("finished_tagging_button"), callback_data=f"{cid}^^^{i}^^^add^^td=1", ) ], @@ -1089,7 +1210,7 @@ def _prepare_response( keyboard.append( [ InlineKeyboardButton( - f"Monitor {o}", + self._xlate("monitor_button", option=o), callback_data=f"{cid}^^^{i}^^^add^^m={k}", ) ], @@ -1099,7 +1220,7 @@ def _prepare_response( keyboard.append( [ InlineKeyboardButton( - f"Add Quality: {q['name']}", + self._xlate("add_quality_button", quality=q["name"]), callback_data=f"{cid}^^^{i}^^^add^^q={q['id']}", ) ], @@ -1109,7 +1230,7 @@ def _prepare_response( keyboard.append( [ InlineKeyboardButton( - f"Add to {p['path']}", + self._xlate("add_path_button", path=p["path"]), callback_data=f"{cid}^^^{i}^^^add^^p={p['id']}", ) ], @@ -1120,18 +1241,21 @@ def _prepare_response( if not r["id"]: keyboardActRow.append( InlineKeyboardButton( - f"Add {kind.title()}!", callback_data=f"{cid}^^^{i}^^^add" + self._xlate("add_button", kind=kind.title()), + callback_data=f"{cid}^^^{i}^^^add", ), ) else: keyboardActRow.append( InlineKeyboardButton( - "Already Added!", callback_data=f"{cid}^^^{i}^^^noop" + self._xlate("already_added_button"), + callback_data=f"{cid}^^^{i}^^^noop", ), ) keyboardActRow.append( InlineKeyboardButton( - "Cancel Search", callback_data=f"{cid}^^^{i}^^^cancel" + self._xlate("cancel_search_button"), + callback_data=f"{cid}^^^{i}^^^cancel", ), ) if len(keyboardActRow): @@ -1140,7 +1264,7 @@ def _prepare_response( keyboard.append( [ InlineKeyboardButton( - "Add Series as Anime Type!", + self._xlate("add_series_anime_button"), callback_data=f"{cid}^^^{i}^^^add^^st=a", ) ] @@ -1157,7 +1281,7 @@ def _prepare_response( 0:1024 ] else: - reply_message = "Something went wrong!" + reply_message = self._xlate("unexpected_error") return (reply_message, reply_markup) @@ -1167,14 +1291,17 @@ def _prepare_response_users(self, cid, users, offset, num, total_results): keyboard.append( [ InlineKeyboardButton( - "Remove", callback_data=f"{cid}^^^{u['id']}^^^remove_user" + self._xlate("remove_user_button"), + callback_data=f"{cid}^^^{u['id']}^^^remove_user", ), InlineKeyboardButton( f"{u['username'] if u['username'] != 'None' else u['id']}", callback_data=f"{cid}^^^{u['id']}^^^noop", ), InlineKeyboardButton( - "Remove Admin" if u["admin"] else "Make Admin", + self._xlate("remove_admin_button") + if u["admin"] + else self._xlate("make_admin_button"), callback_data=f"{cid}^^^{u['id']}^^^{'remove_admin' if u['admin'] else 'make_admin'}", ), ] @@ -1183,22 +1310,29 @@ def _prepare_response_users(self, cid, users, offset, num, total_results): if offset > 0: keyboardNavRow.append( InlineKeyboardButton( - "< Prev", callback_data=f"{cid}^^^{offset - num}^^^prev" + self._xlate("prev_button"), + callback_data=f"{cid}^^^{offset - num}^^^prev", ), ) keyboardNavRow.append( - InlineKeyboardButton("Done", callback_data=f"{cid}^^^{offset}^^^done"), + InlineKeyboardButton( + self._xlate("done"), callback_data=f"{cid}^^^{offset}^^^done" + ), ) if total_results > 1 and offset + num < total_results: keyboardNavRow.append( InlineKeyboardButton( - "Next >", callback_data=f"{cid}^^^{offset + num}^^^next" + self._xlate("next_button"), + callback_data=f"{cid}^^^{offset + num}^^^next", ), ) keyboard.append(keyboardNavRow) reply_markup = InlineKeyboardMarkup(keyboard) - reply_message = f"Listing Searcharr users {offset + 1}-{min(offset + num, total_results)} of {total_results}." + reply_message = self._xlate( + "listing_users_pagination", + page_info=f"{offset + 1}-{min(offset + num, total_results)} of {total_results}", + ) return (reply_message, reply_markup) def handle_error(self, update, context): @@ -1213,20 +1347,51 @@ def cmd_help(self, update, context): auth_level = self._authenticated(update.message.from_user.id) if not auth_level: update.message.reply_text( - "Please authenticate with `/start ` and then try again." + self._xlate( + "auth_required", + commands=" OR ".join( + [ + f"`/{c} <{self._xlate('password')}>`" + for c in settings.searcharr_start_command_aliases + ] + ), + ) ) return + sonarr_help = self._xlate( + "help_sonarr", + series_commands=" OR ".join( + [ + f"`/{c} {self._xlate('title').title()}`" + for c in settings.sonarr_series_command_aliases + ] + ), + ) + radarr_help = self._xlate( + "help_radarr", + movie_commands=" OR ".join( + [ + f"`/{c} {self._xlate('title').title()}`" + for c in settings.radarr_movie_command_aliases + ] + ), + ) if settings.sonarr_enabled and settings.radarr_enabled: - resp = f'Use {" OR ".join([f"/{c} " for c in settings.radarr_movie_command_aliases])} to add a movie to Radarr, and {" OR ".join([f"/{c} <title>" for c in settings.sonarr_series_command_aliases])} to add a series to Sonarr.' + resp = f"{sonarr_help} {radarr_help}" elif settings.sonarr_enabled: - resp = f'Use {" OR ".join([f"/{c} <title>" for c in settings.sonarr_series_command_aliases])} to add a series to Sonarr.' + resp = sonarr_help elif settings.radarr_enabled: - resp = f'Use {" OR ".join([f"/{c} <title>" for c in settings.radarr_movie_command_aliases])} to add a movie to Radarr.' + resp = radarr_help else: - resp = "Sorry, but all of my features are currently disabled." + resp = self._xlate("no_features") if auth_level == 2: - resp += " Since you are an admin, you can also use /users to manage users." + resp += " " + self._xlate( + "admin_help", + commands=" OR ".join( + [f"/{c}" for c in settings.searcharr_users_command_aliases] + ), + ) update.message.reply_text(resp) @@ -1244,15 +1409,21 @@ def run(self): self._init_db() updater = Updater(self.token, use_context=True) - updater.dispatcher.add_handler(CommandHandler("help", self.cmd_help)) - updater.dispatcher.add_handler(CommandHandler("start", self.cmd_start)) + for c in settings.searcharr_help_command_aliases: + logger.debug(f"Registering [/{c}] as a help command") + updater.dispatcher.add_handler(CommandHandler(c, self.cmd_help)) + for c in settings.searcharr_start_command_aliases: + logger.debug(f"Registering [/{c}] as a start command") + updater.dispatcher.add_handler(CommandHandler(c, self.cmd_start)) for c in settings.radarr_movie_command_aliases: logger.debug(f"Registering [/{c}] as a movie command") updater.dispatcher.add_handler(CommandHandler(c, self.cmd_movie)) for c in settings.sonarr_series_command_aliases: logger.debug(f"Registering [/{c}] as a series command") updater.dispatcher.add_handler(CommandHandler(c, self.cmd_series)) - updater.dispatcher.add_handler(CommandHandler("users", self.cmd_users)) + for c in settings.searcharr_users_command_aliases: + logger.debug(f"Registering [/{c}] as a users command") + updater.dispatcher.add_handler(CommandHandler(c, self.cmd_users)) updater.dispatcher.add_handler(CallbackQueryHandler(self.callback)) if not self.DEV_MODE: updater.dispatcher.add_error_handler(self.handle_error) @@ -1560,6 +1731,36 @@ def _init_db(self): con.commit() con.close() + def _load_language(self): + if not hasattr(settings, "searcharr_language"): + logger.warning( + "No language defined! Defaulting to en-us. Please add searcharr_language to settings.py if you want another language, where the value is a filename (without .yml) in the lang folder." + ) + settings.searcharr_language = "en-us" + logger.debug( + f"Attempting to load language file: lang/{settings.searcharr_language}.yml..." + ) + try: + with open( + f"lang/{settings.searcharr_language}.yml", mode="r", encoding="utf-8" + ) as y: + lang = yaml.load(y, Loader=yaml.SafeLoader) + except FileNotFoundError: + logger.error( + f"Error loading lang/{settings.searcharr_language}.yml. Confirm searcharr_language in settings.py has a corresponding yml file in the lang subdirectory. Using default (English) language file." + ) + with open("lang/en-us.yml", "r") as y: + lang = yaml.load(y, Loader=yaml.SafeLoader) + return lang + + def _xlate(self, key, **kwargs): + pass + if t := self._lang.get(key): + return t.format(**kwargs) + else: + logger.error(f"No translation found for key [{key}]!") + return "(translation not found)" + if __name__ == "__main__": args = parse_args() diff --git a/settings-sample.py b/settings-sample.py index 42c0969..5efa933 100644 --- a/settings-sample.py +++ b/settings-sample.py @@ -8,6 +8,10 @@ # Searcharr Bot searcharr_password = "" # Used to authenticate as a regular user to add series/movies searcharr_admin_password = "" # Used to authenticate as admin to manage users +searcharr_language = "en-us" # yml file in the lang folder +searcharr_start_command_aliases = ["start"] # Override /start command +searcharr_help_command_aliases = ["help"] # Override /help command +searcharr_users_command_aliases = ["users"] # Override /users command # Telegram tgram_token = "" From d7366fa9c347cb8d7f530c72b5b83a695896c050 Mon Sep 17 00:00:00 2001 From: todd <toddrob@gmail.com> Date: Mon, 21 Feb 2022 19:58:17 -0500 Subject: [PATCH 02/11] Add German & Spanish, update Romanian --- lang/de-de.yml | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ lang/en-us.yml | 2 +- lang/es-es.yml | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ lang/ro.yml | 12 +++++----- 4 files changed, 125 insertions(+), 7 deletions(-) create mode 100644 lang/de-de.yml create mode 100644 lang/es-es.yml diff --git a/lang/de-de.yml b/lang/de-de.yml new file mode 100644 index 0000000..7b1dff4 --- /dev/null +++ b/lang/de-de.yml @@ -0,0 +1,59 @@ +language_ietf: de-de +language_label: German + +movie: Film +series: Serie +season: Staffel +title: Title +title_here: Titel hier +password: Kennwort +admin_password: admin Kennwort +admin_auth_success: Admin Authentifizierung erfolgreich. Verwenden Sie {commands} für Befehle. +already_authenticated: Sie sind bereits authentifiziert. Versuchen Sie {commands} für Nutzungsinformationen. +auth_successful: Authentifizierung erfolgreich. Verwenden Sie {commands} für Befehle. +incorrect_pw: Falsches Kennwort. +auth_required: Ich scheine Sie nicht zu kennen... Bitte authentifizieren Sie sich mit {commands} und versuchen Sie es erneut. +admin_auth_required: Sie haben keine Administratorrechte... Bitte authentifizieren Sie sich mit {commands} und versuchen Sie es erneut. +radarr_disabled: Tut mir leid, aber die Filmunterstützung ist deaktiviert. +include_movie_title_in_cmd: Bitte geben Sie den Filmtitel in den Befehl ein, z.b. {commands} +no_matching_movies: Tut mir leid, aber ich habe keine passenden Filme gefunden. +sonarr_disabled: Tut mir leid, aber die Serienunterstützung ist deaktiviert. +include_series_title_in_cmd: Bitte geben Sie den Serientitel in den Befehl ein, z.b. {commands} +no_matching_series: Tut mir leid, aber ich habe keine passende Serie gefunden. +no_users_found: Tut mir leid, aber ich habe keine Benutzer gefunden. Das scheint falsch... +convo_not_found: Ich habe Ihren Befehl erhalten, aber ich erkenne das Gespräch nicht. Bitte neu starten. +search_canceled: Suche abgebrochen! +no_root_folders: "Fehler beim Hinzufügen {kind}: keine Root-Ordner aktiviert für {app}! Bitte überprüfen Sie Ihre Searcharr-Konfiguration und versuchen Sie es erneut." +no_quality_profiles: "Fehler beim Hinzufügen {kind}: keine Qualitätsprofile aktiviert für {app}! Bitte überprüfen Sie Ihre Searcharr-Konfiguration und versuchen Sie es erneut." +all_seasons: Alle Staffel +first_season: Nur die erste Staffel +latest_season: Nur letzte Staffel +added: Erfolgreich hinzugefügt {title}! +unknown_error_adding: Beim Hinzufügen ist ein unbekannter Fehler aufgetreten {kind}! +removed_user: Der gesamte Zugriff für die Benutzer-ID wurde erfolgreich entfernt [{user}]! +unknown_error_removing_user: Beim Entfernen der Benutzer-ID ist ein unbekannter Fehler aufgetreten [{user}]! +added_admin_access: Administratorzugriff für Benutzer-ID hinzugefügt [{user}]! +unknown_error_adding_admin: Beim Hinzufügen des Administratorzugriffs für die Benutzer-ID ist ein unbekannter Fehler aufgetreten [{user}]! +removed_admin_access: Administratorzugriff für Benutzer-ID entfernt [{user}]! +unknown_error_removing_admin: Beim Entfernen des Administratorzugriffs für die Benutzer-ID ist ein unbekannter Fehler aufgetreten [{user}]! +prev_button: < Vorher +next_button: nächste > +add_tag_button: "Etikette hinzufügen: {tag}" +finished_tagging_button: Fertiges Etikette +monitor_button: überwachen {option} +add_quality_button: "Qualität hinzufügen: {quality}" +add_path_button: Hinzufügen zu {path} +add_button: Hinzufügen {kind}! +already_added_button: Schon hinzugefügt! +cancel_search_button: Suche abbrechen +add_series_anime_button: Serie als Anime-Typ hinzufügen! +unexpected_error: Etwas ist schief gelaufen! +remove_user_button: Entfernen +make_admin_button: Administrator Machen +remove_admin_button: Administrator entfernen +done: Erledigt +listing_users_pagination: Searcharr-Benutzer auflisten {page_info}. +help_sonarr: Verwenden Sie {series_commands} um Sonarr eine Serie hinzuzufügen. +help_radarr: Verwenden Sie {movie_commands} um einen Film zu Radarr hinzuzufügen. +no_features: Tut mir leid, aber alle meine Funktionen sind derzeit deaktiviert. +admin_help: Da Sie ein Administrator sind, können Sie auch {commands} verwenden, um Benutzer zu verwalten. diff --git a/lang/en-us.yml b/lang/en-us.yml index 0e44845..826d089 100644 --- a/lang/en-us.yml +++ b/lang/en-us.yml @@ -56,4 +56,4 @@ listing_users_pagination: Listing Searcharr users {page_info}. help_sonarr: Use {series_commands} to add a series to Sonarr. help_radarr: Use {movie_commands} to add a movie to Radarr. no_features: Sorry, but all of my features are currently disabled. -admin_help: Since you are an admin, you can also use {commands} to manage users. \ No newline at end of file +admin_help: Since you are an admin, you can also use {commands} to manage users. diff --git a/lang/es-es.yml b/lang/es-es.yml new file mode 100644 index 0000000..a979830 --- /dev/null +++ b/lang/es-es.yml @@ -0,0 +1,59 @@ +language_ietf: es-es +language_label: Español + +movie: película +series: serie +season: temporada +title: título +title_here: título aquí +password: contraseña +admin_password: contraseña de administrador +admin_auth_success: La autenticación del administrador ha sido un éxito. Usa {commands} para comandos. +already_authenticated: Ya estás autenticado. Prueba {commands} para información sobre el uso. +auth_successful: Autenticación exitosa. Usa {commands} para comandos. +incorrect_pw: Contraseña incorrecta. +auth_required: Parece que no te conozco... Por favor, autentícate con {commands} e inténtalo de nuevo. +admin_auth_required: No tienes permisos de administrador... Por favor, autentícate con {commands} e inténtalo de nuevo. +radarr_disabled: Lo siento, pero el soporte para películas está desactivado. +include_movie_title_in_cmd: Por favor, incluye el título de la película en el comando, por ejemplo {commands} +no_matching_movies: Lo siento, pero no he encontrado ninguna película que cumpla el criterio de búsqueda. +sonarr_disabled: Lo siento, pero el soporte para series está desativado. +include_series_title_in_cmd: Por favor, incluye el título de la serie en el comando, por ejemplo {commands} +no_matching_series: Lo siento, no he encontrado ninguna serie que cumpla el criterio de búsqueda. +no_users_found: Lo siento, pero no he encontrado ningún usuario. Parece un error... +convo_not_found: He recibido tu comando, pero no he reconocido la conversación. Por favor, empieza de nuevo. +search_canceled: ¡Búsqueda cancelada! +no_root_folders: "¡Error añadiendo {kind}: no se han encontrado carpetas raíz para {app}! Por favor, consulta tu configuración de Searcharr e inténtalo de nuevo." +no_quality_profiles: "¡Error añadiendo {kind}: no se han encontrado perfiles de calidad activados para {app}! Por favor, consulta tu configuración de Searcharr e inténtalo de nuevo." +all_seasons: Todas las Temporadas +first_season: Sólo la Primera Temporada +latest_season: Sólo la Última Temporada +added: ¡{title} se añadió con éxito! +unknown_error_adding: ¡Error no especificado encontrado mientras se añadía {kind}! +removed_user: ¡Se ha restringido todo el acceso para el usuario id [{user}] con éxito! +unknown_error_removing_user: ¡Error no especificado al intentar borrar el usuario id [{user}]! +added_admin_access: ¡Se ha otorgado acceso de administrador al usuario id [{user}]! +unknown_error_adding_admin: ¡Error no especificado al intentar otorgar acceso de administrador al usuario id [{user}]! +removed_admin_access: ¡Se ha eliminado el acceso de administrador para el usuario id [{user}]! +unknown_error_removing_admin: ¡Error no especificado al intentar eliminar el acceso de adminstrador para el usuario id [{user}]! +prev_button: < Ant +next_button: Sig > +add_tag_button: "Añadir Etiqueta: {tag}" +finished_tagging_button: Etiquetado Finalizado +monitor_button: Monitoraje {option} +add_quality_button: "Añadir Calidad: {quality}" +add_path_button: Añadir a {path} +add_button: ¡Añadir {kind}! +already_added_button: ¡Ya Añadido! +cancel_search_button: Cancelar Búsqueda +add_series_anime_button: ¡Añadir Serie como tipo Anime! +unexpected_error: ¡Algo fue mal! +remove_user_button: Eliminar +make_admin_button: Hacer Administrador +remove_admin_button: Eliminar Administrador +done: Hecho +listing_users_pagination: Listando usuarios de Searcharr {page_info}. +help_sonarr: Usa {series_commands} para añadir serie a Sonarr. +help_radarr: Usa {movie_commands} para añadir película a Radarr. +no_features: Lo siento, pero todas mis funciones están actualmente desactivadas. +admin_help: Ya que eres administrador, también puedes usar {commands} para gestionar los usuarios. diff --git a/lang/ro.yml b/lang/ro.yml index fe8e543..8628fb8 100644 --- a/lang/ro.yml +++ b/lang/ro.yml @@ -15,10 +15,10 @@ incorrect_pw: Parola incorecta. auth_required: Se pare că nu sunteti autentificat... Va rugam sa va autentificati cu {commands} si apoi incercati din nou. admin_auth_required: Nu aveți permisiuni de administrator... Vă rugăm să vă autentificați cu {commands} și apoi încercați din nou. radarr_disabled: Scuze, dar suportul pentru filme este dezactivat. -include_movie_title_in_cmd: Vă rugăm să includeți titlul filmului în comandă, e.g. {commands} +include_movie_title_in_cmd: Vă rugăm să includeți titlul filmului în comandă, de exemplu {commands} no_matching_movies: Îmi pare rău, dar nu am găsit niciun film potrivit. sonarr_disabled: Ne pare rău, dar suportul pentru seriale este dezactivat. -include_series_title_in_cmd: Vă rugăm să includeți titlul serialului în comandă, e.g. {commands} +include_series_title_in_cmd: Vă rugăm să includeți titlul serialului în comandă, de exemplu {commands} no_matching_series: Îmi pare rău, dar nu am găsit nici un serial cu numele acesta. no_users_found: Îmi pare rău, dar nu am găsit nici un utilizator. Pare greșit... convo_not_found: Am primit comanda ta, dar nu recunosc conversația. Vă rugăm să începeți din nou. @@ -40,20 +40,20 @@ prev_button: < Anterior next_button: Urmatorul > add_tag_button: "Adaugă etichetă: {tag}" finished_tagging_button: Etichetarea terminată -monitor_button: Monitorizați {option} +monitor_button: Monitorizare {option} add_quality_button: "Adăugați calitate: {quality}" add_path_button: Adaugă la {path} add_button: Adauga {kind}! already_added_button: Deja Adaugat! cancel_search_button: Cautare anulata -add_series_anime_button: Adăugați serialul ca desene animate! +add_series_anime_button: Adăugați serialul ca anime! unexpected_error: Ceva n-a mers bine! remove_user_button: Elimina make_admin_button: Adaugati administrator remove_admin_button: Eliminați Admin -done: Done +done: Terminat listing_users_pagination: Listarea utilizatorilor Searcharr {page_info}. help_sonarr: Foloseste {series_commands} pentru a adăuga un serial la Sonarr. help_radarr: Foloseste {movie_commands} pentru a adăuga un film la Radarr. no_features: Ne pare rău, dar toate funcțiile mele sunt dezactivate. -admin_help: Deoarece sunteți administrator, puteți utiliza și {commands} pentru a gestiona utilizatorii. \ No newline at end of file +admin_help: Deoarece sunteți administrator, puteți utiliza și {commands} pentru a gestiona utilizatorii. From 02a5cd242709f48baf225bc4fe436bee244b2d59 Mon Sep 17 00:00:00 2001 From: todd <toddrob@gmail.com> Date: Mon, 21 Feb 2022 19:58:35 -0500 Subject: [PATCH 03/11] ver: 2.1-b2 --- searcharr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searcharr.py b/searcharr.py index 2b50a62..061dc19 100644 --- a/searcharr.py +++ b/searcharr.py @@ -22,7 +22,7 @@ import sonarr import settings -__version__ = "2.1-b1" +__version__ = "2.1-b2" DBPATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data") DBFILE = "searcharr.db" From dd05e87b2916946d95821a931236ca3c9e37fe1b Mon Sep 17 00:00:00 2001 From: todd <toddrob@gmail.com> Date: Mon, 21 Feb 2022 22:37:27 -0500 Subject: [PATCH 04/11] fix: error adding to radarr v3 #33 --- radarr.py | 8 ++------ sonarr.py | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/radarr.py b/radarr.py index dad27f3..c1c0431 100644 --- a/radarr.py +++ b/radarr.py @@ -101,7 +101,7 @@ def add_movie( self.logger.debug(f"Additional data: {additional_data}") path = additional_data["p"] - quality = additional_data["q"] + quality = int(additional_data["q"]) tags = additional_data.get("t", "") if len(tags): tag_ids = [int(x) for x in tags.split(",")] @@ -161,11 +161,7 @@ def get_filtered_tags(self, allowed_tags): if not r: return [] elif allowed_tags == []: - return [ - x - for x in r - if not x["label"].startswith("searcharr-") - ] + return [x for x in r if not x["label"].startswith("searcharr-")] else: return [ x diff --git a/sonarr.py b/sonarr.py index 1525999..909d245 100644 --- a/sonarr.py +++ b/sonarr.py @@ -99,7 +99,7 @@ def add_series( self.logger.debug(f"Additional data: {additional_data}") path = additional_data["p"] - quality = additional_data["q"] + quality = int(additional_data["q"]) monitor_options = int(additional_data.get("m", 0)) if monitor_options == 1: # Monitor only the first season @@ -173,11 +173,7 @@ def get_filtered_tags(self, allowed_tags): if not r: return [] elif allowed_tags == []: - return [ - x - for x in r - if not x["label"].startswith("searcharr-") - ] + return [x for x in r if not x["label"].startswith("searcharr-")] else: return [ x From 4a3f566f956a58ba2c17fac2dc356eeda8be03b5 Mon Sep 17 00:00:00 2001 From: todd <toddrob@gmail.com> Date: Mon, 21 Feb 2022 22:37:45 -0500 Subject: [PATCH 05/11] ver: 2.1-b3 --- searcharr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searcharr.py b/searcharr.py index 061dc19..e422771 100644 --- a/searcharr.py +++ b/searcharr.py @@ -22,7 +22,7 @@ import sonarr import settings -__version__ = "2.1-b2" +__version__ = "2.1-b3" DBPATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data") DBFILE = "searcharr.db" From 8470b79b788c1da442106d89acba206a7427e018 Mon Sep 17 00:00:00 2001 From: ldoctoru <68923414+ldoctoru@users.noreply.github.com> Date: Tue, 22 Feb 2022 14:28:13 +0200 Subject: [PATCH 06/11] update ro.yml corect spelling and gramma --- lang/ro.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lang/ro.yml b/lang/ro.yml index 8628fb8..e65c37f 100644 --- a/lang/ro.yml +++ b/lang/ro.yml @@ -1,11 +1,11 @@ language_ietf: ro language_label: Romanian -movie: film -series: serial -season: sezon -title: titlu -title_here: titlu aici +movie: Film +series: Serial +season: Sezon +title: Titlu +title_here: Titlu aici password: parola admin_password: parola administrator admin_auth_success: Autentificare admin reusita. Utilizati {commands} pentru comenzi. @@ -16,10 +16,10 @@ auth_required: Se pare că nu sunteti autentificat... Va rugam sa va autentifica admin_auth_required: Nu aveți permisiuni de administrator... Vă rugăm să vă autentificați cu {commands} și apoi încercați din nou. radarr_disabled: Scuze, dar suportul pentru filme este dezactivat. include_movie_title_in_cmd: Vă rugăm să includeți titlul filmului în comandă, de exemplu {commands} -no_matching_movies: Îmi pare rău, dar nu am găsit niciun film potrivit. +no_matching_movies: Îmi pare rău, dar nu am găsit niciun film cu titlu acesta. sonarr_disabled: Ne pare rău, dar suportul pentru seriale este dezactivat. include_series_title_in_cmd: Vă rugăm să includeți titlul serialului în comandă, de exemplu {commands} -no_matching_series: Îmi pare rău, dar nu am găsit nici un serial cu numele acesta. +no_matching_series: Îmi pare rău, dar nu am găsit nici un serial cu titlul acesta. no_users_found: Îmi pare rău, dar nu am găsit nici un utilizator. Pare greșit... convo_not_found: Am primit comanda ta, dar nu recunosc conversația. Vă rugăm să începeți din nou. search_canceled: Căutare anulată! @@ -45,7 +45,7 @@ add_quality_button: "Adăugați calitate: {quality}" add_path_button: Adaugă la {path} add_button: Adauga {kind}! already_added_button: Deja Adaugat! -cancel_search_button: Cautare anulata +cancel_search_button: Anulaţi Cautarea add_series_anime_button: Adăugați serialul ca anime! unexpected_error: Ceva n-a mers bine! remove_user_button: Elimina From d5c2a04529e362533f85963add20b7a3cf22ff7e Mon Sep 17 00:00:00 2001 From: Todd Roberts <toddrob99@users.noreply.github.com> Date: Tue, 22 Feb 2022 09:35:28 -0500 Subject: [PATCH 07/11] Update ro.yml --- lang/ro.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lang/ro.yml b/lang/ro.yml index e65c37f..573a7cd 100644 --- a/lang/ro.yml +++ b/lang/ro.yml @@ -1,11 +1,11 @@ language_ietf: ro language_label: Romanian -movie: Film -series: Serial -season: Sezon -title: Titlu -title_here: Titlu aici +movie: film +series: serial +season: sezon +title: titlu +title_here: titlu aici password: parola admin_password: parola administrator admin_auth_success: Autentificare admin reusita. Utilizati {commands} pentru comenzi. From ca6a8849a91fc5fa3711f97eb8bd2359adf3a2d9 Mon Sep 17 00:00:00 2001 From: todd <toddrob@gmail.com> Date: Tue, 22 Feb 2022 09:43:57 -0500 Subject: [PATCH 08/11] fix: series/movie not translated in add button --- searcharr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searcharr.py b/searcharr.py index e422771..030dd3b 100644 --- a/searcharr.py +++ b/searcharr.py @@ -1241,7 +1241,7 @@ def _prepare_response( if not r["id"]: keyboardActRow.append( InlineKeyboardButton( - self._xlate("add_button", kind=kind.title()), + self._xlate("add_button", kind=self._xlate(kind).title()), callback_data=f"{cid}^^^{i}^^^add", ), ) From dd64857b4005422959d05652de01fe63bb25d4c6 Mon Sep 17 00:00:00 2001 From: todd <toddrob@gmail.com> Date: Tue, 22 Feb 2022 09:44:14 -0500 Subject: [PATCH 09/11] ver: 2.1-b4 --- searcharr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searcharr.py b/searcharr.py index 030dd3b..d0f3227 100644 --- a/searcharr.py +++ b/searcharr.py @@ -22,7 +22,7 @@ import sonarr import settings -__version__ = "2.1-b3" +__version__ = "2.1-b4" DBPATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data") DBFILE = "searcharr.db" From 5176c92f60764e14b0fa2f3e3d641e632afd6347 Mon Sep 17 00:00:00 2001 From: todd <toddrob@gmail.com> Date: Wed, 2 Mar 2022 16:56:00 -0500 Subject: [PATCH 10/11] feat: Catalan translations --- lang/ca-es.yml | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lang/ca-es.yml diff --git a/lang/ca-es.yml b/lang/ca-es.yml new file mode 100644 index 0000000..d6f6442 --- /dev/null +++ b/lang/ca-es.yml @@ -0,0 +1,59 @@ +language_ietf: ca-es +language_label: Català + +movie: pel·lícula +series: sèrie +season: temporada +title: títol +title_here: títol aquí +password: contrasenya +admin_password: contrasenya d'administrador +admin_auth_success: Autenticació d'administrador correcta. Utilitza {commands} per ordres. +already_authenticated: Ja estàs autenticat. Prova {commands} per informació d'ús. +auth_successful: Autenticació correcta. Utilitza {commands} per ordres. +incorrect_pw: Contrasenya incorrecta. +auth_required: Sembla que no et conec... Sisplau, autentica't amb {commands} i torna a intentar-ho. +admin_auth_required: No tens permís d'administrador... Sisplau, autentica't amb {commands} i torna a intentar-ho. +radarr_disabled: Ho sento, però el suport per pel·lícules està desactivat. +include_movie_title_in_cmd: Sisplau, inclou el títol de la pel·lícula en la ordre, per exemple {commands} +no_matching_movies: Ho sento, però no he trobat cap pel·lícula que compleixi el criteri de cerca. +sonarr_disabled: Ho sento, però el suport per sèries està desactivat. +include_series_title_in_cmd: Sisplau, inclou el títol de la sèrie en la ordre, per exemple {commands} +no_matching_series: Ho sento, però no he trobat cap sèrie que compleixi el criteri de cerca. +no_users_found: Ho sento, però no he trobat cap usuari. Sembla estrany... +convo_not_found: He rebut la teva ordre, però no reconec la conversa. Sisplau, comença de nou. +search_canceled: Cerca cancel·lada! +no_root_folders: "Error afegint {kind}: no hi han carpetes arrel per {app}! Sisplau, comprova la teva configuració de Searcharr i torna a intentar-ho." +no_quality_profiles: "Error afegint {kind}: no hi han perfils de qualitat activats per {app}! Sisplau, comprova la teva configuració de Searcharr i torna a intentar-ho." +all_seasons: Totes les Temporades +first_season: Només la Primera Temporada +latest_season: Només la Última Temporada +added: S'ha afegit {title} correctament! +unknown_error_adding: Error no especificat trobat en intentar afegir {kind}! +removed_user: S'ha restringit tot accés per l'usuari amb id [{user}] correctament! +unknown_error_removing_user: Error no especificat trobat en intentar eliminar l'usuari amb id [{user}]! +added_admin_access: S'ha otorgat accés d'administrador per l'usuari [{user}]! +unknown_error_adding_admin: Error no especificat trobat en intentar otorgar accés d'administrador per l'usuari amb id [{user}]! +removed_admin_access: S'ha eliminat l'accés d'administrador per l'usuari amb id [{user}] correctament! +unknown_error_removing_admin: Error no especificat trobat en intentar eliminar l'accés d'administrador per l'usuari amb id [{user}]! +prev_button: < Prev +next_button: Seg > +add_tag_button: "Afegir Etiqueta: {tag}" +finished_tagging_button: Etiquetat Completat +monitor_button: Monitoratge {option} +add_quality_button: "Afegir Qualitat: {quality}" +add_path_button: Afegir a {path} +add_button: "{kind} afegit!" +already_added_button: "Ja Afegit!" +cancel_search_button: Cancel·lar Cerca +add_series_anime_button: Afegir Sèrie en tipus Anime! +unexpected_error: Alguna cosa ha anat malament! +remove_user_button: Eliminar +make_admin_button: Fer Administrador +remove_admin_button: Eliminar Administrador +done: Fet +listing_users_pagination: Enumerant usuaris de Searcharr {page_info}. +help_sonarr: Utilitza {series_commands} per afegir una sèrie a Sonarr. +help_radarr: Utilitza {movie_commands} per afegir una pel·lícula a Radarr. +no_features: Ho sento, però totes les meves funcions estàn desactivades temporalment. +admin_help: Com que ets administrador, també pots utilitzar {commands} per gestionar els usuaris. From 012fb0c60b1eac5183d0fbb4e2f4acbf1d012101 Mon Sep 17 00:00:00 2001 From: todd <toddrob@gmail.com> Date: Wed, 2 Mar 2022 16:56:19 -0500 Subject: [PATCH 11/11] ver: 2.1 --- searcharr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searcharr.py b/searcharr.py index d0f3227..7857895 100644 --- a/searcharr.py +++ b/searcharr.py @@ -22,7 +22,7 @@ import sonarr import settings -__version__ = "2.1-b4" +__version__ = "2.1" DBPATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data") DBFILE = "searcharr.db"