After playing around with @Hawk's BASE64 discovery above, I found that everything after the BASE64 code is display info. If you remove everything between the last @ and .jpg it will load the image in the highest res it has.
I've done something similar using phantomjs and wget. This bit of phantomjs accepts a search query and returns the first result's movie poster url. You could easily change it to your needs.
var system = require('system');
if (system.args.length === 1) {
console.log('Usage: moviePoster.js <movie name>');
phantom.exit();
}
var formattedTitle = encodeURIComponent(system.args[1]).replace(/%20/g, "+");
var page = require('webpage').create();
page.open('http://m.imdb.com/find?q=' + formattedTitle, function() {
var url = page.evaluate(function() {
return 'http://www.imdb.com' + $(".title").first().find('a').attr('href');
});
page.close();
page = require('webpage').create();
page.open(url, function() {
var url = page.evaluate(function() {
return 'http://www.imdb.com' + $("#img_primary").find('a').attr('href');
});
page.close();
page = require('webpage').create();
page.open(url, function() {
var url = page.evaluate(function() {
return $(".photo").first().find('img').attr('src');
});
console.log(url);
page.close();
phantom.exit();
});
});
});
I download the image using wget for many movies in a directory using this bash script. The mp4 files have names that the IMDB likes, and that's why the first search result is nearly guaranteed to be correct. Names like "Love Exposure (2008).mp4".
for file in *.mp4; do
title="${file%.mp4}"
if [ ! -f "${title}.jpg" ]
then
wget `phantomjs moviePoster.js "$title"` -O "${title}.jpg"
fi
done
Then minidlna uses the movie poster when it builds the thumbnail database, because it has the same name as the video file.
After playing around with @Hawk's BASE64 discovery above, I found that everything after the BASE64 code is display info. If you remove everything between the last
@
and.jpg
it will load the image in the highest res it has.becomes
As I'm sure you know, the actual url for that image is
http://ia.media-imdb.com/images/M/MV5BMTI0MDcxMzE3OF5BMl5BanBnXkFtZTcwODc3OTYzMQ@@._V1._SX100_SY133_.jpg
You're going to be hard pressed to figure out how it's generated though and they don't seem to have a publicly available API.
Screenscraping is probably your best bet.
The picture seems to generally be inside a div with class=photo and the name of the a tag is poster.
The image itself is just inside the a tag.
I've done something similar using phantomjs and wget. This bit of phantomjs accepts a search query and returns the first result's movie poster url. You could easily change it to your needs.
I download the image using wget for many movies in a directory using this bash script. The mp4 files have names that the IMDB likes, and that's why the first search result is nearly guaranteed to be correct. Names like "Love Exposure (2008).mp4".
Then minidlna uses the movie poster when it builds the thumbnail database, because it has the same name as the video file.