flexget.components.trakt.db module#

class flexget.components.trakt.db.TraktActor(actor, session)[source]#

Bases: VersionedBase

to_dict()[source]#
update(actor, session)[source]#
_sa_class_manager = {'biography': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'birthday': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'death': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'homepage': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'imdb': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'name': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'slug': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tmdb': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
biography: Mapped[str | None]#
birthday: Mapped[date | None]#
death: Mapped[date | None]#
homepage: Mapped[str | None]#
id: Mapped[int]#
imdb: Mapped[str | None]#
name: Mapped[str | None]#
slug: Mapped[str | None]#
tmdb: Mapped[int | None]#
class flexget.components.trakt.db.TraktEpisode(trakt_episode, session)[source]#

Bases: VersionedBase

update(trakt_episode, session)[source]#

Update this record from the trakt media object trakt_episode returned by the trakt api.

_sa_class_manager = {'cached_at': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'first_aired': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'imdb_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'number': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'number_abs': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'overview': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'season': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'series_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'show': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'title': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tmdb_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tvdb_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tvrage_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'updated_at': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
cached_at: Mapped[datetime | None]#
property expired#
first_aired: Mapped[datetime | None]#
id: Mapped[int]#
imdb_id: Mapped[str | None]#
number: Mapped[int | None]#
number_abs: Mapped[int | None]#
overview: Mapped[str | None]#
season: Mapped[int | None]#
series_id: Mapped[int]#
show: Mapped[TraktShow]#
title: Mapped[str | None]#
tmdb_id: Mapped[int | None]#
tvdb_id: Mapped[int | None]#
tvrage_id: Mapped[str | None]#
updated_at: Mapped[datetime | None]#
class flexget.components.trakt.db.TraktGenre(**kwargs)[source]#

Bases: VersionedBase

_sa_class_manager = {'name': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
name: Mapped[str]#
class flexget.components.trakt.db.TraktMovie(trakt_movie, session)[source]#

Bases: VersionedBase

to_dict()[source]#
update(trakt_movie, session)[source]#

Update this record from the trakt media object trakt_movie returned by the trakt api.

_actors: Mapped[list[TraktActor]]#
_sa_class_manager = {'_actors': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, '_translation_languages': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, '_translations': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'cached_at': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'genres': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'homepage': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'imdb_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'language': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'overview': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'rating': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'released': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'runtime': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'search_strings': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'slug': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tagline': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'title': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tmdb_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'trailer': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'translation_languages': <sqlalchemy.orm.attributes._create_proxied_attribute.<locals>.Proxy object>, 'updated_at': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'votes': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'year': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
_translation_languages: Mapped[str | None]#
_translations: Mapped[list[TraktMovieTranslation]]#
property actors#
cached_at: Mapped[datetime | None]#
property expired#
Returns:

True if movie details are considered to be expired, ie. need of update

genres: Mapped[list[TraktGenre]]#
homepage: Mapped[str | None]#
id: Mapped[int]#
imdb_id: Mapped[str | None]#
language: Mapped[str | None]#
overview: Mapped[str | None]#
rating: Mapped[int | None]#
released: Mapped[date | None]#
runtime: Mapped[int | None]#
search_strings: Mapped[list[TraktMovieSearchResult]]#
slug: Mapped[str | None]#
tagline: Mapped[str | None]#
title: Mapped[str | None]#
tmdb_id: Mapped[int | None]#
trailer: Mapped[str | None]#
translation_languages#
property translations#
updated_at: Mapped[datetime | None]#
votes: Mapped[int | None]#
year: Mapped[int | None]#
class flexget.components.trakt.db.TraktMovieIds(trakt_id=None, trakt_slug=None, tmdb_id=None, imdb_id=None, **kwargs)[source]#

Bases: object

Simple class that holds a variety of possible IDs that Trakt utilize in their API, eg. imdb id, trakt id.

get_trakt_id()[source]#
to_dict()[source]#

Return a dict containing id fields that are relevant for a movie.

class flexget.components.trakt.db.TraktMovieSearchResult(search, movie_id=None, movie=None)[source]#

Bases: VersionedBase

Parameters:
_sa_class_manager = {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'movie': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'movie_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'search': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
id: Mapped[int]#
movie: Mapped[TraktMovie | None]#
movie_id: Mapped[int | None]#
search: Mapped[str]#
class flexget.components.trakt.db.TraktMovieTranslation(translation, session)[source]#

Bases: VersionedBase

update(translation, session)[source]#
_sa_class_manager = {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'language': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'movie': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'movie_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'overview': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tagline': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'title': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
id: Mapped[int]#
language: Mapped[str | None]#
movie: Mapped[TraktMovie]#
movie_id: Mapped[int | None]#
overview: Mapped[str | None]#
tagline: Mapped[str | None]#
title: Mapped[str | None]#
class flexget.components.trakt.db.TraktSeason(trakt_season, session)[source]#

Bases: VersionedBase

update(trakt_season, session)[source]#

Update this record from the trakt media object trakt_episode returned by the trakt api.

_sa_class_manager = {'aired_episodes': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'cached_at': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'episode_count': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'first_aired': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'number': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'overview': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'ratings': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'series_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'show': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'title': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tmdb_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tvdb_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tvrage_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'votes': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
aired_episodes: Mapped[int | None]#
cached_at: Mapped[datetime | None]#
episode_count: Mapped[int | None]#
property expired#
first_aired: Mapped[datetime | None]#
id: Mapped[int]#
number: Mapped[int | None]#
overview: Mapped[str | None]#
ratings: Mapped[int | None]#
series_id: Mapped[int]#
show: Mapped[TraktShow]#
title: Mapped[str | None]#
tmdb_id: Mapped[int | None]#
tvdb_id: Mapped[int | None]#
tvrage_id: Mapped[str | None]#
votes: Mapped[int | None]#
class flexget.components.trakt.db.TraktShow(trakt_show, session)[source]#

Bases: VersionedBase

get_episode(season, number, session, only_cached=False)[source]#
get_season(number, session, only_cached=False)[source]#
to_dict()[source]#
update(trakt_show, session)[source]#

Update this record from the trakt media object trakt_show returned by the trakt api.

_actors: Mapped[list[TraktActor]]#
_sa_class_manager = {'_actors': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, '_translation_languages': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, '_translations': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'air_day': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'air_time': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'aired_episodes': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'cached_at': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'certification': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'country': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'episodes': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'first_aired': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'genres': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'homepage': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'imdb_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'language': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'network': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'overview': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'rating': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'runtime': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'search_strings': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'seasons': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'slug': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'status': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'timezone': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'title': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tmdb_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'trailer': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'translation_languages': <sqlalchemy.orm.attributes._create_proxied_attribute.<locals>.Proxy object>, 'tvdb_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'tvrage_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'updated_at': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'votes': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'year': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
_translation_languages: Mapped[str | None]#
_translations: Mapped[list[TraktShowTranslation]]#
property actors#
air_day: Mapped[str | None]#
air_time: Mapped[time | None]#
aired_episodes: Mapped[int | None]#
cached_at: Mapped[datetime | None]#
certification: Mapped[str | None]#
country: Mapped[str | None]#
episodes: DynamicMapped[TraktEpisode]#
property expired#
Returns:

True if show details are considered to be expired, ie. need of update

first_aired: Mapped[datetime | None]#
genres: Mapped[list[TraktGenre]]#
homepage: Mapped[str | None]#
id: Mapped[int]#
imdb_id: Mapped[str | None]#
language: Mapped[str | None]#
network: Mapped[str | None]#
overview: Mapped[str | None]#
rating: Mapped[int | None]#
runtime: Mapped[int | None]#
search_strings: Mapped[list[TraktShowSearchResult]]#
seasons: DynamicMapped[TraktSeason]#
slug: Mapped[str | None]#
status: Mapped[str | None]#
timezone: Mapped[str | None]#
title: Mapped[str | None]#
tmdb_id: Mapped[int | None]#
trailer: Mapped[str | None]#
translation_languages#
property translations#
tvdb_id: Mapped[int | None]#
tvrage_id: Mapped[str | None]#
updated_at: Mapped[datetime | None]#
votes: Mapped[int | None]#
year: Mapped[int | None]#
class flexget.components.trakt.db.TraktShowIds(trakt_id=None, trakt_slug=None, tmdb_id=None, imdb_id=None, tvdb_id=None, tvrage_id=None, **kwargs)[source]#

Bases: object

Simple class that holds a variety of possible IDs that Trakt utilize in their API, eg. imdb id, trakt id.

get_trakt_id()[source]#
to_dict()[source]#

Return a dict containing id fields that are relevant for a show/season/episode.

class flexget.components.trakt.db.TraktShowSearchResult(search, series_id=None, series=None)[source]#

Bases: VersionedBase

Parameters:
_sa_class_manager = {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'search': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'series': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'series_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
id: Mapped[int]#
search: Mapped[str]#
series: Mapped[TraktShow | None]#
series_id: Mapped[int | None]#
class flexget.components.trakt.db.TraktShowTranslation(translation, session)[source]#

Bases: VersionedBase

update(translation, session)[source]#
_sa_class_manager = {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'language': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'overview': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'show_id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'title': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
id: Mapped[int]#
language: Mapped[str | None]#
overview: Mapped[str | None]#
show_id: Mapped[int | None]#
title: Mapped[str | None]#
class flexget.components.trakt.db.TraktUserAuth(account, access_token, refresh_token, created, expires)[source]#

Bases: VersionedBase

Parameters:
_sa_class_manager = {'access_token': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'account': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'created': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'expires': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'refresh_token': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
access_token: Mapped[str | None]#
account: Mapped[str]#
created: Mapped[datetime | None]#
expires: Mapped[datetime | None]#
refresh_token: Mapped[str | None]#
flexget.components.trakt.db.delete_account(account)[source]#
flexget.components.trakt.db.device_auth()[source]#
flexget.components.trakt.db.get_access_token(account, token=None, refresh=False, re_auth=False, called_from_cli=False)[source]#

Get authorization info from a pin or refresh token.

Parameters:
  • account – Arbitrary account name to attach authorization to.

  • token (unicode) – The pin or refresh token, as supplied by the trakt website.

  • refresh (bool) – If True, refresh the access token using refresh_token from db.

  • re_auth (bool) – If True, account is re-authorized even if it already exists in db.

Raises:

RequestException – If there is a network error while authorizing.

flexget.components.trakt.db.get_api_url(*endpoint)[source]#

Get the address of a trakt API endpoint.

Parameters:

endpoint – Can by a string endpoint (e.g. ‘sync/watchlist’) or an iterable (e.g. (‘sync’, ‘watchlist’) Multiple parameters can also be specified instead of a single iterable.

Returns:

The absolute url to the specified API endpoint.

flexget.components.trakt.db.get_db_actors(ident, style)[source]#
Return type:

list[TraktActor]

flexget.components.trakt.db.get_entry_ids(entry)[source]#

Create a trakt ids dict from id fields on an entry. Prefer already populated info over lazy lookups.

Parameters:

entry (Entry)

flexget.components.trakt.db.get_item_from_cache(table, session, title=None, year=None, trakt_ids=None)[source]#

Get the cached info for a given show/movie from the database.

Parameters:
  • table – Either TraktMovie or TraktShow

  • title – Title of the show/movie

  • year – First release year

  • trakt_ids – instance of TraktShowIds or TraktMovieIds

  • session – database session object

Returns:

query result

flexget.components.trakt.db.get_session(account=None, token=None)[source]#

Create a requests session ready to talk to trakt API with FlexGet’s api key.

Can also add user level authentication if account parameter is given.

Parameters:

account – An account authorized via flexget trakt auth CLI command. If given, returned session will be authenticated for that account.

flexget.components.trakt.db.get_trakt_data(media_type, title=None, year=None, trakt_ids=None)[source]#
flexget.components.trakt.db.get_trakt_id_from_id(trakt_ids, media_type)[source]#
flexget.components.trakt.db.get_trakt_id_from_title(title, media_type, year=None)[source]#
flexget.components.trakt.db.get_translations(ident, style)[source]#
flexget.components.trakt.db.get_translations_dict(translate, style)[source]#
flexget.components.trakt.db.get_user_data(data_type, media_type, session, username)[source]#

Fetch user data from Trakt.tv on the /users/<username>/<data_type>/<media_type> end point.

Example: a user’s movie collection is fetched from /users/<username>/collection/movies.

Parameters:
  • data_type – Name of the data type eg. collection, watched etc.

  • media_type – Type of media we want <data_type> for eg. shows, episodes, movies.

  • session – A trakt requests session with a valid token

  • username – Username of the user to fetch data

Returns:

List of items from all result pages

flexget.components.trakt.db.get_username(username=None, account=None)[source]#

Return ‘me’ if account is provided and username is not.

flexget.components.trakt.db.list_actors(actors)[source]#
flexget.components.trakt.db.make_list_slug(name)[source]#

Return the slug for use in url for given list name.

flexget.components.trakt.db.token_created_date(created)[source]#
flexget.components.trakt.db.token_expire_date(expires)[source]#
flexget.components.trakt.db.token_oauth(data)[source]#