For example, check http://www.imdbapi.com/?i=&t=inception and you'll get the poster address: Poster":"http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1._SX320.jpg"
Update: Seems like the site owner had some arguments with IMDB legal staff. As mentioned in the original site, new site's address is http://www.omdbapi.com/
You can use Trakt API, you have to make a search request with the imdb ID, and the Json result given by Trakt API contains links for two images of that movie (poster and fan art) http://trakt.tv/api-docs/search-movies
这些海报图像似乎与标题页没有任何关联,因此您必须首先检索标题页,然后检索该页面的 img 元素。 好消息是,img 标签被包装在 name="poster" 的 a 标签中。 你没有说你正在使用什么样的工具,但这基本上是一个屏幕抓取操作。
Those poster images don't appear to have any correlation to the title page, so you'll have to retrieve the title page first, and then retrieve the img element for the page. The good news is that the img tag is wrapped in an a tag with name="poster". You didn't say what kind of tools you are using, but this basically a screen scraping operation.
Be aware tough, that the terms of service explicitly forbid screenscraping. You can download the IMDB database as a set of text files, but as I understand it, the IMDB movie ID is nowhere to be found in these text files.
for file in *.mp4; do
title="${file%.mp4}"
if [ ! -f "${title}.jpg" ]
then
wget `phantomjs moviePoster.js "$title"` -O "${title}.jpg"
fi
done
然后minidlna在构建缩略图数据库时使用电影海报,因为它与视频文件同名。
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.
这是我的程序,用于为 IMDB 页面上找到的电影公司生成人类可读的 html 摘要页面。 根据您的喜好更改初始 URL,它会生成一个 html 文件,您可以在其中看到标题、摘要、分数和缩略图。
npm install -g phantomjs
这是脚本,将其保存到 imdb.js
var system = require('system');
var page = require('webpage').create();
page.open('http://www.imdb.com/company/co0026841/?ref_=fn_al_co_1', function() {
console.log('Fetching movies list');
var movies = page.evaluate(function() {
var list = $('ol li');
var json = []
$.each(list, function(index, listItem) {
var link = $(listItem).find('a');
json.push({link: 'http://www.imdb.com' + link.attr('href')});
});
return json;
});
page.close();
console.log('Found ' + movies.length + ' movies');
fetchMovies(movies, 0);
});
function fetchMovies(movies, index) {
if (index == movies.length) {
console.log('Done');
console.log('Generating HTML');
genHtml(movies);
phantom.exit();
return;
}
var movie = movies[index];
console.log('Requesting data for '+ movie.link);
var page = require('webpage').create();
page.open(movie.link, function() {
console.log('Fetching data');
var data = page.evaluate(function() {
var title = $('.title_wrapper h1').text().trim();
var summary = $('.summary_text').text().trim();
var rating = $('.ratingValue strong').attr('title');
var thumb = $('.poster img').attr('src');
if (title == undefined || thumb == undefined) {
return null;
}
return { title: title, summary: summary, rating: rating, thumb: thumb };
});
if (data != null) {
movie.title = data.title;
movie.summary = data.summary;
movie.rating = data.rating;
movie.thumb = data.thumb;
console.log(movie.title)
console.log('Request complete');
} else {
movies.slice(index, 1);
index -= 1;
console.log('No data found');
}
page.close();
fetchMovies(movies, index + 1);
});
}
function genHtml(movies) {
var fs = require('fs');
var path = 'movies.html';
var content = Array();
movies.forEach(function(movie) {
var section = '';
section += '<div>';
section += '<h3>'+movie.title+'</h3>';
section += '<p>'+movie.summary+'</p>';
section += '<p>'+movie.rating+'</p>';
section += '<img src="'+movie.thumb+'">';
section += '</div>';
content.push(section);
});
var html = '<html>'+content.join('\n')+'</html>';
fs.write(path, html, 'w');
}
并像这样运行
phantomjs imdb.js
Here is my program to generate human readable html summary page for movie companies found on imdb page. Change the initial url to your liking and it generates a html file where you can see title, summary, score and thumbnail.
npm install -g phantomjs
Here is the script, save it to imdb.js
var system = require('system');
var page = require('webpage').create();
page.open('http://www.imdb.com/company/co0026841/?ref_=fn_al_co_1', function() {
console.log('Fetching movies list');
var movies = page.evaluate(function() {
var list = $('ol li');
var json = []
$.each(list, function(index, listItem) {
var link = $(listItem).find('a');
json.push({link: 'http://www.imdb.com' + link.attr('href')});
});
return json;
});
page.close();
console.log('Found ' + movies.length + ' movies');
fetchMovies(movies, 0);
});
function fetchMovies(movies, index) {
if (index == movies.length) {
console.log('Done');
console.log('Generating HTML');
genHtml(movies);
phantom.exit();
return;
}
var movie = movies[index];
console.log('Requesting data for '+ movie.link);
var page = require('webpage').create();
page.open(movie.link, function() {
console.log('Fetching data');
var data = page.evaluate(function() {
var title = $('.title_wrapper h1').text().trim();
var summary = $('.summary_text').text().trim();
var rating = $('.ratingValue strong').attr('title');
var thumb = $('.poster img').attr('src');
if (title == undefined || thumb == undefined) {
return null;
}
return { title: title, summary: summary, rating: rating, thumb: thumb };
});
if (data != null) {
movie.title = data.title;
movie.summary = data.summary;
movie.rating = data.rating;
movie.thumb = data.thumb;
console.log(movie.title)
console.log('Request complete');
} else {
movies.slice(index, 1);
index -= 1;
console.log('No data found');
}
page.close();
fetchMovies(movies, index + 1);
});
}
function genHtml(movies) {
var fs = require('fs');
var path = 'movies.html';
var content = Array();
movies.forEach(function(movie) {
var section = '';
section += '<div>';
section += '<h3>'+movie.title+'</h3>';
section += '<p>'+movie.summary+'</p>';
section += '<p>'+movie.rating+'</p>';
section += '<img src="'+movie.thumb+'">';
section += '</div>';
content.push(section);
});
var html = '<html>'+content.join('\n')+'</html>';
fs.write(path, html, 'w');
}
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.
There is one API service provider which will provide you poster image URL and many other details based on the movie name you have provided in their query string.
发布评论
评论(17)
查看
http://www.imdbapi.com/,它返回 Poster字符串中的 url。例如,检查
http://www.imdbapi.com/?i =&t=inception,您将获得海报地址:Poster":"http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@。 _V1._SX320.jpg"
更新:似乎网站所有者与 IMDB 法律人员发生了一些争执。正如原始网站中提到的,新网站的地址是 http://www.omdbapi.com/
Check out
http://www.imdbapi.com/,It returns Poster url in string.For example, check
http://www.imdbapi.com/?i=&t=inceptionand you'll get the poster address:Poster":"http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1._SX320.jpg"
Update: Seems like the site owner had some arguments with IMDB legal staff. As mentioned in the original site, new site's address is http://www.omdbapi.com/
最好的解决方案是使用 tmdb.org :
在此 api url 中使用您的 imdbid在
find/
之后:https://api.themoviedb.org/3/find/tt0111161?api_key=__YOURAPIKEY__&external_source=imdb_id
检索 json 响应并选择
poster_path
属性:例如
“poster_path”:“/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg”
在此路径前面添加
"http:// image.tmdb.org/t/p/w150"
,您将获得可在 img 标签中使用的海报 URL :-)omdbapi 可以工作,但我发现你不能真正使用这些图像(因为屏幕抓取和 如果您在 img 标签中使用它们,它们无论如何都会被阻止)
The best solution is to use tmdb.org :
use your imdbid in this api url after
find/
:https://api.themoviedb.org/3/find/tt0111161?api_key=__YOURAPIKEY__&external_source=imdb_id
Retrieve the json response and select the
poster_path
attribute:e.g.
"poster_path":"/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg"
Prepend this path with
"http://image.tmdb.org/t/p/w150"
, and you will have the poster URL that you can use in an img tag :-)omdbapi works, but I found out you cannot really use these images (because of screen scraping and they are blocked anyway if you use them in an img tag)
据我所知,URL 是一个随机字符串。
它仍然可以轻松检索。 它是名为
poster
的锚点内唯一的img
。因此,如果您正在阅读源代码,只需搜索
,它将是第一个
src="
之后的文本。但是,您需要不断更新屏幕抓取代码,因为这可能会发生变化。
您还应该意识到这些图像受版权保护,因此请务必在良好的“合理使用”理由下使用该图像。
The URL is a random string as far as I can tell.
It can still be easily retrieved. It is the only
img
inside the anchor namedposter
.So, if you are reading the source, simply search for
<a name="poster"
and it will be the text following the firstsrc="
from there.However, you will need to keep the screen scraping code updated because that will probably change.
You should also be aware that the images are copyrighted, so be careful to only use the image under a good "fair use" rationale.
我确信您知道,该图像的实际网址是
http://ia.media-imdb.com/images/M/MV5BMTI0MDcxMzE3OF5BMl5BanBnXkFtZTcwODc3OTYzMQ@@._V1._SX100_SY133_.jpg
你将很难弄清楚它是如何生成的,但他们不知道似乎没有公开可用的 API。
屏幕抓取可能是您最好的选择。
图片通常位于带有 class=photo 的 div 内,a 标签的名称是 poster。
图像本身就位于 a 标记内。
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 know that it is way too late, but in my project I used this:-
您可以使用 Trakt API,您必须使用 imdb ID 发出搜索请求,Trakt API 给出的 Json 结果包含该电影的两个图像的链接(海报和粉丝艺术)
http://trakt.tv/api-docs/search-movies
You can use Trakt API, you have to make a search request with the imdb ID, and the Json result given by Trakt API contains links for two images of that movie (poster and fan art)
http://trakt.tv/api-docs/search-movies
如果拇指就足够了,您可以使用 Facebook Graph API:
http://graph.facebook.com/?ids=http:// /www.imdb.com/title/tt0438097/
为您提供缩略图:
http://profile.ak.fbcdn.net/hprofile-ak-ash2/50289_117058658320339_650214_s.jpg< /a>
If a thumb is enough, you can use the Facebook Graph API:
http://graph.facebook.com/?ids=http://www.imdb.com/title/tt0438097/
Gets you a thumbnail:
http://profile.ak.fbcdn.net/hprofile-ak-ash2/50289_117058658320339_650214_s.jpg
这些海报图像似乎与标题页没有任何关联,因此您必须首先检索标题页,然后检索该页面的 img 元素。 好消息是,img 标签被包装在 name="poster" 的 a 标签中。 你没有说你正在使用什么样的工具,但这基本上是一个屏幕抓取操作。
Those poster images don't appear to have any correlation to the title page, so you'll have to retrieve the title page first, and then retrieve the img element for the page. The good news is that the img tag is wrapped in an a tag with name="poster". You didn't say what kind of tools you are using, but this basically a screen scraping operation.
请注意,服务条款明确禁止屏幕抓取。 您可以将 IMDB 数据库下载为一组文本文件,但据我了解,IMDB 电影在这些文本文件中找不到 ID。
Be aware tough, that the terms of service explicitly forbid screenscraping. You can download the IMDB database as a set of text files, but as I understand it, the IMDB movie ID is nowhere to be found in these text files.
我使用 phantomjs 和 wget 做了类似的事情。 phantomjs 的这段代码接受搜索查询并返回第一个结果的电影海报 url。 您可以轻松地将其更改为您的需要。
我使用此 bash 脚本使用 wget 下载目录中许多电影的图像。 mp4 文件具有 IMDB 喜欢的名称,这就是为什么第一个搜索结果几乎可以保证是正确的。 名称如“Love Exposure (2008).mp4”。
然后minidlna在构建缩略图数据库时使用电影海报,因为它与视频文件同名。
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.
这是我的程序,用于为 IMDB 页面上找到的电影公司生成人类可读的 html 摘要页面。 根据您的喜好更改初始 URL,它会生成一个 html 文件,您可以在其中看到标题、摘要、分数和缩略图。
这是脚本,将其保存到 imdb.js
并像这样运行
Here is my program to generate human readable html summary page for movie companies found on imdb page. Change the initial url to your liking and it generates a html file where you can see title, summary, score and thumbnail.
Here is the script, save it to imdb.js
And run it like so
现在,所有现代浏览器都有“检查”部分:
仅适用于 Google Chrome 100% 正确:
尝试将其作为 URL 粘贴到任何浏览器中的任何位置,您只会获得图像。
Now a days, all modern browser have "Inspect" section:
100% Correct for Google Chrome only:
Try to paste it any where as URL in any browser, you will only get the image.
您可以使用
imdb-cli
工具下载电影海报,例如You can use
imdb-cli
tool to download movie's poster, e.g.在尝试了上面 @Hawk 的 BASE64 发现之后,我发现 BASE64 代码后面的所有内容都是显示信息。 如果您删除最后一个
@
和.jpg
之间的所有内容,它将以最高分辨率加载图像。变成
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
有一个 API 服务提供商将根据您在其查询字符串中提供的电影名称为您提供海报图像 URL 和许多其他详细信息。
这里是上述服务提供商网站的链接。
您可以在您的网站内注册并使用 API 服务代码。
There is one API service provider which will provide you poster image URL and many other details based on the movie name you have provided in their query string.
Over here is the link to the above service provider's website.
You can sign up and use the API service within your code.