django-tmdb provides useful commands making it easy to sync TMDB with your django project's db.
$ hg clone http://bitbucket.org/zalew/django-tmdb $ ./setup.py install
or simply put the package directory /tmdb/ anywhere accessible.
Add 'tmdb' to your INSTALLED_APPS.
Set your TMDB_API_KEY in settings.py
Add results from query
$ ./manage.py tmdb_sync --query="order_by=rating&order=desc&countries=dz,tn,ly&order_by=id&order=desc" $ ./manage.py tmdb_sync --query="order_by=rating&order=desc&genres=18&min_votes=5&page=1&per_page=10"
See http://api.themoviedb.org/2.1/methods/Movie.browse for building queries.
Update a movie
$ ./manage.py tmdb_sync --update=TMDB_ID_OF_MOVIE
It will check if there's a newer version in the api. If yes, the movie will be updated.
If you want to force update regardless of new version (f.ex. you messed up with the record in the db), use --force-update.
Update all movies in db
$ ./manage.py tmdb_sync --update-all
Works as above.
I'm working on more methods for the commands.
If you don't want results to be written to db, use --test.
Call tmdb_preview_results url (/tmdb/test/) and pass qury arguments to the url. Additionally, pass a method arg with one of the currently supported values: Movie.browse, Movie.getInfo, Person.getInfo.
Example urls would be:
and the results are formatted JSON straight from the API.
Asynchronous tasks (Celery)
Currently I'm integrating it with celery, should commit soon.
Issues? Want to contribute?
Report any issues here. If you have any ideas, you can submit a proposal but better yet feel free to fork it, do it yourself and if it's ok I'll merge it.