Commit eb54e81c authored by echel0n's avatar echel0n

Fixed issue with scene_season being non-integer

Fixed issue #SICKRAGE-APP-5TZ - NoResultFound exception not handled in get_indexer_absolute_numbering function, not returns -1 when exception is thrown
Fixed issue #SICKRAGE-APP-5YH - FakeUserAgentError exception not handled when attempting to get a random user agent string for core web sessions, now returns default SR user agent string if exception is thrown
Fixed issue #SICKRAGE-APP-5XV - NoneType possibly returned when getting season/episode numbering from episode object due to improper comparison
Fixed issue #SICKRAGE-APP-5XE - AttributeError occurrence when trying to split show scene exceptions data by delimiter if previously never set
Fixed issue #SICKRAGE-APP-5ZS - TypeError thrown due to episode status being set as a string instead of a integer
parent 735f9005
......@@ -133,9 +133,10 @@ def get_indexer_absolute_numbering(indexer_id, indexer, scene_absolute_number, f
scene_season=scene_season
).one()
return dbData.absolute_number
except orm.exc.MultipleResultsFound:
except (orm.exc.MultipleResultsFound, orm.exc.NoResultFound):
if fallback_to_xem:
return get_indexer_absolute_numbering_from_xem_numbering(indexer_id, indexer, scene_absolute_number, scene_season)
return -1
......@@ -184,7 +185,7 @@ def get_indexer_absolute_numbering_from_xem_numbering(indexer_id, indexer, xem_a
xem_absolute_number=xem_absolute_number,
xem_season=xem_season).one()
return dbData.absolute_number
except (orm.exc.NoResultFound, orm.exc.MultipleResultsFound):
except (orm.exc.MultipleResultsFound, orm.exc.NoResultFound):
return -1
......@@ -316,9 +317,7 @@ def find_scene_absolute_numbering(indexer_id, indexer, absolute_number):
).filter(MainDB.TVEpisode.scene_absolute_number != -1).one()
return dbData.scene_absolute_number
except orm.exc.MultipleResultsFound:
return
except orm.exc.NoResultFound:
except (orm.exc.MultipleResultsFound, orm.exc.NoResultFound):
return
......
......@@ -509,8 +509,7 @@ class TVEpisode(object):
if self.location:
sickrage.app.log.debug("%s: Setting status for S%02dE%02d based on status %s and location %s" %
(self.show.indexer_id, season or 0, episode or 0, statusStrings[self.status],
self.location))
(self.show.indexer_id, season or 0, episode or 0, statusStrings[self.status], self.location))
if not os.path.isfile(self.location):
if self.airdate >= datetime.date.today() or not self.airdate > datetime.date.min:
......@@ -1271,9 +1270,9 @@ class TVEpisode(object):
return True
def get_season_episode_numbering(self):
if self.show.scene and self.scene_season != -1 and self.scene_episode != -1:
if self.show.scene and self.scene_season not in [-1, None] and self.scene_episode not in [-1, None]:
return self.scene_season, self.scene_episode
elif self.show.scene and self.xem_season != -1 and self.xem_episode != -1:
elif self.show.scene and self.xem_season not in [-1, None] and self.xem_episode not in [-1, None]:
return self.xem_season, self.xem_season
else:
return self.season, self.episode
......
......@@ -305,7 +305,9 @@ class TVShow(object):
@property
def scene_exceptions(self):
return list(filter(None, self._data_local['scene_exceptions'].split(',')))
if self._data_local['scene_exceptions']:
return list(filter(None, self._data_local['scene_exceptions'].split(',')))
return []
@scene_exceptions.setter
def scene_exceptions(self, value):
......@@ -1356,7 +1358,8 @@ class TVShow(object):
def get_scene_exception_by_name(self, exception_name):
for x in self.scene_exceptions:
if exception_name in x:
return x.split('|')
scene_name, scene_season = x.split('|')
return scene_name, int(scene_season)
def get_scene_exceptions_by_season(self, season=-1):
scene_exceptions = []
......
......@@ -894,7 +894,7 @@ class CMD_EpisodeSetStatus(ApiCall):
failure = True
continue
epObj.status = self.status
epObj.status = int(self.status)
epObj.save()
if self.status == WANTED:
......
......@@ -19,17 +19,17 @@
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
import collections
import errno
import os
import traceback
from time import sleep
from urllib.parse import urlparse
import certifi
import errno
import requests
from cachecontrol import CacheControlAdapter
from cloudscraper import CloudScraper
from fake_useragent import UserAgent
from fake_useragent import UserAgent, FakeUserAgentError
from requests import Session
from requests.utils import dict_from_cookiejar
from urllib3 import disable_warnings
......@@ -75,9 +75,18 @@ class WebSession(Session):
"""
return certifi.where() if all([sickrage.app.config.ssl_verify, verify]) else False
@staticmethod
def _get_user_agent(random_ua=False):
try:
user_agent = (sickrage.app.user_agent, UserAgent().random)[random_ua]
except FakeUserAgentError:
user_agent = sickrage.app.user_agent
return user_agent
def request(self, method, url, verify=False, random_ua=False, timeout=15, *args, **kwargs):
self.headers.update({'Accept-Encoding': 'gzip, deflate',
'User-Agent': (sickrage.app.user_agent, UserAgent().random)[random_ua]})
'User-Agent': self._get_user_agent(random_ua)})
if not verify:
disable_warnings()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment