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

added get histroy #35

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion trakt/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "Unknown"
__version__ = "alpha"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must not be modified. this is filled automatically by CI on release.

19 changes: 18 additions & 1 deletion trakt/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from trakt.utils import slugify, timestamp

__author__ = 'Jon Nappi'
__all__ = ['Scrobbler', 'comment', 'rate', 'add_to_history', 'get_collection',
__all__ = ['Scrobbler', 'comment', 'rate', 'get_history', 'add_to_history', 'get_collection',
'get_watchlist', 'add_to_watchlist', 'remove_from_history',
'remove_from_watchlist', 'add_to_collection',
'remove_from_collection', 'search', 'search_by_id', 'checkin_media',
Expand Down Expand Up @@ -409,6 +409,23 @@ def get_watched(list_type=None, extended=None):
yield results


@get
def get_history(media):
"""
Retrieve a :class:`Movie`, :class:`TVShow`, or :class:`TVEpisode
from your history.

:param media: Supports both the PyTrakt :class:`Movie`,
:class:`TVShow`, etc. But also supports passing custom json structures.
"""

uri = 'sync/history'
uri += f'/{media.media_type}/{media.trakt}'

results = yield uri
yield results


@get
def get_collection(list_type=None, extended=None):
"""
Expand Down
18 changes: 16 additions & 2 deletions trakt/tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
__all__ = ['dismiss_recommendation', 'get_recommended_shows', 'genres',
'popular_shows', 'trending_shows', 'updated_shows',
'recommended_shows', 'played_shows', 'watched_shows',
'collected_shows', 'anticipated_shows', 'TVShow', 'TVEpisode',
'collected_shows', 'anticipated_shows', 'studios', 'TVShow', 'TVEpisode',
'TVSeason', 'Translation']


Expand Down Expand Up @@ -201,6 +201,20 @@ def anticipated_shows(page=1, limit=10, extended=None):
data = yield uri
yield [TVShow(**show['show']) for show in data]

@get
def studios(tvshow):
"""
Check :class:`TVShow`' for published studios
as well the title can be passed directly.
"""
if isinstance(tvshow, TVShow):
title = tvshow.slug

uri = f'shows/{title}/studios'

data = yield uri
yield data


class TVShow(IdsMixin):
"""A Class representing a TV Show object."""
Expand Down Expand Up @@ -341,7 +355,7 @@ def progress(self):
The next_episode will be the next episode the user should collect,
if there are no upcoming episodes it will be set to null.
"""
return self._progress('collection')
return self._progress('watched')

@get
def collection_progress(self, **kwargs):
Expand Down