2010-12-16 205 views
20

我看到今天vimeo改變了他們流式傳輸視頻的方式,我無法再播放他們的視頻。我看到,當我生成鏈接到視頻,這是例如:如何找到vimeo視頻的下載鏈接?

http://vimeo.com/moogaloop/play/clip:6649390/1eab2a25f30f1aadaf5e306d0f40fd6c/1292498602/?q=hd 

它將我重定向到一個頁面,說「權限被拒絕」。我嘗試使用捲曲,但沒有任何成功。我聞交通,我看到它是從像流:

http://av.vimeo.com/02047/623/34209065.mp4?token=1292496582_34de09a6d13212cf26af08357d311c30 

有誰知道怎麼去工作URL將視頻文件?

我得到的影片目前的方法是:

  1. 選擇鏈接http://vimeo.com/video_id
  2. 只獲取video_id
  3. 獲取視頻的XML http://vimeo.com/moogaloop/load/clip:video_id;
  4. 解析XML並找到所需要的信息:

    • request_signature
    • request_signature_expires
    • ISHD
  5. 生成鏈接:

    $video_link = "http://vimeo.com/moogaloop/play/clip:".$video_id."/".$request_signature."/".$request_signature_expires."/?q=".$quality.""; 
    

如果我通過瀏覽器手動執行此操作,但是如果通過腳本執行操作,則不會。

+0

moogalooop鏈接現在不起作用。 – Asghar 2013-09-10 11:35:43

+0

Vimeo沒有正式支持此方法,並且可能會隨時中斷而不發出警告。唯一官方支持的以編程方式訪問視頻文件的方式是通過[API](https://developer.vimeo.com/api) – Dashron 2014-12-03 15:46:02

回答

8

花了幾個小時找出我如何能夠直接鏈接到VIMO我找到了一個很好的解決方案。因此,下面是希望直接從vimeo下載和流式傳輸視頻src的用戶的步驟。請記住,他們會阻止所有IP地址,並可能以這種方式下載視頻的主機,所以我只是停止使用他們的服務,我將永遠不會再使用它們。

步驟獲得的視頻源:

  1. 選擇鏈接http://vimeo.com/video_id
  2. 只得到video_id
  3. 獲得XML的視頻http://vimeo.com/moogaloop/load/clip:video_id;
  4. 解析XML,我覺得必要的信息我需要:

    • request_signature
    • request_signature_expires
    • isHD
  5. 然後我生成的鏈接:

    $video_link = "http://vimeo.com/moogaloop/play/clip:".$video_id."/".$request_signature."/".$request_signature_expires."/?q=".$quality.""; 
    
  6. 然後,如果你是PHP開發,您可以通過EXEC以這種方式調用wget命令

    exec("wget -b '$video_link' -a 'wget.log' -O -");

  7. 然後您閱讀日誌並找出您正在尋找的鏈接。您可以簡單地解析日誌文件。直接鏈接之間的「位置」和「[在]」

  8. 您返回的直接聯繫和清理日誌文件:

注:再次記住,這將不會永遠工作。遲早他們會阻止你的IP :)。

+0

鏈接:$ video_link =「http://vimeo.com/moogaloop/play/clip :「。$ video_id。」/「。$ request_signature。」/「。$ request_signature_expires。」/?q =「。$ quality。」「現在無法使用 – xtr 2012-03-12 03:04:06

+1

moogaloop鏈接現在不起作用。 – Asghar 2013-09-10 11:36:32

+1

現在您可以使用'http://vimeo.com/api/v2/video/ {video_id} .xml'獲取基本信息,但它不包含* request_signature *或* request_signature_expires * – Hunger 2014-10-05 18:44:37

1

僅供參考,上述示例不起作用,但非常接近。你需要發送假餅乾。因此,基本上當您使用XML訪問網頁時,您需要獲取Cookie,然後發送您在訪問最終視頻網址時收到的cookies。所以這裏是你如何使用curl在PHP中使用Yii(使用Yii):

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; 
    } 
+0

moogaloop鏈接現在不起作用。 – Asghar 2013-07-02 10:22:28

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>"; 

source

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); 
    } 
} 
0

的算法是這樣的:

  • 輸入數據:vimeoUrl。
  • content = getRemoteContent(vimeoUrl)。
  • 解析內容以查找並提取data-config-url 屬性的值。
  • 導航到data-config-url並將內容加載爲JSON對象: $ video = json_decode($ this-> getRemoteContent($ video-> getAttribute('data-config-url')));
  • 返回$ video-> request-> files-> h264-> sd-> url - 這將返回一個 直接鏈接SD質量的視頻。

這裏是我的簡單的類,對於這一刻的工作:

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')); 
3

警告上述方法不受Vimeo的支持。目前無法保證他們正在工作,或者將來會繼續工作。他們可以(也可能會)在任何時候中斷,恕不另行通知。

訪問視頻文件URL唯一正式支持的方法是通過API

如果您嘗試訪問您擁有的視頻的網址,則必須擁有PRO帳號。

如果您嘗試訪問不屬於您的視頻的網址,您應該使用embed the videoopen it with the Vimeo iOS app

1

不需要任何腳本,更不用說PHP。

我想下載受保護的視頻(嵌入在特定的網站上),即使在vimeo.com上也無法播放,因爲「隱私設置」。

簡單地火了開發者工具(Opera蜻蜓,Chrome開發者工具,等等),選擇網絡,你去:

http://pdl.vimeocdn.com/23062/181/302074466.mp4?token2=1424299768_bbeb6039c037cd429cd560d668ec851e&aksessionid=1f4d289cd1a3abe1
方法:獲取
狀態文本:206部分內容
類型:視頻/ mp4

只需複製該第一個網址並下載一些工具(我用「wget」)。
保存。

+0

在開發者工具中打開網絡面板後,可能需要點擊「播放」。 – Akom 2016-11-12 12:40:35

0

這個超級用戶的答案是過時的,所以我想我會後在這裏(沒有足夠的口碑後有)

與鉻devtools所以,我只是記錄XHR請求,並第一個請求是爲包含akamai CDN託管視頻鏈接的json文件以及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(1080)最高質量的對象,並下載該文件。格式:

https://fpdl.vimeocdn.com/vimeo-prod-skyfire-std-us/01/XXXXX/8/XXXX/XXXXXXXX.mp4?token=XXXXXXX-0xXXXXXXXXXXXXX 

請注意,X是我替換的隱私數字。

相關問題