Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[add] series: special season #2957

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion flexget/components/series/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
)
from flexget.utils.tools import parse_episode_identifier

SCHEMA_VER = 14
SCHEMA_VER = 15
logger = logger.bind(name='series.db')
Base = db_schema.versioned_base('series', SCHEMA_VER)

Expand Down Expand Up @@ -260,6 +260,7 @@ class Episode(Base):

season = Column(Integer)
number = Column(Integer)
special = Column(Boolean, default=False)

identified_by = Column(String)
series_id = Column(Integer, ForeignKey('series.id'), nullable=False)
Expand Down Expand Up @@ -315,6 +316,10 @@ def is_premiere(self):
return 'Season Premiere'
return False

@property
def is_special(self):
return self.identified_by == 'special' or self.special

@property
def downloaded_releases(self):
return [release for release in self.releases if release.downloaded]
Expand Down Expand Up @@ -407,6 +412,7 @@ def to_dict(self):
'season': self.season,
'identified_by': self.identified_by,
'number': self.number,
'special': self.special,
'series_id': self.series_id,
'first_seen': self.first_seen,
'premiere': self.is_premiere,
Expand Down Expand Up @@ -717,6 +723,11 @@ def upgrade(ver, session):
# New season_releases table, added by "create_all"
logger.info('Adding season_releases table')
ver = 14
if ver == 14:
# New season_releases table, added by "create_all"
logger.info('Adding special column to series_episodes table')
table_add_column('series_episodes', 'special', Boolean, session)
ver = 15
return ver


Expand Down Expand Up @@ -1464,6 +1475,7 @@ def store_parser(session, parser, series=None, quality=None):
elif parser.id_type == 'sequence':
episode.season = 0
episode.number = parser.id + ix
episode.special = parser.special
series.episodes.append(episode) # pylint:disable=E1103
logger.debug('-> added `{}`', episode)
session.flush()
Expand Down
2 changes: 1 addition & 1 deletion flexget/components/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def _exclude_season_on_accept(
continue

# skip special episodes if special handling has been turned off
if not config.get('specials', True) and entity.identified_by == 'special':
if not config.get('specials', True) and entity.is_special:
logger.debug('Skipping special episode as support is turned off.')
continue

Expand Down
4 changes: 4 additions & 0 deletions flexget/utils/parsers/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ def parse(self, data=None, field=None, quality=None):
data_parts.remove(part)
elif part in self.specials:
self.special = True
self.special_title = True
data_parts.remove(part)

data_stripped = ' '.join(data_parts).strip()
Expand Down Expand Up @@ -381,6 +382,9 @@ def parse(self, data=None, field=None, quality=None):
self.id = (self.season, self.episode)
self.id_type = 'ep'
self.valid = True
if self.season == 0 and self.episode > 0:
self.special = True
self.special_season = True
if not (self.special and self.prefer_specials):
return
else:
Expand Down