mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-19 05:07:51 +08:00
Added Bazarr user-agent to requests to Sonarr and Radarr
This commit is contained in:
parent
6582c1a06e
commit
a193576b63
3 changed files with 14 additions and 8 deletions
|
@ -1,5 +1,6 @@
|
|||
# coding=utf-8
|
||||
|
||||
import os
|
||||
import requests
|
||||
import logging
|
||||
from database import database, dict_converter, get_exclusion_clause
|
||||
|
@ -10,6 +11,8 @@ from list_subtitles import store_subtitles, series_full_scan_subtitles
|
|||
from get_subtitle import episode_download_subtitles
|
||||
from event_handler import event_stream
|
||||
|
||||
headers = {"User-Agent": os.environ["SZ_USER_AGENT"]}
|
||||
|
||||
|
||||
def update_all_episodes():
|
||||
series_full_scan_subtitles()
|
||||
|
@ -37,7 +40,7 @@ def sync_episodes():
|
|||
# Get episodes data for a series from Sonarr
|
||||
url_sonarr_api_episode = url_sonarr() + "/api/episode?seriesId=" + str(seriesId['sonarrSeriesId']) + "&apikey=" + apikey_sonarr
|
||||
try:
|
||||
r = requests.get(url_sonarr_api_episode, timeout=60, verify=False)
|
||||
r = requests.get(url_sonarr_api_episode, timeout=60, verify=False, headers=headers)
|
||||
r.raise_for_status()
|
||||
except requests.exceptions.HTTPError as errh:
|
||||
logging.exception("BAZARR Error trying to get episodes from Sonarr. Http error.")
|
||||
|
|
|
@ -12,6 +12,8 @@ from list_subtitles import store_subtitles_movie, movies_full_scan_subtitles
|
|||
from get_subtitle import movies_download_subtitles
|
||||
from database import database, dict_converter, get_exclusion_clause
|
||||
|
||||
headers = {"User-Agent": os.environ["SZ_USER_AGENT"]}
|
||||
|
||||
|
||||
def update_all_movies():
|
||||
movies_full_scan_subtitles()
|
||||
|
@ -45,7 +47,7 @@ def update_movies():
|
|||
url_radarr_api_movies = url_radarr() + "/api/v3/movie?apikey=" + apikey_radarr
|
||||
|
||||
try:
|
||||
r = requests.get(url_radarr_api_movies, timeout=60, verify=False)
|
||||
r = requests.get(url_radarr_api_movies, timeout=60, verify=False, headers=headers)
|
||||
r.raise_for_status()
|
||||
except requests.exceptions.HTTPError as errh:
|
||||
logging.exception("BAZARR Error trying to get movies from Radarr. Http error.")
|
||||
|
@ -288,7 +290,7 @@ def get_profile_list():
|
|||
url_radarr_api_movies = url_radarr() + "/api/v3/qualityprofile?apikey=" + apikey_radarr
|
||||
|
||||
try:
|
||||
profiles_json = requests.get(url_radarr_api_movies, timeout=60, verify=False)
|
||||
profiles_json = requests.get(url_radarr_api_movies, timeout=60, verify=False, headers=headers)
|
||||
except requests.exceptions.ConnectionError as errc:
|
||||
logging.exception("BAZARR Error trying to get profiles from Radarr. Connection Error.")
|
||||
except requests.exceptions.Timeout as errt:
|
||||
|
@ -371,7 +373,7 @@ def get_tags():
|
|||
url_sonarr_api_series = url_radarr() + "/api/tag?apikey=" + apikey_radarr
|
||||
|
||||
try:
|
||||
tagsDict = requests.get(url_sonarr_api_series, timeout=60, verify=False)
|
||||
tagsDict = requests.get(url_sonarr_api_series, timeout=60, verify=False, headers=headers)
|
||||
except requests.exceptions.ConnectionError:
|
||||
logging.exception("BAZARR Error trying to get tags from Radarr. Connection Error.")
|
||||
return []
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import os
|
||||
import requests
|
||||
import logging
|
||||
import ast
|
||||
|
||||
from config import settings, url_sonarr
|
||||
from list_subtitles import list_missing_subtitles
|
||||
|
@ -12,6 +11,8 @@ from utils import get_sonarr_version
|
|||
from helper import path_mappings
|
||||
from event_handler import event_stream
|
||||
|
||||
headers = {"User-Agent": os.environ["SZ_USER_AGENT"]}
|
||||
|
||||
|
||||
def update_series():
|
||||
apikey_sonarr = settings.sonarr.apikey
|
||||
|
@ -34,7 +35,7 @@ def update_series():
|
|||
# Get shows data from Sonarr
|
||||
url_sonarr_api_series = url_sonarr() + "/api/series?apikey=" + apikey_sonarr
|
||||
try:
|
||||
r = requests.get(url_sonarr_api_series, timeout=60, verify=False)
|
||||
r = requests.get(url_sonarr_api_series, timeout=60, verify=False, headers=headers)
|
||||
r.raise_for_status()
|
||||
except requests.exceptions.HTTPError:
|
||||
logging.exception("BAZARR Error trying to get series from Sonarr. Http error.")
|
||||
|
@ -171,7 +172,7 @@ def get_profile_list():
|
|||
url_sonarr_api_series = url_sonarr() + "/api/v3/languageprofile?apikey=" + apikey_sonarr
|
||||
|
||||
try:
|
||||
profiles_json = requests.get(url_sonarr_api_series, timeout=60, verify=False)
|
||||
profiles_json = requests.get(url_sonarr_api_series, timeout=60, verify=False, headers=headers)
|
||||
except requests.exceptions.ConnectionError:
|
||||
logging.exception("BAZARR Error trying to get profiles from Sonarr. Connection Error.")
|
||||
return None
|
||||
|
@ -209,7 +210,7 @@ def get_tags():
|
|||
url_sonarr_api_series = url_sonarr() + "/api/tag?apikey=" + apikey_sonarr
|
||||
|
||||
try:
|
||||
tagsDict = requests.get(url_sonarr_api_series, timeout=60, verify=False)
|
||||
tagsDict = requests.get(url_sonarr_api_series, timeout=60, verify=False, headers=headers)
|
||||
except requests.exceptions.ConnectionError:
|
||||
logging.exception("BAZARR Error trying to get tags from Sonarr. Connection Error.")
|
||||
return []
|
||||
|
|
Loading…
Reference in a new issue