Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ nosetests.xml

# Virtual environments
venv
*.log
*.json
Comment thread
9Mad-Max5 marked this conversation as resolved.
Outdated
40 changes: 12 additions & 28 deletions 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 @@ -374,38 +374,22 @@ def get_watchlist(list_type=None, sort=None):
yield results


@deprecated("This method returns watchlist, not watched list. "
"This will be fixed in PyTrakt 4.x to return watched list")
# @deprecated("This method returns watchlist, not watched list. "
# "This will be fixed in PyTrakt 4.x to return watched list")
@get
def get_watched(list_type=None, extended=None):
"""Return all movies or shows a user has watched sorted by most plays.

:param list_type: Optional Filter by a specific type.
Possible values: movies, shows, seasons or episodes.
:param extended: Optional value for requesting extended information.
def get_history(media):
"""
valid_type = ('movies', 'shows', 'seasons', 'episodes')

if list_type and list_type not in valid_type:
raise ValueError('list_type must be one of {}'.format(valid_type))

uri = 'sync/watched'
if list_type:
uri += '/{}'.format(list_type)
Retrieve a :class:`Movie`, :class:`TVShow`, or :class:`TVEpisode
from your history.

if list_type == 'shows' and extended:
uri += '?extended={extended}'.format(extended=extended)
:param media: Supports both the PyTrakt :class:`Movie`,
:class:`TVShow`, etc. But also supports passing custom json structures.
"""

data = yield uri
results = []
for d in data:
if 'movie' in d:
from trakt.movies import Movie
results.append(Movie(**d.pop('movie')))
elif 'show' in d:
from trakt.tv import TVShow
results.append(TVShow(**d.pop('show')))
uri = 'sync/history'
uri += f'/{media.media_type}/{media.ids["ids"]["trakt"]}'

results = yield uri
yield results


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