我看到今天vimeo改变了他们播放视频的方式,我再也无法播放他们的视频了。当我生成视频链接时,我看到了这一点,例如:
http://vimeo.com/moogaloop/play/clip:6649390/1eab2a25f30f1aadaf5e306d0f40fd6c/1292498602/?q=hd
它正在将我重定向到一个名为“Permission denied”的页面。我尝试使用curl,但没有任何成功。我嗅到了流量,我看到它是从以下内容流式传输的:
http://av.vimeo.com/02047/623/34209065.mp4?token=1292496582_34de09a6d13212cf26af08357d311c30
有人知道如何获取视频文件的工作URL吗?
目前我收到视频的方式是:
http://vimeo.com/video_id
。video_id
。http://vimeo.com/moogaloop/load/clip:video_id;
。解析XML并找到必要的信息:
生成链接:
$video_link = "http://vimeo.com/moogaloop/play/clip:".$video_id."/".$request_signature."/".$request_signature_expires."/?q=".$quality."";
如果我通过浏览器手动执行此操作,但是如果我通过脚本执行此操作则不会。
答案 0 :(得分:8)
花了几个小时才发现我如何能够直接链接到vimeo,我找到了一个很好的解决方案。因此,以下是希望直接从vimeo下载和流式传输视频src的用户的步骤。请记住,它们会阻止所有IP地址以及可能以这种方式下载视频的主机,因此我只是停止使用他们的服务,我将永远不再使用它们。)。
获取视频源的步骤:
http://vimeo.com/video_id
video_id
http://vimeo.com/moogaloop/load/clip:video_id;
解析xml,我找到了我需要的必要信息:
request_signature
request_signature_expires
isHD
然后我生成链接:
$video_link = "http://vimeo.com/moogaloop/play/clip:".$video_id."/".$request_signature."/".$request_signature_expires."/?q=".$quality."";
然后,如果你是php dev,你可以用这种方式通过exec调用wget命令
exec("wget -b '$video_link' -a 'wget.log' -O -");
然后您阅读日志并找到您要查找的链接。您只需解析日志文件即可。直接链接位于“Location:”和“[following]”
您返回直接链接并清除日志文件:)
注意:再次请记住,这不会永远有效。他们迟早会阻止你的ip :)。
答案 1 :(得分:3)
这个javascript对我有用。
var player = document.getElementsByClassName("player")[0].getAttribute("id");
player = eval(player.replace("player_", "clip"));
var time = player.config.request.timestamp;
var sig = player.config.request.signature;
var clip_id = window.location.href.substring(17);
var url = "http://player.vimeo.com/play_redirect" +
"?clip_id=" + clip_id +
"&sig=" + sig +
"&time=" + time;
var v = document.getElementById("menu");
v.style.fontSize = "4em";
v.style.lineHeight = "1em";
v.innerHTML =
"<a href='" + url + "'>SD</a>, " +
"<a href='" + url + "&quality=hd'>HD</a>";
答案 2 :(得分:3)
警告 Vimeo不支持上述方法。他们无法保证他们现在可以工作,或者将来会继续工作。他们可以(并且可能会)在任何时候破裂,而不事先通知。
唯一官方支持的访问视频文件网址的方法是API。
如果您尝试访问自己拥有的视频的网址,则必须拥有PRO帐户。
如果您尝试访问自己不拥有的视频的网址,则应embed the video或open it with the Vimeo iOS app。
答案 3 :(得分:1)
仅供参考,上面的例子不起作用,但它很接近。你需要发送假饼干。因此,基本上当您使用XML访问页面时,您需要获取cookie,然后在访问最终视频URL时发送您之前收到的cookie。所以这里是你用PHP(使用Yii)和curl:
的方式public function actionVimeo($video_id)
{
$xml_url = "http://vimeo.com/moogaloop/load/clip:$video_id";
$ch = curl_init($xml_url);
$cookieFile = Yii::app()->basePath . '/runtime/vimeocookie'. time().'.txt'; //replace this line with code to generate a writeable path in your application
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile); //the cookie file will be populated with cookies received while viewing the xml page
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); //you need to send a user agent here and it must be the same below when you visit the video url
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($output);
$request_signature = $xml->request_signature;
$request_signature_expires = $xml->request_signature_expires;
$vid_url = "http://vimeo.com/moogaloop/play/clip:".$video_id."/".$request_signature."/".$request_signature_expires."/?q=sd";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$vid_url);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); //same user agent as on previous vimeo page you visited
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile); //the cookies in that cookie file will be used while visiting the video URL
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); //vimeo changes the header location, so you gotta follow it
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$video = curl_exec($ch);
curl_close($ch);
unlink($cookieFile); //remove the temporary cookie file
$savePath = Yii::app()->basePath . '/runtime/testvim.mp4'; //change this to a path your application can write the final video to
file_put_contents($savePath, $video);
exit;
}
答案 4 :(得分:1)
不需要任何脚本,更不用说PHP了。
我想下载受保护的视频(嵌入在特定网站上),由于“隐私设置”,即使在vimeo.com上也无法播放。
只需启动开发人员工具(Opera Dragonfly,Chrome开发者工具等),选择网络即可:
http://pdl.vimeocdn.com/23062/181/302074466.mp4?token2=1424299768_bbeb6039c037cd429cd560d668ec851e&aksessionid=1f4d289cd1a3abe1
方法:获得
状态文本:206部分内容
键入:video / mp4
只需复制第一个网址并使用某种工具下载(我使用“wget”) 保存。
答案 5 :(得分:0)
快速而肮脏的方法是:
$base = 'http://player.vimeo.com/play_redirect';
$curl = curl_init(sprintf('http://player.vimeo.com/video/%s', $_GET['id']));
curl_setopt_array($curl, array(
CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
CURLOPT_RETURNTRANSFER => true
));
preg_match('/g:(\{.*?\}),a/s', curl_exec($curl), $match);
curl_close($curl);
$json = json_decode($match[1])->request;
$url = sprintf('%s?quality=sd&clip_id=%s&time=%d&sig=%s',
$base,
$_GET['id'],
$json->timestamp,
$json->signature
);
$curl = curl_init($url);
curl_setopt_array($curl, array(
CURLOPT_HEADER => true,
CURLOPT_NOBODY => true,
CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
CURLOPT_RETURNTRANSFER => true
));
$headers = explode("\r\n", curl_exec($curl));
curl_close($curl);
foreach ($headers as $header) {
if ($header) {
header($header);
}
}
答案 6 :(得分:0)
算法如下所示:
这是我的简单课程,适合这一刻:
class VideoController
{
/**
* @var array Vimeo video quality priority
*/
public $vimeoQualityPrioritet = array('sd', 'hd', 'mobile');
/**
* @var string Vimeo video codec priority
*/
public $vimeoVideoCodec = 'h264';
/**
* Get direct URL to Vimeo video file
*
* @param string $url to video on Vimeo
* @return string file URL
*/
public function getVimeoDirectUrl($url)
{
$result = '';
$videoInfo = $this->getVimeoVideoInfo($url);
if ($videoInfo && $videoObject = $this->getVimeoQualityVideo($videoInfo->request->files))
{
$result = $videoObject->url;
}
return $result;
}
/**
* Get Vimeo video info
*
* @param string $url to video on Vimeo
* @return \stdClass|null result
*/
public function getVimeoVideoInfo($url)
{
$videoInfo = null;
$page = $this->getRemoteContent($url);
$dom = new \DOMDocument("1.0", "utf-8");
libxml_use_internal_errors(true);
$dom->loadHTML('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . $page);
$xPath = new \DOMXpath($dom);
$video = $xPath->query('//div[@data-config-url]');
if ($video)
{
$videoObj = json_decode($this->getRemoteContent($video->item(0)->getAttribute('data-config-url')));
if (!property_exists($videoObj, 'message'))
{
$videoInfo = $videoObj;
}
}
return $videoInfo;
}
/**
* Get vimeo video object
*
* @param stdClass $files object of Vimeo files
* @return stdClass Video file object
*/
public function getVimeoQualityVideo($files)
{
$video = null;
if (!property_exists($files, $this->vimeoVideoCodec) && count($files->codecs))
{
$this->vimeoVideoCodec = array_shift($files->codecs);
}
$codecFiles = $files->{$this->vimeoVideoCodec};
foreach ($this->vimeoQualityPrioritet as $quality)
{
if (property_exists($codecFiles, $quality))
{
$video = $codecFiles->{$quality};
break;
}
}
if (!$video)
{
foreach (get_object_vars($codecFiles) as $file)
{
$video = $file;
break;
}
}
return $video;
}
/**
* Get remote content by URL
*
* @param string $url remote page URL
* @return string result content
*/
public function getRemoteContent($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_USERAGENT, 'spider');
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
}
使用:
$video = new VideoController;
var_dump($video->getVimeoDirectUrl('http://vimeo.com/90747156'));
答案 7 :(得分:0)
SuperUser上的答案已经过时了,所以我想我会在这里发布(没有足够的声誉在那里发布)
所以我只是用Chrome devtools记录了XHR请求,第一个请求是json文件,其中包含与akamai CDN托管视频的链接以及akamai提供的令牌。这个标记很重要。它是包含时间戳的哈希,因此这里的视频链接需要稍微下载,否则请求将被拒绝。
此JSON文件的格式为:
https://player.vimeo.com/video/VIDEO_ID/config?byline=0&collections=1&context=Vimeo%5CController%5CClipController.main&default_to_hd=1&outro=nothing&portrait=0&share=1&title=0&watch_trailer=0&s=6cffff97fffffffffff4ffffffff679ec66ffff_14ffffffff
然后我只是在JSON(1080p)中寻找最高质量的对象并下载该文件。格式为:
https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/XXXXX/8/XXXX/XXXXXXXX.mp4?token=XXXXXXX-0xXXXXXXXXXXXXX
注意X是我为隐私而替换的数字。
答案 8 :(得分:0)
浏览器的扩展名Vimeo video downloader有助于实现这一目标。
在Chrome或Edge浏览器中安装扩展程序后,然后单击页面中的Download
按钮。最后,您可以下载所需质量的视频。
此扩展程序还可以帮助您下载需要输入密码的私人vimeo视频,当然,您需要知道密码。这里没有裂缝。
答案 9 :(得分:0)
对于 Python,要获取视频的直接 (.mp4) URL,您可以使用 vimeo-downloader 包
from vimeo_downloader import Vimeo
url = 'https://vimeo.com/video_id'
v = Vimeo(url)
best_stream = v.streams[-1] # Select best video quality
print(best_stream.direct_url)
# https://vod-progressive.akamaized.net.../2298326263.mp4
首先你需要安装它:
pip install vimeo-downloader