Home php教程 PHP源码 用PHP嗅探youku视频的真实地址!

用PHP嗅探youku视频的真实地址!

May 25, 2016 pm 05:04 PM

PHP代码

<?php 
//--调用方法http://xiaomizhou.net/demo/flv.php?url=http://v.youku.com/v_show/id_XMzg2OTQ3MjQw.html
echo fetch_youku_flv($_GET[&#39;url&#39;]); 
function fetch_youku_flv($url){ 
    preg_match("#id_(.*?)\.html#",$url,$out); 
    $id=$out[1]; 
    $content=get_curl_contents(&#39;http://v.youku.com/player/getPlayList/VideoIDS/&#39;.$id); 
    $data=json_decode($content); 
    foreach($data->data[0]->streamfileids AS $k=>$v){ 
    $sid=getSid(); 
    $fileid=getfileid($v,$data->data[0]->seed); 
    $one=($data->data[0]->segs->$k); 
    if($k == &#39;flv&#39; || $k == &#39;mp4&#39;) return "http://f.youku.com/player/getFlvPath/sid/{$sid}_00/st/{$k}/fileid/{$fileid}?K={$one[0]->k}"; 
    continue; 
    } 
}  
function get_curl_contents($url, $second = 5){ 
    if(!function_exists(&#39;curl_init&#39;)) die(&#39;php.ini未开启php_curl.dll&#39;); 
    $c = curl_init(); 
    curl_setopt($c,CURLOPT_URL,$url); 
    $UserAgent=$_SERVER[&#39;HTTP_USER_AGENT&#39;]; 
    curl_setopt($c,CURLOPT_USERAGENT,$UserAgent); 
    curl_setopt($c,CURLOPT_HEADER,0); 
    curl_setopt($c,CURLOPT_TIMEOUT,$second); 
    curl_setopt($c,CURLOPT_RETURNTRANSFER, true); 
    $cnt = curl_exec($c); 
    $cnt=mb_check_encoding($cnt,&#39;utf-8&#39;)?iconv(&#39;gbk&#39;,&#39;utf-8//IGNORE&#39;,$cnt):$cnt; //字符编码转换 
    curl_close($c); 
    return $cnt; 
} 
function getSid() { 
    $sid = time().(rand(0,9000)+10000); 
    return $sid; 
} 
function getkey($key1,$key2){ 
    $a = hexdec($key1); 
    $b = $a ^ 0xA55AA5A5; 
    $b = dechex($b); 
    return $key2.$b; 
} 
function getfileid($fileId,$seed) { 
    $mixed = getMixString($seed); 
    $ids = explode("*",$fileId); 
    unset($ids[count($ids)-1]); 
    $realId = ""; 
    for ($i=0;$i < count($ids);++$i) { 
    $idx = $ids[$i]; 
    $realId .= substr($mixed,$idx,1); 
    } 
    return $realId; 
} 
function getMixString($seed) { 
    $mixed = ""; 
    $source = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\\:._-1234567890"; 
    $len = strlen($source); 
    for($i=0;$i< $len;++$i){ 
    $seed = ($seed * 211 + 30031) % 65536; 
    $index = ($seed / 65536 * strlen($source)); 
    $c = substr($source,$index,1); 
    $mixed .= $c; 
    $source = str_replace($c, "",$source); 
    } 
    return $mixed; 
}
Copy after login

                   

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)