乐视真实视频解析

时间:2019-06-05

PHP源代码

<?php
$id = Le::parse($url);
$video_info = Le::parseVideoUrl($id);
echo json_encode($video_info);
/**
* 
*/
class Le
{
	public static function parse($url)
    {
    	$content = self::curl($url);
        preg_match('#vid: (.*?),#',$content,$vids);
        preg_match('#isPay: (.*?),#',$content,$isPay);
        $vid = $vids[1];
        $pay = $isPay[1];//是否付费
        return $vid;
    }
	public static function parseVideoUrl($vid){
		$time = number_format(microtime(true),3,'.',''); 
		$tkey = self::getMmsKey($time);
		//$url = "http://player-pc.le.com/mms/out/video/playJson?id={$vid}&format=1&tkey={$tkey}&domain=www.le.com&dvtype=1000&region=cn&accessyx=1&platid=3&splatid=304&source=1000&tss=no";
		$url = "http://player-pc.le.com/mms/out/video/playJson?id={$vid}&platid=1&splatid=105&format=1&tkey={$tkey}&domain=www.le.com&dvtype=720p&devid=70A6E0A1FB93DA437B79DA594B3C9D03B428043B&region=cn&source=1000&accessyx=1&tss=no";//&tss=tvts
 
		$data = self::curl($url);
		$content = json_decode($data,true);
		$playurl = $content["msgs"]["playurl"];
		$point = $content["msgs"]["point"];
		$hot = $point["hot"];
		$seek = $point["skip"][0];
 
		$pic = $playurl["picAll"]["640*320"];
		$domains = array("http://play.g3proxy.lecloud.com","http://bplay.g3proxy.lecloud.com","http://g3.letv.com");
		$domain = $domains[0];//$domains[mt_rand(0,count($domains)-1)];
		$dispatch = $playurl["dispatch"];
		$duration = $playurl["duration"];
   		$count = 0;
		foreach ($dispatch as $key => $value) {
			switch ($key) {
				case '350':$def = "流畅";break;
				case '1000':$def = "超清";break;
				case '1300':$def = "原画";break;
				case '720p':$def = "720P";break;
				case '1080p':$def = "1080P";break;
			}
			$vurl = self::getVideoUrl($domain.$value[0]."&format=1&expect=3&sign=letv"); //&format=1为json &format=1为xml  preg_replace("#/vod/v2/#","/
 
			if (GlobalBase::is_ipad()) {
				if($key =="1000"){
					$videoinfo["video"]["file"] = $vurl;
					$videoinfo["video"]["type"] = "video/mp4";
				}
         	}else{
			  	$video[0] = $vurl;
				$video[1] = "video/mp4";
				$video[2] = $def;
				$video[3] =  $key !="1000"? 0 : 10;
				$videoinfo["video"][$count] = $video;
				$count++;
         	}
		}
   		return $videoinfo;
	}
	public static function curl($url,$cookie="")
	{
    	$params["ua"] = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36";
    	$params["cookie"] = $cookie;
      	return GlobalBase::curl($url,$params);
	}
	//==================================================以下代码不需要修改==========================================================
	/**
	 * [getVideoUrl 获取视频最终地址]
	 * @param  [type] $url [description]
	 * @return [type]      [description]
	 */
	private static function getVideoUrl($url){
		$data = GlobalBase::curl($url);
		$content = json_decode($data,true);
		$location = $content["location"];
		$nodelist = $content["nodelist"];
		$vurl = $nodelist[mt_rand(0,count($nodelist)-1)]["location"];
		return $location;
	}
	//========================================= 方式二 =================================================
	/**
	 * [getMmsKey 获取tkey]
	 * @param  [type] $e [时间]
	 * @return [type]    [description]
	 */
  	private static function getMmsKey($e)
    {
        $t = 185025305;
        $r = 8;
        $n = $e;
        $n = self::rotateRight($n, $r);
        $o = self::s2v("O",$n, $t);
        return $o;
    }
    private static function rotateRight($e, $t)
    {
        for ($r, $n = 0; self::s2v("g",$t, $n); $n++){
            $r = self::s2v("o",1,$e);
            $e >>= 1;
            $r <<= 31;
            $e += $r;
        }
        return $e;
    }
    private static function s2v($k,$y,$r){
        switch ($k) {
            case 'D':return $y | $r;break;
            case 'd':return $y % $r;break;
            case 'O':return $y ^ $r;break;
            case 'k':return $y < $r;break;
            case 'J':return $y >> $r;break;
            case 'R':return $y === $r;break;
            case 'g':return $y > $r;break;
            case 'o':return $y & $r;break;
            case 'l':return $y !== $r;break;
            case 'L':return $y != $r;break;
            case 'a':return $y - $r;break;
            case 'u':return $y == $r;break;
            case 'e':return $y << $r;break;
        }
    }
}
?>

 

  1. 鲤鱼泡泡说道:

    大神,这个怎么调用啊?我测试了一下,返回null,能给个调用示例吗?谢谢

    1. 隐士说道:

      这个我是在某个一次解析源码里面找到的,发表的时候还是有效。
      现在不知道有没改动
      播放里面中:< ?php echo "/parse.php?url=";?>

      parse文件中包含
      # 乐视
      require_once("video/class.le.php");

      你直接把你需要播放的链接替换文中第一行的$url试试
      $id = Le::parse($url);

      1. 鲤鱼泡泡说道:

        谢谢回复,已经可以提取地址出来了,但是分辨率无法搞定,只有把分辨率那部分删除才能提取出来,而且会员视频还是只能看十分钟左右。

    2. 隐士说道:

      其他的你自己看源码
      下载:https://www.lanzous.com/i58dgda

      1. 鲤鱼泡泡说道:

        看明白了,虽然可以正确解析出地址,但是没有cookie提交会员信息,观看依然受限制,分辨率问题也搞明白了,谢谢大神。

发表评论

邮箱地址不会被公开。 必填项已用*标注