mirror of https://github.com/morpheus65535/bazarr
import JSONDecodeError from requests.exceptions instead of json
Because sometimes it will return the simplejson one instead and that one won't be caught by the except clause.
This commit is contained in:
parent
fa64309179
commit
484fe7fb4a
|
@ -3,7 +3,7 @@
|
|||
import logging
|
||||
import requests
|
||||
import datetime
|
||||
import json
|
||||
from requests.exceptions import JSONDecodeError
|
||||
|
||||
from dogpile.cache import make_region
|
||||
|
||||
|
@ -34,13 +34,13 @@ class GetRadarrInfo:
|
|||
if 'version' in radarr_json:
|
||||
radarr_version = radarr_json['version']
|
||||
else:
|
||||
raise json.decoder.JSONDecodeError
|
||||
except json.decoder.JSONDecodeError:
|
||||
raise JSONDecodeError
|
||||
except JSONDecodeError:
|
||||
try:
|
||||
rv = f"{url_radarr()}/api/v3/system/status?apikey={settings.radarr.apikey}"
|
||||
radarr_version = requests.get(rv, timeout=int(settings.radarr.http_timeout), verify=False,
|
||||
headers=headers).json()['version']
|
||||
except json.decoder.JSONDecodeError:
|
||||
except JSONDecodeError:
|
||||
logging.debug('BAZARR cannot get Radarr version')
|
||||
radarr_version = 'unknown'
|
||||
except Exception:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import logging
|
||||
import requests
|
||||
import datetime
|
||||
import json
|
||||
from requests.exceptions import JSONDecodeError
|
||||
|
||||
from dogpile.cache import make_region
|
||||
|
||||
|
@ -34,13 +34,13 @@ class GetSonarrInfo:
|
|||
if 'version' in sonarr_json:
|
||||
sonarr_version = sonarr_json['version']
|
||||
else:
|
||||
raise json.decoder.JSONDecodeError
|
||||
except json.decoder.JSONDecodeError:
|
||||
raise JSONDecodeError
|
||||
except JSONDecodeError:
|
||||
try:
|
||||
sv = f"{url_sonarr()}/api/v3/system/status?apikey={settings.sonarr.apikey}"
|
||||
sonarr_version = requests.get(sv, timeout=int(settings.sonarr.http_timeout), verify=False,
|
||||
headers=headers).json()['version']
|
||||
except json.decoder.JSONDecodeError:
|
||||
except JSONDecodeError:
|
||||
logging.debug('BAZARR cannot get Sonarr version')
|
||||
sonarr_version = 'unknown'
|
||||
except Exception:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import functools
|
||||
from json import JSONDecodeError
|
||||
from requests.exceptions import JSONDecodeError
|
||||
import logging
|
||||
import re
|
||||
import time
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import
|
||||
|
||||
from json import JSONDecodeError
|
||||
from requests.exceptions import JSONDecodeError
|
||||
import logging
|
||||
import random
|
||||
import re
|
||||
|
|
Loading…
Reference in New Issue