Commit 03e8ad39 authored by echel0n's avatar echel0n

Added xem_season and xem_episode columns to TVEpisodes table

Fixed issue with invalid episodes being created, refactored episodes to be added to database only when calling episode object save function
Refactored default value for scene_season, scene_episode, scene_absolute_number, xem_season, xem_episode, and xem_absolute_number to be -1
Refactored TVShow class to save it self only when its save function is called
Fixed missing scene_value variable
Added functions to TVEpisode class to logically return indexer, scene, or XEM season/episode/absolute numbering
Fixed column offset for show display page
parent 8b470cf0
......@@ -33,7 +33,7 @@ class MainDBBase(SRDatabaseBase):
class MainDB(SRDatabase):
def __init__(self, db_type, db_prefix, db_host, db_port, db_username, db_password):
super(MainDB, self).__init__('main', 14, db_type, db_prefix, db_host, db_port, db_username, db_password)
super(MainDB, self).__init__('main', 15, db_type, db_prefix, db_host, db_port, db_username, db_password)
MainDBBase.metadata.create_all(self.engine)
for model in MainDBBase._decl_class_registry.values():
if hasattr(model, '__tablename__'):
......@@ -47,12 +47,12 @@ class MainDB(SRDatabase):
duplicates = session.query(
self.TVShow.indexer_id,
func.count(self.TVShow.indexer_id).label('count')
). group_by(
).group_by(
self.TVShow.indexer_id
). having(literal_column('count') > 1).all()
).having(literal_column('count') > 1).all()
for cur_duplicate in duplicates:
session.query(self.TVShow).filter_by(showid=cur_duplicate['indexer_id']). limit(int(cur_duplicate['count']) - 1).delete()
session.query(self.TVShow).filter_by(showid=cur_duplicate['indexer_id']).limit(int(cur_duplicate['count']) - 1).delete()
session.commit()
def remove_duplicate_episodes():
......@@ -94,9 +94,40 @@ class MainDB(SRDatabase):
session.query(self.TVEpisode).filter_by(indexer_id=0).delete()
session.commit()
def fix_invalid_scene_numbering():
session = self.session()
session.query(self.TVEpisode).filter_by(scene_season=0, scene_episode=0).update({
self.TVEpisode.scene_season: -1,
self.TVEpisode.scene_episode: -1
})
session.commit()
session.query(self.TVEpisode).filter_by(scene_absolute_number=0).update({
self.TVEpisode.scene_absolute_number: -1
})
session.commit()
session.query(self.TVEpisode).filter(self.TVEpisode.season == self.TVEpisode.scene_season,
self.TVEpisode.episode == self.TVEpisode.scene_episode).update({
self.TVEpisode.scene_season: -1,
self.TVEpisode.scene_episode: -1
})
session.commit()
session.query(self.TVEpisode).filter(self.TVEpisode.absolute_number == self.TVEpisode.scene_absolute_number).update({
self.TVEpisode.scene_absolute_number: -1
})
session.commit()
remove_duplicate_shows()
remove_duplicate_episodes()
remove_invalid_episodes()
fix_invalid_scene_numbering()
class TVShow(MainDBBase):
__tablename__ = 'tv_shows'
......@@ -131,10 +162,10 @@ class MainDB(SRDatabase):
notify_list = Column(Text, default='')
search_delay = Column(Integer, default=0)
scene_exceptions = Column(Text, default='')
last_scene_exceptions_refresh = Column(Integer, default=0)
last_xem_refresh = Column(Integer, default=0)
last_update = Column(Integer, default=datetime.datetime.now().toordinal())
last_refresh = Column(Integer, default=datetime.datetime.now().toordinal())
last_xem_refresh = Column(Integer, default=datetime.datetime.now().toordinal())
last_scene_exceptions_refresh = Column(Integer, default=datetime.datetime.now().toordinal())
last_update = Column(Integer, default=datetime.datetime.now().toordinal())
last_backlog_search = Column(Integer, default=0)
last_proper_search = Column(Integer, default=0)
......@@ -157,8 +188,13 @@ class MainDB(SRDatabase):
indexer = Column(Integer, index=True, primary_key=True)
season = Column(Integer, index=True, primary_key=True)
episode = Column(Integer, index=True, primary_key=True)
scene_season = Column(Integer, default=0)
scene_episode = Column(Integer, default=0)
absolute_number = Column(Integer, default=-1)
scene_season = Column(Integer, default=-1)
scene_episode = Column(Integer, default=-1)
scene_absolute_number = Column(Integer, default=-1)
xem_season = Column(Integer, default=-1)
xem_episode = Column(Integer, default=-1)
xem_absolute_number = Column(Integer, default=-1)
name = Column(Text, default='')
description = Column(Text, default='')
subtitles = Column(Text, default='')
......@@ -172,8 +208,6 @@ class MainDB(SRDatabase):
file_size = Column(BigInteger, default=0)
release_name = Column(Text, default='')
is_proper = Column(Boolean, default=False)
absolute_number = Column(Integer, default=0)
scene_absolute_number = Column(Integer, default=0)
version = Column(Integer, default=-1)
release_group = Column(Text, default='')
......
import datetime
from sqlalchemy import *
......@@ -5,7 +7,7 @@ def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
tv_shows = Table('tv_shows', meta, autoload=True)
if not hasattr(tv_shows.c, 'last_xem_refresh'):
last_xem_refresh = Column('last_xem_refresh', Integer, default=0)
last_xem_refresh = Column('last_xem_refresh', Integer, default=datetime.datetime.now().toordinal())
last_xem_refresh.create(tv_shows)
xem_refresh = Table('xem_refresh', meta, autoload=True)
......
import datetime
from sqlalchemy import *
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
tv_episodes = Table('tv_episodes', meta, autoload=True)
if not hasattr(tv_episodes.c, 'xem_season'):
xem_season = Column('xem_season', Integer, default=-1)
xem_season.create(tv_episodes)
if not hasattr(tv_episodes.c, 'xem_episode'):
xem_episode = Column('xem_episode', Integer, default=-1)
xem_episode.create(tv_episodes)
if not hasattr(tv_episodes.c, 'xem_absolute_number'):
xem_absolute_number = Column('xem_absolute_number', Integer, default=-1)
xem_absolute_number.create(tv_episodes)
def downgrade(migrate_engine):
pass
from sqlalchemy import *
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
tv_episodes = Table('tv_episodes', meta, autoload=True)
scene_numbering = Table('scene_numbering', meta, autoload=True)
if scene_numbering is not None:
with migrate_engine.begin() as conn:
for row in migrate_engine.execute(scene_numbering.select()):
conn.execute(tv_episodes.update().where(
tv_episodes.c.show_id == row.indexer_id,
tv_episodes.c.season == row.season,
tv_episodes.c.episode == row.episode
).values(
scene_season=row.scene_season,
scene_episode=row.scene_episode
))
scene_numbering.drop()
def downgrade(migrate_engine):
pass
......@@ -151,20 +151,19 @@ def scene_to_normal_show_names(name):
def make_scene_show_search_strings(show_id, season=-1, anime=False):
"""
:rtype: list[unicode]
"""
showNames = all_possible_show_names(show_id, season=season)
show_names = all_possible_show_names(show_id, season=season)
# scenify the names
if anime:
sanitizeSceneNameAnime = partial(sanitize_scene_name, anime=True)
return map(sanitizeSceneNameAnime, showNames)
sanitize_scene_name_anime = partial(sanitize_scene_name, anime=True)
return map(sanitize_scene_name_anime, show_names)
else:
return map(sanitize_scene_name, showNames)
return map(sanitize_scene_name, show_names)
def make_scene_season_search_string(show_id, season, episode, extraSearchType=None):
def make_scene_season_search_string(show_id, season, episode, extraSearchType=None): # TODO: remove as this is no longer needed
numseasons = 0
show_object = find_show(show_id)
......@@ -183,22 +182,18 @@ def make_scene_season_search_string(show_id, season, episode, extraSearchType=No
# compile a list of all the episode numbers we need in this 'season'
seasonStrings = []
for episode in (x for x in show_object.episodes if x.season == episode_object.season):
# get quality of the episode
curCompositeStatus = episode.status
curStatus, curQuality = common.Quality.split_composite_status(curCompositeStatus)
highestBestQuality = 0
if bestQualities:
highestBestQuality = max(bestQualities)
else:
highestBestQuality = 0
# if we need a better one then add it to the list of episodes to fetch
if (curStatus in (
common.DOWNLOADED,
common.SNATCHED) and curQuality < highestBestQuality) or curStatus == common.WANTED:
if (curStatus in (common.DOWNLOADED, common.SNATCHED) and curQuality < highestBestQuality) or curStatus == common.WANTED:
ab_number = episode.scene_absolute_number
if ab_number > 0:
if ab_number > -1:
seasonStrings.append("%02d" % ab_number)
else:
numseasons = len(set([s.season for s in show_object.episodes if s.season > 0]))
......@@ -229,7 +224,7 @@ def make_scene_season_search_string(show_id, season, episode, extraSearchType=No
return toReturn
def make_scene_search_string(show_id, season, episode):
def make_scene_search_string(show_id, season, episode): # TODO: remove as this is no longer needed
toReturn = []
show_object = find_show(show_id)
......
This diff is collapsed.
......@@ -53,24 +53,16 @@ class TVEpisode(object):
query = session.query(MainDB.TVEpisode).filter_by(showid=showid, indexer=indexer, season=season, episode=episode).one()
self._data_local = query.as_dict()
except orm.exc.NoResultFound:
session.add(MainDB.TVEpisode(**{
self._data_local = MainDB.TVEpisode().as_dict()
self._data_local.update(**{
'showid': showid,
'indexer': indexer,
'season': season,
'episode': episode,
'location': location
}))
try:
session.commit()
except Exception as e:
pass
query = session.query(MainDB.TVEpisode).filter_by(showid=showid, indexer=indexer, season=season, episode=episode).one()
self._data_local = query.as_dict()
})
self.populate_episode(season, episode)
# self.checkForMetaFiles()
@property
def showid(self):
......@@ -112,6 +104,14 @@ class TVEpisode(object):
def episode(self, value):
self._data_local['episode'] = value
@property
def absolute_number(self):
return self._data_local['absolute_number']
@absolute_number.setter
def absolute_number(self, value):
self._data_local['absolute_number'] = value
@property
def scene_season(self):
return self._data_local['scene_season']
......@@ -128,6 +128,38 @@ class TVEpisode(object):
def scene_episode(self, value):
self._data_local['scene_episode'] = value
@property
def scene_absolute_number(self):
return self._data_local['scene_absolute_number']
@scene_absolute_number.setter
def scene_absolute_number(self, value):
self._data_local['scene_absolute_number'] = value
@property
def xem_season(self):
return self._data_local['xem_season']
@xem_season.setter
def xem_season(self, value):
self._data_local['xem_season'] = value
@property
def xem_episode(self):
return self._data_local['xem_episode']
@xem_episode.setter
def xem_episode(self, value):
self._data_local['xem_episode'] = value
@property
def xem_absolute_number(self):
return self._data_local['xem_absolute_number']
@xem_absolute_number.setter
def xem_absolute_number(self, value):
self._data_local['xem_absolute_number'] = value
@property
def name(self):
return self._data_local['name']
......@@ -234,22 +266,6 @@ class TVEpisode(object):
def is_proper(self, value):
self._data_local['is_proper'] = value
@property
def absolute_number(self):
return self._data_local['absolute_number']
@absolute_number.setter
def absolute_number(self, value):
self._data_local['absolute_number'] = value
@property
def scene_absolute_number(self):
return self._data_local['scene_absolute_number']
@scene_absolute_number.setter
def scene_absolute_number(self, value):
self._data_local['scene_absolute_number'] = value
@property
def version(self):
return self._data_local['version']
......@@ -278,18 +294,20 @@ class TVEpisode(object):
return [x for x in self.show.episodes if x.location and x.location == self.location and x.season == self.season and x.episode != self.episode]
def save(self):
with sickrage.app.main_db.session() as session:
query = session.query(MainDB.TVEpisode).filter_by(showid=self.showid,
indexer=self.indexer,
season=self.season,
episode=self.episode).one_or_none()
if query:
with self.lock, sickrage.app.main_db.session() as session:
try:
query = session.query(MainDB.TVEpisode).filter_by(showid=self.showid,
indexer=self.indexer,
season=self.season,
episode=self.episode).one()
query.update(**self._data_local)
session.commit()
except orm.exc.NoResultFound:
session.add(MainDB.TVEpisode(**self._data_local))
finally:
session.commit()
def delete(self):
with sickrage.app.main_db.session() as session:
with self.lock, sickrage.app.main_db.session() as session:
session.query(MainDB.TVEpisode).filter_by(showid=self.showid,
indexer=self.indexer,
season=self.season,
......@@ -457,16 +475,16 @@ class TVEpisode(object):
self.season = season
self.episode = episode
self.scene_absolute_number = get_scene_absolute_numbering(
self.scene_season, self.scene_episode = get_scene_numbering(
self.show.indexer_id,
self.show.indexer,
self.absolute_number
self.season, self.episode
)
self.scene_season, self.scene_episode = get_scene_numbering(
self.scene_absolute_number = get_scene_absolute_numbering(
self.show.indexer_id,
self.show.indexer,
self.season, self.episode
self.absolute_number
)
self.description = safe_getattr(myEp, 'overview', self.description)
......@@ -1257,6 +1275,22 @@ 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:
return self.scene_season, self.scene_episode
elif self.show.scene and self.xem_season != -1 and self.xem_episode != -1:
return self.xem_season, self.xem_season
else:
return self.season, self.episode
def get_absolute_numbering(self):
if self.show.scene and self.scene_absolute_number != -1:
return self.scene_absolute_number
elif self.show.scene and self.xem_absolute_number != -1:
return self.xem_absolute_number
else:
return self.absolute_number
def __unicode__(self):
to_return = ""
to_return += "%r - S%02rE%02r - %r\n" % (self.show.name, self.season, self.episode, self.name)
......
......@@ -58,22 +58,18 @@ class TVShow(object):
query = session.query(MainDB.TVShow).filter_by(indexer_id=indexer_id, indexer=indexer).one()
self._data_local = query.as_dict()
except orm.exc.NoResultFound:
session.add(MainDB.TVShow(**{
self._data_local = MainDB.TVShow().as_dict()
self._data_local.update(**{
'indexer_id': indexer_id,
'indexer': indexer,
'lang': lang,
'location': location
}))
})
session.commit()
query = session.query(MainDB.TVShow).filter_by(indexer_id=indexer_id, indexer=indexer).one()
self._data_local = query.as_dict()
self.load_from_indexer()
sickrage.app.shows.update({(self.indexer_id, self.indexer): self})
self.load_from_indexer()
@property
def indexer_id(self):
return self._data_local['indexer_id']
......@@ -568,15 +564,19 @@ class TVShow(object):
return BlackAndWhiteList(self.indexer_id)
def save(self):
with sickrage.app.main_db.session() as session:
with self.lock, sickrage.app.main_db.session() as session:
sickrage.app.log.debug("{0:d}: Saving to database: {1}".format(self.indexer_id, self.name))
query = session.query(MainDB.TVShow).filter_by(indexer_id=self.indexer_id, indexer=self.indexer).one_or_none()
if query:
try:
query = session.query(MainDB.TVShow).filter_by(indexer_id=self.indexer_id, indexer=self.indexer).one()
query.update(**self._data_local)
session.commit()
except orm.exc.NoResultFound:
session.add(MainDB.TVShow(**self._data_local))
finally:
session.commit()
def delete(self):
with sickrage.app.main_db.session() as session:
with self.lock, sickrage.app.main_db.session() as session:
session.query(MainDB.TVShow).filter_by(indexer_id=self.indexer_id, indexer=self.indexer).delete()
session.commit()
......@@ -1042,7 +1042,6 @@ class TVShow(object):
session.query(MainDB.TVShow).filter_by(indexer_id=self.indexer_id).delete()
session.query(MainDB.TVEpisode).filter_by(showid=self.indexer_id).delete()
session.query(MainDB.IMDbInfo).filter_by(indexer_id=self.indexer_id).delete()
session.query(MainDB.SceneNumbering).filter_by(indexer_id=self.indexer_id).delete()
self.save()
# remove episodes from show episode cache
......
......@@ -1100,16 +1100,13 @@ class DisplayShowHandler(BaseHandler, ABC):
if show_obj.is_anime:
bwl = show_obj.release_groups
indexer_id = int(show_obj.indexer_id)
indexer = int(show_obj.indexer)
# Insert most recent show
for index, recentShow in enumerate(sickrage.app.shows_recent):
if recentShow['indexer_id'] == indexer_id:
if recentShow['indexer_id'] == show_obj.indexer_id:
break
else:
sickrage.app.shows_recent.append({
'indexer_id': indexer_id,
'indexer_id': show_obj.indexer_id,
'name': show_obj.name,
})
......@@ -1124,10 +1121,10 @@ class DisplayShowHandler(BaseHandler, ABC):
bwl=bwl,
epCounts=ep_counts,
epCats=ep_cats,
scene_numbering=get_scene_numbering_for_show(indexer_id, indexer),
xem_numbering=get_xem_numbering_for_show(indexer_id, indexer),
scene_absolute_numbering=get_scene_absolute_numbering_for_show(indexer_id, indexer),
xem_absolute_numbering=get_xem_absolute_numbering_for_show(indexer_id, indexer),
scene_numbering=get_scene_numbering_for_show(show_obj.indexer_id, show_obj.indexer),
xem_numbering=get_xem_numbering_for_show(show_obj.indexer_id, show_obj.indexer),
scene_absolute_numbering=get_scene_absolute_numbering_for_show(show_obj.indexer_id, show_obj.indexer),
xem_absolute_numbering=get_xem_absolute_numbering_for_show(show_obj.indexer_id, show_obj.indexer),
title=show_obj.name,
controller='home',
action="display_show")
......@@ -1664,7 +1661,8 @@ class SetSceneNumberingHandler(BaseHandler, ABC):
if scene_absolute is not None:
scene_absolute = int(scene_absolute)
set_scene_numbering(show, indexer, absolute_number=for_absolute, sceneAbsolute=scene_absolute)
set_scene_numbering(show, indexer, absolute_number=for_absolute, scene_absolute=scene_absolute)
result['sceneAbsolute'] = get_scene_absolute_numbering(show, indexer, for_absolute)
else:
sickrage.app.log.debug("setEpisodeSceneNumbering for %s from %sx%s to %sx%s" % (show, for_season, for_episode, scene_season, scene_episode))
......@@ -1677,20 +1675,8 @@ class SetSceneNumberingHandler(BaseHandler, ABC):
if scene_episode is not None:
scene_episode = int(scene_episode)
set_scene_numbering(show, indexer, season=for_season, episode=for_episode, sceneSeason=scene_season, sceneEpisode=scene_episode)
if show_obj.is_anime:
sn = get_scene_absolute_numbering(show, indexer, for_absolute)
if sn:
result['sceneAbsolute'] = sn
else:
result['sceneAbsolute'] = None
else:
sn = get_scene_numbering(show, indexer, for_season, for_episode)
if sn:
(result['sceneSeason'], result['sceneEpisode']) = sn
else:
(result['sceneSeason'], result['sceneEpisode']) = (None, None)
set_scene_numbering(show, indexer, season=for_season, episode=for_episode, scene_season=scene_season, scene_episode=scene_episode)
(result['sceneSeason'], result['sceneEpisode']) = get_scene_numbering(show, indexer, for_season, for_episode)
except (EpisodeNotFoundException, MultipleEpisodesInDatabaseException):
result['errorMessage'] = _("Episode couldn't be retrieved")
result['success'] = False
......
......@@ -837,6 +837,7 @@ class MassEditHandler(BaseHandler, ABC):
skip_downloaded_value = last_skip_downloaded if skip_downloaded_all_same else None
default_ep_status_value = last_default_ep_status if default_ep_status_all_same else None
paused_value = last_paused if paused_all_same else None
scene_value = last_scene if scene_all_same else None
anime_value = last_anime if anime_all_same else None
flatten_folders_value = last_flatten_folders if flatten_folders_all_same else None
quality_value = last_quality if quality_all_same else None
......@@ -849,6 +850,7 @@ class MassEditHandler(BaseHandler, ABC):
skip_downloaded_value=skip_downloaded_value,
default_ep_status_value=default_ep_status_value,
paused_value=paused_value,
scene_value=scene_value,
anime_value=anime_value,
flatten_folders_value=flatten_folders_value,
quality_value=quality_value,
......
......@@ -474,11 +474,11 @@
continue
(dfltSeas, dfltEpis, dfltAbsolute) = (0, 0, 0)
if (episode_object.season, episode_object.episode) in xem_numbering:
(dfltSeas, dfltEpis) = xem_numbering[(episode_object.season, episode_object.episode)]
if episode_object.absolute_number in xem_absolute_numbering:
dfltAbsolute = xem_absolute_numbering[episode_object.absolute_number]
## if (episode_object.season, episode_object.episode) in xem_numbering:
## (dfltSeas, dfltEpis) = xem_numbering[(episode_object.season, episode_object.episode)]
##
## if episode_object.absolute_number in xem_absolute_numbering:
## dfltAbsolute = xem_absolute_numbering[episode_object.absolute_number]
if episode_object.absolute_number in scene_absolute_numbering:
scAbsolute = scene_absolute_numbering[episode_object.absolute_number]
......@@ -547,6 +547,11 @@
<th data-sorter="false" ${("class=\"col-ep columnSelector-false\"", "class=\"col-ep\"")[bool(show.is_anime)]}>${_('Absolute')}</th>
<th data-sorter="false" class="col-name">${_('Scene Season/Episode')}</th>
<th data-sorter="false" class="col-name">${_('Scene Absolute')}</th>
% if xem_numbering or xem_absolute_numbering:
<th data-sorter="false" class="col-name">${_('XEM Scene Season')}</th>
<th data-sorter="false" class="col-name">${_('XEM Scene Episode')}</th>
<th data-sorter="false" class="col-name">${_('XEM Scene Absolute')}</th>
% endif
<th data-sorter="false" class="col-name">${_('Name')}</th>
<th data-sorter="false" class="col-ep columnSelector-false size">${_('Size')}</th>
<th data-sorter="false" class="col-airdate">${_('Airdate')}</th>
......@@ -601,7 +606,7 @@
<td class="table-fit">
<input placeholder="${str(dfltSeas)}x${str(dfltEpis)}" size="6"
maxlength="8"
class="sceneSeasonXEpisode form-control input-scene"
class="sceneSeasonXEpisode form-control d-inline input-scene"
data-for-season="${episode_object.season}"
data-for-episode="${episode_object.episode}"
id="sceneSeasonXEpisode_${show.indexer_id}_${str(episode_object.season)}_${str(episode_object.episode)}"
......@@ -628,6 +633,12 @@
style="padding: 0; text-align: center; max-width: 60px;"/>
</td>
% if xem_numbering or xem_absolute_numbering:
<td class="table-fit">${episode_object.xem_season}</td>
<td class="table-fit">${episode_object.xem_episode}</td>
<td class="table-fit">${episode_object.xem_absolute_number}</td>
% endif
<td class="col-name">
<i id="plot_info_${str(show.indexer_id)}_${str(episode_object.season)}_${str(episode_object.episode)}"
class="fas fa-info-circle" title="${episode_object.description}"></i>
......@@ -653,7 +664,7 @@
</td>
<td class="table-fit">
% if sickrage.app.config.download_url and episode_object.location:
% if sickrage.app.config.download_url and os.path.isfile(episode_object.location):
<%
filename = episode_object.location
for rootDir in sickrage.app.config.root_dirs.split('|'):
......@@ -667,21 +678,23 @@
% endif
</td>
<td class="table-fit col-subtitles">
% for flag in (episode_object.subtitles or '').split(','):
% if Subtitles().name_from_code(flag).lower() != 'undetermined':
% if flag.strip() != 'und':
<i class="sickrage-flags sickrage-flags-${flag}"
title="${Subtitles().name_from_code(flag)}"></i>
% if sickrage.app.config.use_subtitles:
<td class="table-fit col-subtitles">
% for flag in (episode_object.subtitles or '').split(','):
% if Subtitles().name_from_code(flag).lower() != 'undetermined':
% if flag.strip() != 'und':
<i class="sickrage-flags sickrage-flags-${flag}"
title="${Subtitles().name_from_code(flag)}"></i>
% else:
<i class="sickrage-flags sickrage-flags-${flag}"
title="${Subtitles().name_from_code(flag)}"></i>
% endif
% else:
<i class="sickrage-flags sickrage-flags-${flag}"
title="${Subtitles().name_from_code(flag)}"></i>
<i class="sickrage-flags sickrage-flags-unknown" title="${_('Unknown')}"></i>
% endif
% else:
<i class="sickrage-flags sickrage-flags-unknown" title="${_('Unknown')}"></i>
% endif
% endfor
</td>
% endfor
</td>
% endif
<% curStatus, curQuality = Quality.split_composite_status(int(episode_object.status)) %>
% if curQuality != Quality.NONE:
......
......@@ -36,7 +36,6 @@ from time import sleep
from urllib.parse import urljoin
from xml.sax import SAXParseException
from apscheduler.triggers.interval import IntervalTrigger
from bencode3 import bdecode, bencode
from feedparser import FeedParserDict
from requests.utils import add_dict_to_cookiejar, dict_from_cookiejar
......@@ -164,7 +163,7 @@ class GenericProvider(object):
episode_object = show_object.get_episode(season, episode)
for show_name in all_possible_show_names(show_id, episode_object.scene_season):
for show_name in all_possible_show_names(show_id, episode_object.season):
episode_string = "{}{}".format(show_name, self.search_separator)
if show_object.search_format in [SearchFormats.AIR_BY_DATE, SearchFormats.SPORTS]:
......@@ -172,9 +171,9 @@ class GenericProvider(object):
elif show_object.search_format == SearchFormats.ANIME:
episode_string += 'Season'
elif show_object.search_format == SearchFormats.COLLECTION:
episode_string += 'Series {season}'.format(season=int(episode_object.scene_season))
episode_string += 'Series {season}'.format(season=episode_object.get_season_episode_numbering()[0])
else:
episode_string += 'S{season:0>2}'.format(season=episode_object.scene_season)
episode_string += 'S{season:0>2}'.format(season=episode_object.get_season_episode_numbering()[0])
search_string['Season'].append(episode_string.strip())
......@@ -195,7 +194,7 @@ class GenericProvider(object):
episode_object = show_object.get_episode(season, episode)
for show_name in all_possible_show_names(show_id, episode_object.scene_season):
for show_name in all_possible_show_names(show_id, episode_object.season):
episode_string = "{}{}".format(show_name, self.search_separator)
episode_string_fallback = None
......@@ -207,26 +206,27 @@ class GenericProvider(object):
episode_string += episode_object.airdate.strftime('%b')
elif show_object.search_format == SearchFormats.ANIME:
# If the show name is a season scene exception, we want to use the indexer episode number.
if episode_object.scene_season > 0 and show_name in show_object.get_scene_exceptions_by_season(episode_object.scene_season):
if episode_object.season > 0 and show_name in show_object.get_scene_exceptions_by_season(episode_object.season):
# This is apparently a season exception, let's use the scene_episode instead of absolute
ep = episode_object.scene_episode
ep = episode_object.get_season_episode_numbering()[1]
else:
ep = episode_object.