Skip to content
Merged
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
19 changes: 8 additions & 11 deletions trakt/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,38 +435,34 @@ def lists(self):
yield self._lists

@property
@get
def watchlist_shows(self):
"""Returns all watchlist shows of :class:`User`.
"""
if self._show_watchlist is None:
data = yield 'users/{username}/watchlist/shows'.format(
data = paginate('users/{username}/watchlist/shows',
username=slugify(self.username),
)
self._show_watchlist = []
for show in data:
show_data = show.pop('show')
show_data.update(show)
self._show_watchlist.append(TVShow(**show_data))
yield self._show_watchlist
yield self._show_watchlist
return self._show_watchlist

@property
@get
def watchlist_movies(self):
"""Returns all watchlist movies of :class:`User`.
"""
if self._movie_watchlist is None:
data = yield 'users/{username}/watchlist/movies'.format(
data = paginate('users/{username}/watchlist/movies',
username=slugify(self.username),
)
self._movie_watchlist = []
for movie in data:
mov = movie.pop('movie')
mov.update(movie)
self._movie_watchlist.append(Movie(**mov))
yield self._movie_watchlist
yield self._movie_watchlist
return self._movie_watchlist

@property
@get
Expand Down Expand Up @@ -512,7 +508,8 @@ def show_collection(self):
self._show_collection.append(show)
yield self._show_collection

def _build_watched_movies(self, data):
@staticmethod
def _build_movies(data):
"""Parse raw API response data into a list of :class:`Movie` objects.

:param data: List of raw movie dicts from the Trakt API
Expand Down Expand Up @@ -541,7 +538,7 @@ def get_watched_movies(self, page=None, limit=None):
)

data = yield uri
yield self._build_watched_movies(data)
yield self._build_movies(data)

@property
def watched_movies(self):
Expand All @@ -553,7 +550,7 @@ def watched_movies(self):
'users/{user}/watched/movies',
user=slugify(self.username),
)
self._watched_movies = self._build_watched_movies(all_movies or [])
self._watched_movies = self._build_movies(all_movies or [])
return self._watched_movies

@property
Expand Down