Skip to content
Permalink
Browse files

Add support for lists.

  • Loading branch information
wagnerrp committed Dec 3, 2012
1 parent f652982 commit 8672dbcf62b5ec0d2439e3916de5ed2583681275
Showing with 56 additions and 7 deletions.
  1. +16 −3 README
  2. +1 −1 setup.py
  3. +2 −2 tmdb3/__init__.py
  4. +37 −1 tmdb3/tmdb_api.py
19 README
@@ -80,9 +80,9 @@ This is not yet supported.
## Searching

There are currently three search methods available for use: movies, people,
and studios. Search results from TheMovieDb are sent iteratively, twenty
results per page. The search methods provided by the PyTMDB3 module return
list-like structures that will automatically grab new pages as needed.
studios, and lists. Search results from TheMovieDb are sent iteratively,
twenty results per page. The search methods provided by the PyTMDB3 module
return list-like structures that will automatically grab new pages as needed.

>>> from tmdb3 import searchMovie
>>> res = searchMovie('A New Hope')
@@ -234,6 +234,8 @@ Movie:
list(Keyword) keywords
dict(Release) releases (indexed by country)
list(Translation) translations
list(Movie) similar
list(List) lists
list(Movie) getSimilar()
None setFavorite(bool) mark favorite status for current user
None setRating(int) rate movie by current user
@@ -250,6 +252,17 @@ Movie classmethods:
list(Movie) ratedmovies() movies rated by current user
list(Movie) watchlist() movies marked to watch by current user

List:
hex string id
string name
string author
string description
integer favorites number of users that have marked list
string language
integer count
Poster poster
list(Movie) members

Person:
integer id
string name
@@ -4,7 +4,7 @@

setup(
name='tmdb3',
version='0.6.13',
version='0.6.14',
description='TheMovieDB.org APIv3 interface',
long_description="Object-oriented interface to TheMovieDB.org's v3 API.",
packages=['tmdb3']
@@ -1,8 +1,8 @@
#!/usr/bin/env python

from tmdb_api import Configuration, searchMovie, searchMovieWithYear, \
searchPerson, searchStudio, Studio, Person, Movie, \
Collection, Genre, __version__
searchPerson, searchStudio, searchList, Person, \
Movie, Collection, Genre, List, __version__
from request import set_key, set_cache
from locales import get_locale, set_locale
from tmdb_auth import get_session, set_session
@@ -22,7 +22,7 @@
Preliminary API specifications can be found at
http://help.themoviedb.org/kb/api/about-3"""

__version__="v0.6.13"
__version__="v0.6.14"
# 0.1.0 Initial development
# 0.2.0 Add caching mechanism for API queries
# 0.2.1 Temporary work around for broken search paging
@@ -56,6 +56,7 @@
# 0.6.11 Fix URL for top rated Movie query
# 0.6.12 Add support for Movie watchlist query and editing
# 0.6.13 Fix URL for rating Movies
# 0.6.14 Add support for Lists

from request import set_key, Request
from util import Datapoint, Datalist, Datadict, Element, NameRepr, SearchRepr
@@ -163,6 +164,16 @@ def __init__(self, request):
super(StudioSearchResult, self).__init__(request,
lambda x: Studio(raw=x))

def searchList(query):
ListSearchResult(Request('search/list', query=query))

class ListSearchResult( SearchRepr, PagedRequest ):
"""Stores a list of search matches."""
_name = None
def __init__(self, request):
super(ListSearchResult, self).__init__(request,
lambda x: List(raw=x))

class Image( Element ):
filename = Datapoint('file_path', initarg=1,
handler=lambda x: x.lstrip('/'))
@@ -563,12 +574,22 @@ def setWatchlist(self, value):
req.readJSON()

def getSimilar(self):
return self.similar

@property
def similar(self):
res = MovieSearchResult(Request('movie/{0}/similar_movies'\
.format(self.id)),
locale=self._locale)
res._name = 'Similar to {0}'.format(self._printable_name())
return res

@property
def lists(self):
res = ListSearchResult(Request('movie/{0}/lists'.format(self.id)))
res._name = "Lists containing {0}".format(self._printable_name())
return res

def _printable_name(self):
if self.title is not None:
s = u"'{0}'".format(self.title)
@@ -620,3 +641,18 @@ def _populate_images(self):
posters = Datalist('posters', handler=Poster, \
poller=_populate_images, sort=True)

class List( NameRepr, Element ):
id = Datapoint('id', initarg=1)
name = Datapoint('name')
author = Datapoint('created_by')
description = Datapoint('description')
favorites = Datapoint('favorite_count')
language = Datapoint('iso_639_1')
count = Datapoint('item_count')
poster = Datapoint('poster_path', handler=Poster, raw=False)

members = Datalist('items', handler=Movie)

def _populate(self):
return Request('list/{0}'.format(self.id))

0 comments on commit 8672dbc

Please sign in to comment.
You can’t perform that action at this time.