Commit 29011fcc authored by echel0n's avatar echel0n

Fixed issues with searching by scene numbers.

parent 7db2b7b2
# Changelog
- * 8b4d821 - 2018-11-25: Release v9.4.43
- * 8c81bf0 - 2018-11-25: Fixed issues with searching by scene numbers.
- * 5882a99 - 2018-11-25: Release v9.4.43
- * db39bd2 - 2018-11-25: Fixed episode search string fallback. Added touch file helper function.
- * 6f17262 - 2018-11-24: Shows now flagged with `scene numbering` will display and search by episode scene numbers.
- * c5327f5 - 2018-11-24: Added ability to add new shows using quicksearch. Bugfixed Torrent9 provider.
......
......@@ -245,15 +245,16 @@ class TVCache(object):
pass
def search_cache(self, ep_obj, manualSearch=False, downCurQuality=False):
season = ep_obj.scene_season if ep_obj.show.scene else ep_obj.season
episode = ep_obj.scene_episode if ep_obj.show.scene else ep_obj.episode
neededEps = {}
dbData = []
# get data from external database
if sickrage.app.config.enable_api_providers_cache and not self.provider.private:
try:
dbData += ProviderCacheAPI().get(self.providerID,
ep_obj.show.indexerid,
ep_obj.season, ep_obj.episode)['data']
dbData += ProviderCacheAPI().get(self.providerID, ep_obj.show.indexerid, season, episode)['data']
except Exception:
pass
......@@ -261,8 +262,8 @@ class TVCache(object):
dbData += [x for x in sickrage.app.cache_db.get_many('providers', self.providerID)]
# for each cache entry
for curResult in (x for x in dbData if x['indexerid'] == ep_obj.show.indexerid and x['season'] == ep_obj.season
and "|" + str(ep_obj.episode) + "|" in x['episodes']):
for curResult in (x for x in dbData if x['indexerid'] == ep_obj.show.indexerid and x['season'] == season
and "|" + str(episode) + "|" in x['episodes']):
result = self.provider.getResult()
# ignore invalid and private IP address urls
......@@ -304,7 +305,11 @@ class TVCache(object):
# make sure we want the episode
wantEp = False
for curEp in result.episodes:
if result.show.want_episode(curEp.season, curEp.episode, result.quality, manualSearch, downCurQuality):
if result.show.want_episode(curEp.season,
curEp.episode,
result.quality,
manualSearch,
downCurQuality):
wantEp = True
if not wantEp:
......
......@@ -380,7 +380,8 @@ def get_scene_numbering_for_show(indexer_id, indexer):
episode = try_int(dbData['episode'])
scene_season = try_int(dbData['scene_season'])
scene_episode = try_int(dbData['scene_episode'])
if try_int(dbData['indexer']) != indexer or (scene_season or scene_episode) == 0: continue
if try_int(dbData['indexer']) != indexer or (scene_season or scene_episode) == 0:
continue
result[(season, episode)] = (scene_season, scene_episode)
......@@ -407,7 +408,8 @@ def get_xem_numbering_for_show(indexer_id, indexer):
episode = try_int(dbData.get('episode'))
scene_season = try_int(dbData.get('scene_season'))
scene_episode = try_int(dbData.get('scene_episode'))
if try_int(dbData['indexer']) != indexer or (scene_season or scene_episode) == 0: continue
if try_int(dbData['indexer']) != indexer or (scene_season or scene_episode) == 0:
continue
result[(season, episode)] = (scene_season, scene_episode)
......@@ -430,7 +432,8 @@ def get_scene_absolute_numbering_for_show(indexer_id, indexer):
for dbData in sickrage.app.main_db.get_many('scene_numbering', indexer_id):
absolute_number = try_int(dbData.get('absolute_number'))
scene_absolute_number = try_int(dbData.get('scene_absolute_number'))
if try_int(dbData.get('indexer')) != indexer or scene_absolute_number == 0: continue
if try_int(dbData.get('indexer')) != indexer or scene_absolute_number == 0:
continue
result[absolute_number] = scene_absolute_number
......
......@@ -53,6 +53,9 @@ class TVEpisode(object):
self._season = season
self._episode = episode
self._absolute_number = 0
self._scene_season = 0
self._scene_episode = 0
self._scene_absolute_number = 0
self._description = ""
self._subtitles = []
self._subtitles_searchcount = 0
......@@ -70,9 +73,6 @@ class TVEpisode(object):
self._location = file
self.show = show
self.scene_season = 0
self.scene_episode = 0
self.scene_absolute_number = 0
self.populateEpisode(self.season, self.episode)
......@@ -120,6 +120,36 @@ class TVEpisode(object):
self.dirty = True
self._absolute_number = value
@property
def scene_season(self):
if self._scene_season:
return self._scene_season
return self._season
@scene_season.setter
def scene_season(self, value):
self._scene_season = value
@property
def scene_episode(self):
if self._scene_episode:
return self._scene_episode
return self._episode
@scene_episode.setter
def scene_episode(self, value):
self._scene_episode = value
@property
def scene_absolute_number(self):
if self._scene_absolute_number:
return self._scene_absolute_number
return self._absolute_number
@scene_absolute_number.setter
def scene_absolute_number(self, value):
self._scene_absolute_number = value
@property
def description(self):
return self._description
......@@ -407,19 +437,19 @@ class TVEpisode(object):
self._is_proper = try_int(dbData[0]["is_proper"], self.is_proper)
self._version = try_int(dbData[0]["version"], self.version)
self.scene_season = try_int(dbData[0]["scene_season"], self.scene_season)
self.scene_episode = try_int(dbData[0]["scene_episode"], self.scene_episode)
self.scene_absolute_number = try_int(dbData[0]["scene_absolute_number"], self.scene_absolute_number)
self._scene_season = try_int(dbData[0]["scene_season"], self.scene_season)
self._scene_episode = try_int(dbData[0]["scene_episode"], self.scene_episode)
self._scene_absolute_number = try_int(dbData[0]["scene_absolute_number"], self.scene_absolute_number)
if self.scene_absolute_number == 0:
self.scene_absolute_number = get_scene_absolute_numbering(
if self._scene_absolute_number == 0:
self._scene_absolute_number = get_scene_absolute_numbering(
self.show.indexerid,
self.show.indexer,
self.absolute_number
)
if self.scene_season == 0 or self.scene_episode == 0:
self.scene_season, self.scene_episode = get_scene_numbering(
if self._scene_season == 0 or self._scene_episode == 0:
self._scene_season, self._scene_episode = get_scene_numbering(
self.show.indexerid,
self.show.indexer,
self.season, self.episode
......@@ -816,8 +846,6 @@ class TVEpisode(object):
return self._format_pattern('%SN - %AB - %EN')
elif self.show.air_by_date:
return self._format_pattern('%SN - %AD - %EN')
elif self.show.scene:
return self._format_pattern('%SN - %XSx%0XE - %EN')
return self._format_pattern('%SN - %Sx%0E - %EN')
......
......@@ -1339,8 +1339,8 @@ class TVShow(object):
curStatus, curQuality = Quality.splitCompositeStatus(epStatus)
# if it's one of these then we want it as long as it's in our allowed initial qualities
if epStatus in (WANTED, SKIPPED, UNKNOWN):
sickrage.app.log.debug("Existing episode status is wanted/skipped/unknown, getting found episode")
if epStatus == WANTED:
sickrage.app.log.debug("Existing episode status is WANTED, getting found episode")
return True
elif manualSearch:
if (downCurQuality and quality >= curQuality) or (not downCurQuality and quality > curQuality):
......
......@@ -410,8 +410,10 @@ class GenericProvider(object):
result.episodes.append(result.show.get_episode(actual_season, curEp))
sickrage.app.log.debug(
"FOUND RESULT:[{}] QUALITY:[{}] URL:[{}]".format(result.name, Quality.qualityStrings[result.quality],
result.url))
"FOUND RESULT:[{}] QUALITY:[{}] URL:[{}]".format(result.name,
Quality.qualityStrings[result.quality],
result.url)
)
if len(result.episodes) == 1:
epNum = result.episodes[0].episode
......@@ -421,7 +423,7 @@ class GenericProvider(object):
sickrage.app.log.debug(
"Separating multi-episode result to check for later - result contains episodes: " + str(
parse_result.episode_numbers))
elif len(result.episodes) == 0:
else:
epNum = SEASON_RESULT
sickrage.app.log.debug("Separating full season result to check for later")
......
......@@ -168,8 +168,8 @@ class BTNProvider(TorrentProvider):
else:
search_name = '{type} {number}'.format(
type=season,
number=ep_obj.season if season else episode_num(
ep_obj.season, ep_obj.episode
number=ep_obj.scene_season if season else episode_num(
ep_obj.scene_season, ep_obj.scene_episode
),
).strip()
......
......@@ -64,7 +64,7 @@ class NewpctProvider(TorrentProvider):
for show_name in allPossibleShowNames(episode.show, episode.scene_season):
for season_string in season_strings:
season_string = season_string % (show_name.replace(' ', '-'), episode.season, episode.episode)
season_string = season_string % (show_name.replace(' ', '-'), episode.scene_season, episode.scene_episode)
search_strings['Season'].append(season_string.strip())
return [search_strings]
......@@ -88,7 +88,7 @@ class NewpctProvider(TorrentProvider):
for show_name in allPossibleShowNames(episode.show, episode.scene_season):
for episode_string in episode_strings:
episode_string = episode_string % (show_name.replace(' ', '-'), episode.season, episode.episode)
episode_string = episode_string % (show_name.replace(' ', '-'), episode.scene_season, episode.scene_episode)
search_strings['Episode'].append(episode_string.strip())
return [search_strings]
......
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