|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import os
|
|
|
|
|
import sqlite3
|
|
|
|
|
import requests
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
from get_general_settings import *
|
|
|
|
|
from list_subtitles import *
|
|
|
|
@ -25,8 +26,18 @@ def update_series():
|
|
|
|
|
|
|
|
|
|
# Get shows data from Sonarr
|
|
|
|
|
url_sonarr_api_series = url_sonarr + "/api/series?apikey=" + apikey_sonarr
|
|
|
|
|
r = requests.get(url_sonarr_api_series)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
r = requests.get(url_sonarr_api_series, timeout=15)
|
|
|
|
|
r.raise_for_status()
|
|
|
|
|
except requests.exceptions.HTTPError as errh:
|
|
|
|
|
logging.exception("Error trying to get series from Sonarr. Http error.")
|
|
|
|
|
except requests.exceptions.ConnectionError as errc:
|
|
|
|
|
logging.exception("Error trying to get series from Sonarr. Connection Error.")
|
|
|
|
|
except requests.exceptions.Timeout as errt:
|
|
|
|
|
logging.exception("Error trying to get series from Sonarr. Timeout Error.")
|
|
|
|
|
except requests.exceptions.RequestException as err:
|
|
|
|
|
logging.exception("Error trying to get series from Sonarr.")
|
|
|
|
|
else:
|
|
|
|
|
# Get current shows in DB
|
|
|
|
|
current_shows_db = c.execute('SELECT tvdbId FROM table_shows').fetchall()
|
|
|
|
|
current_shows_db_list = [x[0] for x in current_shows_db]
|
|
|
|
@ -80,13 +91,38 @@ def get_profile_list():
|
|
|
|
|
apikey_sonarr = get_sonarr_settings()[2]
|
|
|
|
|
|
|
|
|
|
# Get profiles data from Sonarr
|
|
|
|
|
error = False
|
|
|
|
|
|
|
|
|
|
url_sonarr_api_series = url_sonarr + "/api/profile?apikey=" + apikey_sonarr
|
|
|
|
|
profiles_json = requests.get(url_sonarr_api_series)
|
|
|
|
|
try:
|
|
|
|
|
profiles_json = requests.get(url_sonarr_api_series, timeout=15)
|
|
|
|
|
except requests.exceptions.ConnectionError as errc:
|
|
|
|
|
error = True
|
|
|
|
|
logging.exception("Error trying to get profiles from Sonarr. Connection Error.")
|
|
|
|
|
except requests.exceptions.Timeout as errt:
|
|
|
|
|
error = True
|
|
|
|
|
logging.exception("Error trying to get profiles from Sonarr. Timeout Error.")
|
|
|
|
|
except requests.exceptions.RequestException as err:
|
|
|
|
|
error = True
|
|
|
|
|
logging.exception("Error trying to get profiles from Sonarr.")
|
|
|
|
|
|
|
|
|
|
url_sonarr_api_series_v3 = url_sonarr + "/api/v3/languageprofile?apikey=" + apikey_sonarr
|
|
|
|
|
profiles_json_v3 = requests.get(url_sonarr_api_series_v3)
|
|
|
|
|
try:
|
|
|
|
|
profiles_json_v3 = requests.get(url_sonarr_api_series_v3, timeout=15)
|
|
|
|
|
except requests.exceptions.ConnectionError as errc:
|
|
|
|
|
error = True
|
|
|
|
|
logging.exception("Error trying to get profiles from Sonarr. Connection Error.")
|
|
|
|
|
except requests.exceptions.Timeout as errt:
|
|
|
|
|
error = True
|
|
|
|
|
logging.exception("Error trying to get profiles from Sonarr. Timeout Error.")
|
|
|
|
|
except requests.exceptions.RequestException as err:
|
|
|
|
|
error = True
|
|
|
|
|
logging.exception("Error trying to get profiles from Sonarr.")
|
|
|
|
|
|
|
|
|
|
global profiles_list
|
|
|
|
|
profiles_list = []
|
|
|
|
|
|
|
|
|
|
if error is False:
|
|
|
|
|
# Parsing data returned from Sonarr
|
|
|
|
|
global sonarr_version
|
|
|
|
|
if type(profiles_json_v3.json()) != list:
|
|
|
|
|