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
17 changes: 8 additions & 9 deletions trakt/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,21 +474,18 @@ def watchlist_movies(self):
return self._movie_watchlist

@property
@get
def movie_collection(self):
"""All :class:`Movie`'s in this :class:`User`'s library collection.
Collection items might include blu-rays, dvds, and digital downloads.
Protected users won't return any data unless you are friends.
"""
if self._movie_collection is None:
data = yield build_uri('users/{username}/collection/movies',
data = paginate('users/{username}/collection/movies',
username=slugify(self.username),
extended='metadata')
self._movie_collection = []
for movie in data:
mov = movie.pop('movie')
self._movie_collection.append(Movie(**mov))
yield self._movie_collection

self._movie_collection = self._build_movies(data, merge=False)
return self._movie_collection

@property
@get
Expand Down Expand Up @@ -518,7 +515,7 @@ def show_collection(self):
yield self._show_collection

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

:param data: List of raw movie dicts from the Trakt API
Expand All @@ -534,7 +531,9 @@ def _build_movies(data):
logger.warning("Ignoring invalid Movie with no title: %s", original)
continue

movie_data.update(movie)
if merge:
movie_data.update(movie)

movies.append(Movie(**movie_data))

return movies
Expand Down