Skip to content

Commit 935ebc5

Browse files
committed
Remove Sonarr language profile support
1 parent 0cb2433 commit 935ebc5

File tree

3 files changed

+0
-116
lines changed

3 files changed

+0
-116
lines changed

searcharr.py

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -100,38 +100,6 @@ def __init__(self, token):
100100
)
101101
self.sonarr._quality_profiles = quality_profiles
102102

103-
language_profiles = []
104-
if not hasattr(settings, "sonarr_language_profile_id"):
105-
settings.sonarr_language_profile_id = []
106-
logger.warning(
107-
'No sonarr_language_profile_id setting detected. Please set one in settings.py if needed (e.g. sonarr_language_profile_id=["English", "German"]).'
108-
)
109-
if not isinstance(settings.sonarr_language_profile_id, list):
110-
settings.sonarr_language_profile_id = [
111-
settings.sonarr_language_profile_id
112-
]
113-
for i in settings.sonarr_language_profile_id:
114-
logger.debug(
115-
f"Looking up/validating Sonarr language profile id for [{i}]..."
116-
)
117-
foundProfile = self.sonarr.lookup_language_profile(i)
118-
if not foundProfile:
119-
logger.error(f"Sonarr language profile id/name [{i}] is invalid!")
120-
else:
121-
logger.debug(
122-
f"Found Sonarr language profile for [{i}]: [{foundProfile}]"
123-
)
124-
language_profiles.append(foundProfile)
125-
if not len(language_profiles):
126-
logger.warning(
127-
f"No valid Sonarr language profile(s) provided! Using all of the language profiles I found in Sonarr: {self.sonarr._language_profiles}"
128-
)
129-
else:
130-
logger.debug(
131-
f"Using the following Sonarr language profile(s): {[(x['id'], x['name']) for x in language_profiles]}"
132-
)
133-
self.sonarr._language_profiles = language_profiles
134-
135103
root_folders = []
136104
if not hasattr(settings, "sonarr_series_paths"):
137105
settings.sonarr_series_paths = []
@@ -1132,65 +1100,6 @@ def callback(self, update, context):
11321100
query.answer()
11331101
return
11341102

1135-
if not additional_data.get("l"):
1136-
if convo["type"] == "series":
1137-
language_profiles = self.sonarr._language_profiles
1138-
1139-
if len(language_profiles) > 1:
1140-
# prepare response to prompt user to select language profile, and return
1141-
reply_message, reply_markup = self._prepare_response(
1142-
convo["type"],
1143-
r,
1144-
cid,
1145-
i,
1146-
len(convo["results"]),
1147-
add=True,
1148-
language_profiles=language_profiles,
1149-
)
1150-
try:
1151-
query.message.edit_media(
1152-
media=InputMediaPhoto(r["remotePoster"]),
1153-
reply_markup=reply_markup,
1154-
)
1155-
except BadRequest as e:
1156-
if str(e) in self._bad_request_poster_error_messages:
1157-
logger.error(
1158-
f"Error sending photo [{r['remotePoster']}]: BadRequest: {e}. Attempting to send with default poster..."
1159-
)
1160-
query.message.edit_media(
1161-
media=InputMediaPhoto(
1162-
"https://artworks.thetvdb.com/banners/images/missing/movie.jpg"
1163-
),
1164-
reply_markup=reply_markup,
1165-
)
1166-
else:
1167-
raise
1168-
query.bot.edit_message_caption(
1169-
chat_id=query.message.chat_id,
1170-
message_id=query.message.message_id,
1171-
caption=reply_message,
1172-
reply_markup=reply_markup,
1173-
)
1174-
query.answer()
1175-
return
1176-
elif len(language_profiles) == 1:
1177-
logger.debug(
1178-
f"Only one language profile enabled. Adding/Updating additional data for cid=[{cid}], key=[q], value=[{language_profiles[0]['id']}]..."
1179-
)
1180-
self._update_add_data(cid, "l", language_profiles[0]["id"])
1181-
else:
1182-
self._delete_conversation(cid)
1183-
query.message.reply_text(
1184-
self._xlate(
1185-
"no_language_profiles",
1186-
kind=self._xlate(convo["type"]),
1187-
app="Sonarr" if convo["type"] == "series" else "Radarr",
1188-
)
1189-
)
1190-
query.message.delete()
1191-
query.answer()
1192-
return
1193-
11941103
if (
11951104
convo["type"] == "series"
11961105
and settings.sonarr_season_monitor_prompt
@@ -1535,7 +1444,6 @@ def _prepare_response(
15351444
add=False,
15361445
paths=None,
15371446
quality_profiles=None,
1538-
language_profiles=None,
15391447
metadata_profiles=None,
15401448
monitor_options=None,
15411449
tags=None,
@@ -1619,16 +1527,6 @@ def _prepare_response(
16191527
)
16201528
],
16211529
)
1622-
elif language_profiles:
1623-
for lp in language_profiles:
1624-
keyboard.append(
1625-
[
1626-
InlineKeyboardButton(
1627-
self._xlate("add_language_button", language=lp["name"]),
1628-
callback_data=f"{cid}^^^{i}^^^add^^l={lp['id']}",
1629-
)
1630-
],
1631-
)
16321530
elif metadata_profiles:
16331531
for m in metadata_profiles:
16341532
keyboard.append(

settings-sample.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
sonarr_url = "" # http://192.168.0.100:8989
2222
sonarr_api_key = ""
2323
sonarr_quality_profile_id = ["HD - 720p/1080p"] # can be name or id value - include multiple to allow the user to choose
24-
sonarr_language_profile_id = [] # e.g. ["English", "German"] - language profile names/ids from Sonarr, include multiple to allow the user to choose
2524
sonarr_add_monitored = True
2625
sonarr_search_on_add = True
2726
sonarr_tag_with_username = True

sonarr.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def __init__(self, api_url, api_key, verbose=False):
2424
)
2525
self.api_url = api_url + "/api/v3/{endpoint}?apikey=" + api_key
2626
self._quality_profiles = self.get_all_quality_profiles()
27-
self._language_profiles = self.get_all_language_profiles()
2827
self._root_folders = self.get_root_folders()
2928
self._all_series = {}
3029
self.get_all_series()
@@ -101,7 +100,6 @@ def add_series(
101100

102101
path = additional_data["p"]
103102
quality = int(additional_data["q"])
104-
language = int(additional_data["l"])
105103
monitor_options = int(additional_data.get("m", 0))
106104
if monitor_options == 1:
107105
# Monitor only the first season
@@ -132,7 +130,6 @@ def add_series(
132130
"tvdbId": series_info["tvdbId"],
133131
"title": series_info["title"],
134132
"qualityProfileId": quality,
135-
"languageProfileId": language,
136133
"titleSlug": series_info["titleSlug"],
137134
"images": series_info["images"],
138135
"seasons": series_info["seasons"],
@@ -235,19 +232,9 @@ def lookup_quality_profile(self, v):
235232
None,
236233
)
237234

238-
def lookup_language_profile(self, v):
239-
# Look up language profile from a profile name or id
240-
return next(
241-
(x for x in self._language_profiles if str(v) in [x["name"], str(x["id"])]),
242-
None,
243-
)
244-
245235
def get_all_quality_profiles(self):
246236
return self._api_get("qualityprofile", {}) or None
247237

248-
def get_all_language_profiles(self):
249-
return self._api_get("languageprofile", {}) or None
250-
251238
def lookup_root_folder(self, v):
252239
# Look up root folder from a path or id
253240
return next(

0 commit comments

Comments
 (0)