Skip to content

Commit

Permalink
Add Studio search method.
Browse files Browse the repository at this point in the history
  • Loading branch information
wagnerrp committed Jun 21, 2012
1 parent 76c8c51 commit c2bb6ae
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
16 changes: 12 additions & 4 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ This is not yet supported.

## Searching

There are currently two search methods available for use: movies and people.
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.
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.

>>> from tmdb3 import searchMovie
>>> res = searchMovie('A New Hope')
Expand All @@ -104,6 +104,14 @@ out. The people search method behaves similarly.
>>> res[0]
<Person 'Tom Hanks'>

>>> from tmdb import searchStudio
>>> res = searchStudio('Sony Pictures')
>>> res
<Search Results: Sony Pictures>
>>> res[0]
<Studio 'Sony Pictures'>


## Direct Queries

There are currently four data types that support direct access: collections,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='tmdb3',
version='0.6.2',
version='0.6.3',
description='TheMovieDB.org APIv3 interface',
long_description="Object-oriented interface to TheMovieDB.org's v3 API.",
packages=['tmdb3']
Expand Down
4 changes: 2 additions & 2 deletions tmdb3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

from tmdb_api import Configuration, searchMovie, searchPerson, Person, \
Movie, Collection, __version__
from tmdb_api import Configuration, searchMovie, searchPerson, searchStudio, \
Studio, Person, Movie, Collection, __version__
from request import set_key, set_cache
from locales import get_locale, set_locale
from tmdb_auth import get_session, set_session
Expand Down
11 changes: 11 additions & 0 deletions tmdb3/tmdb_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
# 0.6.0 Add user authentication support
# 0.6.1 Add adult filtering for people searches
# 0.6.2 Add similar movie search for Movie objects
# 0.6.3 Add Studio search

from request import set_key, Request
from util import Datapoint, Datalist, Datadict, Element, NameRepr, SearchRepr
Expand Down Expand Up @@ -110,6 +111,16 @@ def __init__(self, request):
super(PeopleSearchResult, self).__init__(request,
lambda x: Person(raw=x))

def searchStudio(query):
return StudioSearchResult(Request('search/company', query=query))

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

class Image( Element ):
filename = Datapoint('file_path', initarg=1,
handler=lambda x: x.lstrip('/'))
Expand Down

0 comments on commit c2bb6ae

Please sign in to comment.