小赖子的英国生活和资讯

第一视频解析下载的经验和技巧

阅读 桌面完整版

第一视频 v1.cn 的视频播放器是用FLASH做的, 所以你直接查看的FLASH视频的地址是一个SWF的地址 是没有啥卵用的, 不过你仔细一看, HTML代码里的SWF地址后面会有一个真正的视频地址, videoUrl所指向的值就是.

1
2
<param value="id=2470427&startSwfUrl=http://www.v1.cn/player/cloud/loading.swf&videoUrl=
 http://f02.v1.cn/transcode/14506452FLVSDT1.flv" name="FlashVars" />
<param value="id=2470427&startSwfUrl=http://www.v1.cn/player/cloud/loading.swf&videoUrl=
 http://f02.v1.cn/transcode/14506452FLVSDT1.flv" name="FlashVars" />

在客户端下载第一视频的JS代码如下 (第一视频解析下载的 Chrome 插件):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
if (domain.includes("v1.cn")) {
    if (!ValidURL(video_url)) {
        video_dom = document.querySelector("param[name='FlashVars']");
        if (video_dom) {
            var tmp = video_dom.getAttribute("value");   
            if (tmp.length) {
                var re = /videoUrl=(.*)/i;
                var found = re.exec(tmp);
                if (found != null) {
                    if (ValidURL(found[1])) {
                        video_url = found[1];
                    }
                }
            }
        }
    }                
}  
if (domain.includes("v1.cn")) {
    if (!ValidURL(video_url)) {
        video_dom = document.querySelector("param[name='FlashVars']");
        if (video_dom) {
            var tmp = video_dom.getAttribute("value");   
            if (tmp.length) {
                var re = /videoUrl=(.*)/i;
                var found = re.exec(tmp);
                if (found != null) {
                    if (ValidURL(found[1])) {
                        video_url = found[1];
                    }
                }
            }
        }
    }                
}  

在服务端PHP解析视频的代码如下 (远程服务器下载第一视频的在线工具):

1
2
3
4
5
6
7
8
9
10
11
12
function download_v1cn_video($url) {    
  $doc = phpQuery::newDocumentFile($url);      
  $tag = trim(strip_tags($doc->find("param[name='FlashVars']")->attr('value')));
  if ($tag) {
    if (preg_match('~videoUrl=(.*)~', $tag, $matches)) {
      if (is_good_url($matches[1])) {
        return $matches[1]; 
      }
    }       
  }
  return ""; // 无法解析v1cn第一视频地址
}
function download_v1cn_video($url) {    
  $doc = phpQuery::newDocumentFile($url);      
  $tag = trim(strip_tags($doc->find("param[name='FlashVars']")->attr('value')));
  if ($tag) {
    if (preg_match('~videoUrl=(.*)~', $tag, $matches)) {
      if (is_good_url($matches[1])) {
        return $matches[1]; 
      }
    }       
  }
  return ""; // 无法解析v1cn第一视频地址
}

第一视频解析下载的经验和技巧

视频下载相关技术帖子

视频下载相关的几个帖子:

强烈推荐

微信公众号: 小赖子的英国生活和资讯 JustYYUK

阅读 桌面完整版
Exit mobile version