flexget.components.series.db module#

class flexget.components.series.db.AlternateNames(name)[source]#

Bases: VersionedBase

Similar to Series. Name is handled case insensitively transparently.

_alt_name#
_alt_name_normalized#
_sa_class_manager = {'_alt_name': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, '_alt_name_normalized': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'series_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
alt_name#
id#
property name_normalized#
series_id#
class flexget.components.series.db.Episode(**kwargs)[source]#

Bases: VersionedBase

to_dict()[source]#
_sa_class_manager = {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'identified_by': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'identifier': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'number': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'releases': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'season': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'series_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
property age#

Return Pretty string representing age of episode.

Example: “23d 12h” or “No releases seen”

property age_timedelta#
Returns:

Timedelta or None if episode is never seen

property downloaded_releases#
first_seen#
id#
identified_by#
identifier#
property is_premiere#
is_season = False#
property latest_release#
Returns:

Latest downloaded Release or None

number#
releases#
season#
series_id#
class flexget.components.series.db.EpisodeRelease[source]#

Bases: VersionedBase

to_dict()[source]#
_quality#
_sa_class_manager = {'_quality': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'downloaded': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'episode_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'first_seen': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'proper_count': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'title': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
downloaded#
episode_id#
first_seen#
id#
property proper#
proper_count#
quality#
title#
class flexget.components.series.db.NormalizedComparator(expression)[source]#

Bases: Comparator

Parameters:

expression (Union[_HasClauseElement[_T], SQLColumnExpression[_T]])

operate(op, other)[source]#

Operate on an argument.

This is the lowest level of operation, raises NotImplementedError by default.

Overriding this on a subclass can allow common behavior to be applied to all operations. For example, overriding ColumnOperators to apply func.lower() to the left and right side:

class MyComparator(ColumnOperators):
    def operate(self, op, other, **kwargs):
        return op(func.lower(self), func.lower(other), **kwargs)
Parameters:
  • op – Operator callable.

  • *other – the ‘other’ side of the operation. Will be a single scalar for most operations.

  • **kwargs – modifiers. These may be passed by special operators such as ColumnOperators.contains().

_adapt_to_entity#
_parententity#
prop#
class flexget.components.series.db.Season(**kwargs)[source]#

Bases: VersionedBase

to_dict()[source]#
_sa_class_manager = {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'identified_by': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'identifier': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'releases': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'season': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'series_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
property age#

Return Pretty string representing age of episode.

Example: “23d 12h” or “No releases seen”

property age_timedelta#
Returns:

Timedelta or None if seasons is never seen

property completed#

Return True if the season has any released marked as downloaded.

property downloaded_releases#
first_seen#
id#
identified_by#
identifier#
property is_premiere#
is_season = True#
property latest_release#
Returns:

Latest downloaded Release or None

releases#
season#
series_id#
class flexget.components.series.db.SeasonRelease[source]#

Bases: VersionedBase

to_dict()[source]#
_quality#
_sa_class_manager = {'_quality': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'downloaded': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'first_seen': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'proper_count': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'season_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'title': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
downloaded#
first_seen#
id#
property proper#
proper_count#
quality#
season_id#
title#
class flexget.components.series.db.Series(**kwargs)[source]#

Bases: VersionedBase

Name is handled case insensitively transparently.

episodes_for_season(season_num)[source]#
_name#
_name_normalized#
_sa_class_manager = {'_name': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, '_name_normalized': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'alternate_names': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'begin': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'begin_episode_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'episodes': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'identified_by': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'in_tasks': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'seasons': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
alternate_names#
begin#
begin_episode_id#
property completed_seasons#
episodes#
id#
identified_by#
in_tasks#
name#
property name_normalized#
seasons#
class flexget.components.series.db.SeriesTask(name)[source]#

Bases: VersionedBase

_sa_class_manager = {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'name': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'series_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
id#
name#
series_id#
flexget.components.series.db._add_alt_name(alt, db_series, series_name, session)[source]#
Parameters:
  • alt (str)

  • db_series (Series)

  • series_name (str)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

None

flexget.components.series.db.add_series_entity(session, series, identifier, quality=None)[source]#

Add entity identified by identifier to series name in database.

Parameters:
  • series (Series) – Series in database to add entity to.

  • identifier (str) – Series identifier to be added.

  • quality (Quality) – If supplied, this will override the quality from the series parser.

  • session (Session)

Return type:

None

flexget.components.series.db.auto_identified_by(series)[source]#

Determine if series name should be considered identified by episode or id format.

Returns ‘ep’, ‘sequence’, ‘date’ or ‘id’ if enough history is present to identify the series’ id type. Returns ‘auto’ if there is not enough history to determine the format yet

Parameters:

series (Series)

Return type:

str

flexget.components.series.db.db_cleanup(manager, session)[source]#
Parameters:

session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

None

flexget.components.series.db.delete_episode_release_by_id(release_id)[source]#
Parameters:

release_id (int)

Return type:

None

flexget.components.series.db.delete_season_release_by_id(release_id)[source]#
Parameters:

release_id (int)

Return type:

None

flexget.components.series.db.episode_by_id(episode_id, session=None)[source]#

Return an instance of an episode by querying its ID.

Parameters:
  • episode_id (int)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

Episode

flexget.components.series.db.episode_in_show(series_id, episode_id)[source]#

Return True if episode_id is part of show with series_id, else return False.

Parameters:
  • series_id (int)

  • episode_id (int)

Return type:

bool

flexget.components.series.db.episode_release_by_id(release_id, session=None)[source]#

Return an instance of an episode release by querying its ID.

Parameters:
  • release_id (int)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

EpisodeRelease

flexget.components.series.db.get_all_entities(series, session, sort_by='age', reverse=False)[source]#
Parameters:
  • series (Series)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

  • sort_by (str)

  • reverse (bool)

Return type:

list[Episode | Season]

flexget.components.series.db.get_episode_releases(episode, downloaded=None, start=None, stop=None, count=False, descending=False, sort_by=None, session=None)[source]#

Return all releases for a given episode.

Parameters:
  • episode (Episode)

  • downloaded (bool | None)

  • start (int | None)

  • stop (int | None)

  • count (bool)

  • descending (bool)

  • sort_by (str | None)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

list[EpisodeRelease]

flexget.components.series.db.get_latest_episode_release(series, downloaded=True, season=None)[source]#

Return instance of Episode or None if not found.

Parameters:
  • series (Series) – SQLAlchemy session

  • downloaded (bool) – find only downloaded releases

  • season (int | None) – season to find newest release for

Return type:

Episode | None

flexget.components.series.db.get_latest_release(series, downloaded=True, season=None)[source]#

Return the latest downloaded entity of a series, either season pack or episode.

Parameters:
  • series (Series) – Series object

  • downloaded (bool) – Downloaded flag

  • season (int) – Filter by season

Returns:

Return type:

EpisodeRelease | SeasonRelease | None

flexget.components.series.db.get_latest_season_pack_release(series, downloaded=True, season=None)[source]#

Return the latest season pack release for a series.

Parameters:
  • series (Series) – Series object

  • downloaded (bool) – Flag to return only downloaded season packs

  • season (int | None) – Filter by season number

Returns:

Latest release of a season object

Return type:

Season | None

flexget.components.series.db.get_season_releases(season, downloaded=None, start=None, stop=None, count=False, descending=False, sort_by=None, session=None)[source]#

Return all releases for a given season.

Parameters:
  • season (Season)

  • downloaded (bool | None)

  • start (int | None)

  • stop (int | None)

  • count (bool)

  • descending (bool)

  • sort_by (str | None)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

int | list[SeasonRelease]

flexget.components.series.db.new_entities_after(since_entity)[source]#
Parameters:

since_entity (Season | Episode)

Return type:

tuple[int, str]

flexget.components.series.db.new_eps_after(series, since_ep, session)[source]#

Return number of episodes since then.

Parameters:
  • since_ep (Episode) – Episode instance

  • series (Series)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

tuple[int, str]

flexget.components.series.db.new_seasons_after(series, since_season, session)[source]#
Parameters:
  • series (Series)

  • since_season (Season)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

tuple[int, str]

flexget.components.series.db.release_in_episode(episode_id, release_id)[source]#

Return True if release_id is part of episode with episode_id, else return False.

Parameters:
  • episode_id (int)

  • release_id (int)

Return type:

bool

flexget.components.series.db.release_in_season(season_id, release_id)[source]#

Return True if release_id is part of episode with episode_id, else return False.

Parameters:
  • season_id (int)

  • release_id (int)

Return type:

bool

flexget.components.series.db.remove_series(name, forget=False)[source]#

Remove a whole series name from database.

Parameters:
  • name (str) – Name of series to be removed

  • forget (bool) – Indication whether or not to fire a ‘forget’ event

Return type:

None

flexget.components.series.db.remove_series_entity(name, identifier, forget=False)[source]#

Remove all entities by identifier from series name from database.

Parameters:
  • name (str) – Name of series to be removed

  • identifier (str) – Series identifier to be deleted,

  • forget (bool) – Indication whether or not to fire a ‘forget’ event

Return type:

None

flexget.components.series.db.season_by_id(season_id, session=None)[source]#

Return an instance of an season by querying its ID.

Parameters:
  • season_id (int)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

Season

flexget.components.series.db.season_in_show(series_id, season_id)[source]#

Return True if episode_id is part of show with series_id, else return False.

Parameters:
  • series_id (int)

  • season_id (int)

Return type:

bool

flexget.components.series.db.season_release_by_id(release_id, session=None)[source]#

Return an instance of an episode release by querying its ID.

Parameters:
  • release_id (int)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

SeasonRelease

flexget.components.series.db.set_alt_names(alt_names, db_series, session)[source]#
Parameters:
Return type:

None

flexget.components.series.db.set_series_begin(series, ep_id)[source]#

Set beginning for series.

Parameters:
  • series (Series) – Series instance

  • ep_id (str | int) – Integer for sequence mode, SxxEyy for episodic and yyyy-mm-dd for date.

Raises:

ValueError – If malformed ep_id or series in different mode

Returns:

tuple containing identified_by and identity_type

Return type:

tuple[str, str]

flexget.components.series.db.show_by_id(show_id, session=None)[source]#

Return an instance of a show by querying its ID.

Parameters:
  • show_id (int)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

Series

flexget.components.series.db.show_episodes(series, start=None, stop=None, count=False, descending=False, session=None)[source]#

Return all episodes of a given series.

Parameters:
  • series (Series)

  • start (int | None)

  • stop (int | None)

  • count (bool)

  • descending (bool)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

int | list[Episode]

flexget.components.series.db.show_seasons(series, start=None, stop=None, count=False, descending=False, session=None)[source]#

Return all seasons of a given series.

Parameters:
  • series (Series)

  • start (int | None)

  • stop (int | None)

  • count (bool)

  • descending (bool)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

int | list[Season]

flexget.components.series.db.shows_by_exact_name(normalized_name, session=None)[source]#

Return all series matching normalized_name.

Parameters:
  • normalized_name (str)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

list[Series]

flexget.components.series.db.shows_by_name(normalized_name, session=None)[source]#

Return all series matching normalized_name.

Parameters:
  • normalized_name (str)

  • session (sessionmaker(class_='ContextSession', bind=None, autoflush=True, expire_on_commit=True))

Return type:

list[Series]

flexget.components.series.db.store_parser(session, parser, series=None, quality=None)[source]#

Push series information into database. Returns added/existing release.

Parameters:
  • session (Session) – Database session to use

  • parser (SeriesParseResult) – parser for release that should be added to database

  • series (Series) – Series in database to add release to. Will be looked up if not provided.

  • quality (Quality) – If supplied, this will override the quality from the series parser

Returns:

List of Releases

Return type:

list[SeasonRelease | EpisodeRelease]