On Nov 09, Andrew Kelley <[EMAIL PROTECTED]> wrote:
> Thanks for IMDbPy, it is very useful.
Hello, and thank you!
> How do you get the picture of a movie's cover, or a thumbnail of the
> movie's cover?
If present, the url is accessible through movie['cover url'].
Beware that it could be missing, so you must first test it with
something like:
if 'cover url' in movie:
...
After that, you can use the urllib module to fetch the image itself.
To provide a complete example, something like that should do the trick:
import urllib
from imdb import IMDb
ia = IMDb(#yourParameters)
movie = ia.get_movie(#theMovieID)
if 'cover url' in movie:
urlObj = urllib.urlopen(movie['cover url'])
imageData = urlObj.read()
urlObj.close()
# now you can save imageData in a file (open it in binary mode).
In the same way, a person's headshot is stored in person['headshot'].
Things to be aware of:
- covers and headshots are available only fetching the data from the
web server (via the 'http' or 'mobile' data access systems), and not
in the plain text data files ('sql' or 'local').
- using the images, you must respect the terms of the IMDb's policy;
see http://imdbpy.sourceforge.net/docs/DISCLAIMER.txt
- the images you'll get will vary in size; you can use the python-imaging
module to rescale them, if needed.
--
Davide Alberani <[EMAIL PROTECTED]> [PGP KeyID: 0x465BFD47]
http://erlug.linux.it/~da/
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Imdbpy-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/imdbpy-help