Sync¶
This module contains Trakt.tv sync endpoint support functions
- class trakt.sync.PlaybackEntry(progress: float, paused_at: str, id: int, type: str, data: Any)¶
- data: Any¶
- id: int¶
- paused_at: str¶
- progress: float¶
- type: str¶
- class trakt.sync.Scrobbler(media, progress, app_version, app_date)¶
Scrobbling is a seemless and automated way to track what you’re watching in a media center. This class allows the media center to easily send events that correspond to starting, pausing, stopping or finishing a movie or episode.
- trakt.sync.add_to_collection(media)¶
- Add a
Movie
,TVShow
, or :class:`TVEpisode to your collection.
- Parameters:
media – Supports both the PyTrakt
Movie
,TVShow
, etc. But also supports passing custom json structures.
- Add a
- trakt.sync.add_to_history(media, watched_at=None)¶
- Add a
Movie
,TVShow
, orTVEpisode
to your watched history.
- Parameters:
media – The media object to add to your history. But also supports passing custom json structures.
watched_at – A datetime.datetime object indicating the time at which this media item was viewed. Defaults to now.
- Add a
- trakt.sync.add_to_watchlist(media)¶
- Add a
Movie
,TVShow
, orTVEpisode
to your watchlist
- Parameters:
media – Supports both the PyTrakt
Movie
,TVShow
, etc. But also supports passing custom json structures.
- Add a
- trakt.sync.checkin_media(media, app_version, app_date, message='', sharing=None, venue_id='', venue_name='')¶
Checkin a media item.
- trakt.sync.comment(media, comment_body, spoiler=False, review=False)¶
- Add a new comment to a
Movie
,TVShow
, or TVEpisode
. If you add a review, it needs to be at least 200 words.
- Parameters:
media – The media object to post the comment to
comment_body – The content of comment
spoiler – Boolean flag to indicate whether this comment contains spoilers
review – Boolean flag to determine if this comment is a review (>200 characters. Note, if comment_body is longer than 200 characters, the review flag will automatically be set to True
- Add a new comment to a
- trakt.sync.delete_checkin()¶
- trakt.sync.get_collection(list_type=None, extended=None)¶
Get all collected items in a user’s collection.
A collected item indicates availability to watch digitally or on physical media.
- Parameters:
list_type – Optional Filter by a specific type. Possible values: movies or shows.
extended – Optional value for requesting extended information.
- trakt.sync.get_playback(list_type=None)¶
Get playback progress.
Whenever a scrobble is paused, the playback progress is saved. Use this progress to sync up playback across different media centers or apps.
For example, you can start watching a movie in a media center, stop it, then resume on your tablet from the same spot. Each item will have the progress percentage between 0 and 100.
You can optionally specify a type to only get movies or episodes.
By default, all results will be returned.
Pagination is optional and can be used for something like an “on deck” feature, or if you only need a limited data set.
https://trakt.docs.apiary.io/#reference/sync/playback/get-playback-progress
- trakt.sync.get_watchlist(list_type=None, sort=None)¶
Returns all items in a user’s watchlist filtered by type. optionally with a filter for a specific item type.
The watchlist should not be used as a list of what the user is actively watching.
- Parameters:
list_type – Optional Filter by a specific type. Possible values: movies, shows, seasons or episodes.
sort – Optional sort. Only if the type is also sent. Possible values: rank, added, released or title.
https://trakt.docs.apiary.io/#reference/sync/get-watchlist/get-watchlist
- trakt.sync.rate(media, rating, rated_at=None)¶
- Add a rating from 1 to 10 to a
Movie
,TVShow
, or TVEpisode
.
- Parameters:
media – The media object to post a rating to
rating – A rating from 1 to 10 for the media item
rated_at – A datetime.datetime object or str indicating the time at which this rating was created
- Add a rating from 1 to 10 to a
- trakt.sync.remove_from_collection(media)¶
Remove a
TVShow
from your collection. :param media: Supports both the PyTraktMovie
,TVShow
, etc. But also supports passing custom json structures.
- trakt.sync.remove_from_history(media)¶
Remove the specified media object from your history
- Parameters:
media – Supports both the PyTrakt
Movie
,TVShow
, etc. But also supports passing custom json structures.
- trakt.sync.remove_from_watchlist(media)¶
Remove a
TVShow
from your watchlist. :param media: Supports both the PyTraktMovie
,TVShow
, etc. But also supports passing custom json structures.
- trakt.sync.search(query, search_type='movie', year=None, slugify_query=False)¶
Perform a search query against all of trakt’s media types.
- Parameters:
query – Your search string
search_type – The type of object you’re looking for. Must be one of ‘movie’, ‘show’, ‘episode’, or ‘person’
year – This parameter is ignored as it is no longer a part of the official API. It is left here as a valid arg for backwards compatibility.
slugify_query – A boolean indicating whether or not the provided query should be slugified or not prior to executing the query.
- trakt.sync.search_by_id(query, id_type='imdb', media_type=None, slugify_query=False)¶
Perform a search query by using a Trakt.tv ID or other external ID.
- Parameters:
query – Your search string, which should be an ID from your source
id_type – The source of the ID you’re looking for. Must be one of ‘trakt’, trakt-movie’, ‘trakt-show’, ‘trakt-episode’, ‘trakt-person’, ‘imdb’, ‘tmdb’, or ‘tvdb’
media_type – The type of media you’re looking for. May be one of ‘movie’, ‘show’, ‘episode’, or ‘person’, or a comma-separated list of any combination of those. Null by default, which will return all types of media that match the ID given.
slugify_query – A boolean indicating whether or not the provided query should be slugified or not prior to executing the query.