php 如何从该视频的视频 ID 中获取 Dailymotion 视频的视频缩略图,例如在 youtube 中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13173641/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:54:19  来源:igfitidea点击:

How to get the video thumbnail from Dailymotion video from the video id of that video like in youtube?

phpdailymotion-api

提问by Derfder

For youtube I use something like this:

对于 youtube 我使用这样的东西:

<img class="video-thumbnail" src="http://img.youtube.com/vi/<?php echo $video_id; ?>/0.jpg" alt="" width="190">

where

在哪里

$video_id is the code of that video from url.

$video_id 是来自 url 的视频的代码。

Can I do something similar for Dailymotion videos

我可以为 Dailymotion 视频做类似的事情吗

回答by Ravi

You just need to add an extra thumbnailinto the link.

您只需要thumbnail在链接中添加一个额外内容。

Video URL

视频网址

https://www.dailymotion.com/video/{video_id}

Thumbnail URL

缩略图网址

https://www.dailymotion.com/thumbnail/video/{video_id}

回答by Derfder

Using the Dailymotion API

使用 Dailymotion API

https://api.dailymotion.com/video/VIDEO_ID?fields=field1,field2,...

https://api.dailymotion.com/video/VIDEO_ID?fields=field1,field2,...

Replace field1,field2 with

将 field1,field2 替换为

thumbnail_large_url (320px by 240px)
thumbnail_medium_url (160px by 120px)
thumbnail_small_url (80px by 60px)

This API request does not require any Access Tokens.

此 API 请求不需要任何访问令牌。

Example : https://api.dailymotion.com/video/xjfn0s?fields=thumbnail_small_url

示例:https: //api.dailymotion.com/video/xjfn0s?fields=thumbnail_small_url

This HTTP request returns a JSON data with the image link of the video. For processing JSON data check PHP Manual - JSON Decode

此 HTTP 请求返回带有视频图像链接的 JSON 数据。用于处理 JSON 数据检查PHP 手册 - JSON 解码

EDITAs suggested by Ravi using http://www.dailymotion.com/thumbnail/video/video_idis pretty straight forward. But different resolution images use the API

编辑正如 Ravi 所建议的那样,使用 http://www.dailymotion.com/thumbnail/video/video_id非常简单。但是不同分辨率的图片使用API

回答by Anass El Fakir

$id='xwxadz'; // ID DAILYMOTION EXAMPLE
$thumbnail_medium_url='https://api.dailymotion.com/video/'.$id.'?fields=thumbnail_medium_url';
$json_thumbnail = file_get_contents($thumbnail_medium_url);
$get_thumbnail = json_decode($json_thumbnail, TRUE);
$thumb=$get_thumbnail['thumbnail_medium_url'];
echo $thumb; // Output Example : http://s2.dmcdn.net/BJL4o/160x120-mzR.jpg

回答by Shafiq

Just a simpler way for above objective. Suppose following is the url that I want to download thumbnail

只是实现上述目标的一种更简单的方法。假设以下是我要下载缩略图的网址

http://www.dailymotion.com/video/x17pcar_hadoop-tutorial-how-to-index-and-search-data-with-solr_tech

http://www.dailymotion.com/video/x17pcar_hadoop-tutorial-how-to-index-and-search-data-with-solr_tech

From this url get last string and Extract string id

从这个 url 获取最后一个字符串和提取字符串 id

x17pcar_hadoop-tutorial-how-to-index-and-search-data-with-solr_tech

Now split above string on underscorebasis (_). First one is video id i.e. x17pcar

现在在下划线 (_) 上拆分字符串。第一个是视频 ID,即x17pcar

Now run following url using id to get thumbnail

现在使用 id 运行以下 url 以获取缩略图

http://www.dailymotion.com/thumbnail/video/x17pcar

http://www.dailymotion.com/thumbnail/video/x17pcar