Skip to content

Commit

Permalink
Add support for user Movie watchlist.
Browse files Browse the repository at this point in the history
  • Loading branch information
wagnerrp committed Aug 19, 2012
1 parent 52aed6e commit 45fd261
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README
Expand Up @@ -235,6 +235,9 @@ Movie:
dict(Release) releases (indexed by country)
list(Translation) translations
list(Movie) getSimilar()
None setFavorite(bool) mark favorite status for current user
None setRating(int) rate movie by current user
None setWatchlist(bool) mark watchlist status for current user

Movie classmethods:
Movie fromIMDB(imdbid) special constructor for use with IMDb codes
Expand All @@ -243,6 +246,9 @@ Movie classmethods:
list(Movie) mostpopular() based off themoviedb.org page view counts
list(Movie) toprated() based off themoviedb.org user ratings
list(Movie) upcoming() curated list, typically contains 100 movies
list(Movie) favorites() current user's favorite movies
list(Movie) ratedmovies() movies rated by current user
list(Movie) watchlist() movies marked to watch by current user

Person:
integer id
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -4,7 +4,7 @@

setup(
name='tmdb3',
version='0.6.11',
version='0.6.12',
description='TheMovieDB.org APIv3 interface',
long_description="Object-oriented interface to TheMovieDB.org's v3 API.",
packages=['tmdb3']
Expand Down
23 changes: 22 additions & 1 deletion tmdb3/tmdb_api.py
Expand Up @@ -22,7 +22,7 @@
Preliminary API specifications can be found at
http://help.themoviedb.org/kb/api/about-3"""

__version__="v0.6.11"
__version__="v0.6.12"
# 0.1.0 Initial development
# 0.2.0 Add caching mechanism for API queries
# 0.2.1 Temporary work around for broken search paging
Expand Down Expand Up @@ -54,6 +54,7 @@
# 0.6.9 Correct Movie image language filtering
# 0.6.10 Add upcoming movie classmethod
# 0.6.11 Fix URL for top rated Movie query
# 0.6.12 Add support for Movie watchlist query and editing

from request import set_key, Request
from util import Datapoint, Datalist, Datadict, Element, NameRepr, SearchRepr
Expand Down Expand Up @@ -436,6 +437,17 @@ def ratedmovies(cls, session=None):
res._name = "Movies You Rated"
return res

@classmethod
def watchlist(cls, session=None):
if session is None:
session = get_session()
account = Account(session=session)
res = MovieSearchResult(
Request('account/{0}/movie_watchlist'.format(account.id),
session_id=session.sessionid))
res._name = "Movies You're Watching"
return res

@classmethod
def fromIMDB(cls, imdbid, locale=None):
try:
Expand Down Expand Up @@ -540,6 +552,15 @@ def setRating(self, value):
req.add_data({'value':value})
req.readJSON()

def setWatchlist(self, value):
req = Request('account/{0}/movie_watchlist'.format(\
Account(session=self._session).id),
session_id=self._session.sessionid)
req.lifetime = 0
req.add_data({'movie_id':self.id,
'movie_watchlist':str(bool(value)).lower()})
req.readJSON()

def getSimilar(self):
res = MovieSearchResult(Request('movie/{0}/similar_movies'\
.format(self.id)),
Expand Down

0 comments on commit 45fd261

Please sign in to comment.