Skip to content

Commit

Permalink
Add searchCollection function.
Browse files Browse the repository at this point in the history
  • Loading branch information
wagnerrp committed Dec 3, 2012
1 parent 8672dbc commit 867e733
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
7 changes: 4 additions & 3 deletions README
Expand Up @@ -80,9 +80,10 @@ This is not yet supported.
## Searching

There are currently three search methods available for use: movies, people,
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.
studios, lists, and collections. 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 Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -4,7 +4,7 @@

setup(
name='tmdb3',
version='0.6.14',
version='0.6.15',
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
@@ -1,8 +1,8 @@
#!/usr/bin/env python

from tmdb_api import Configuration, searchMovie, searchMovieWithYear, \
searchPerson, searchStudio, searchList, Person, \
Movie, Collection, Genre, List, __version__
searchPerson, searchStudio, searchList, searchCollection, \
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
Expand Down
21 changes: 18 additions & 3 deletions 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.14"
__version__="v0.6.15"
# 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 @@ -57,6 +57,7 @@
# 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
# 0.6.15 Add ability to search Collections

from request import set_key, Request
from util import Datapoint, Datalist, Datadict, Element, NameRepr, SearchRepr
Expand Down Expand Up @@ -164,8 +165,8 @@ def __init__(self, request):
super(StudioSearchResult, self).__init__(request,
lambda x: Studio(raw=x))

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

class ListSearchResult( SearchRepr, PagedRequest ):
"""Stores a list of search matches."""
Expand All @@ -174,6 +175,20 @@ def __init__(self, request):
super(ListSearchResult, self).__init__(request,
lambda x: List(raw=x))

def searchCollection(query, locale=None):
return CollectionSearchResult(Request('search/collection', query=query),
locale=locale)

class CollectionSearchResult( SearchRepr, PagedRequest ):
"""Stores a list of search matches."""
_name=None
def __init__(self, request, locale=None):
if locale is None:
locale = get_locale()
super(CollectionSearchResult, self).__init__(
request.new(language=locale.language),
lambda x: Collection(raw=x, locale=locale))

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

0 comments on commit 867e733

Please sign in to comment.