rabin 7 years ago
parent
commit
768366c8ec
3 changed files with 41 additions and 2 deletions
  1. 1 1
      content/database/course.php
  2. 1 1
      content/lib/Base.php
  3. 39 0
      content/v1/Video.php

+ 1 - 1
content/database/course.php

@@ -86,7 +86,7 @@ return array
 		'video'		=> array
 		(
 			'type' 		=> 'varchar-300',
-			'name' 		=> '视频地址-腾讯视频直接输入网址即可',
+			'name' 		=> '视频地址-腾讯视频直接输入网址即可,如https://v.qq.com/x/page/j0515xuxz37.html',
 			'default' 	=> '',
 			'desc' 		=> '请输入视频地址',
 			'match' 	=> 'is_string',

+ 1 - 1
content/lib/Base.php

@@ -55,7 +55,7 @@ class Base
     {
         $pic = Dever::pic($pic);
         if (strstr($pic, 'http://')) {
-            //$pic = str_replace('http://', 'https://', $pic);
+            $pic = str_replace('http://', 'https://', $pic);
         }
         
         return $pic;

+ 39 - 0
content/v1/Video.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace Content\V1;
+
+use Dever;
+
+class Video
+{
+    # 从腾讯视频中解析mp4
+    public function mp4_api($link)
+    {
+        if (!$link) {
+            $link = 'https://v.qq.com/x/page/j0515xuxz37.html';
+        }
+        $key = str_replace(array('https://v.qq.com/x/page/', '.html'), '', $link);
+
+        $api = 'http://vv.video.qq.com/getinfo?vids='.$key.'&platform=101001&charge=0&otype=json';
+
+        $data = Dever::curl($api);
+
+        $data = json_decode(str_replace(array('QZOutputJson=', ';'), '', $data), true);
+        //print_r($data);die;
+        $data = $data['vl']['vi'][0];
+        $urls = $data['ul']['ui'];
+        foreach ($urls as $k => $v) {
+            if (strstr($v['url'], 'vhot2.qqvideo.tc.qq.com')) {
+                $url = $v['url'];
+            }
+        }
+        if (empty($url)) {
+            return $this->mp4_api($link);
+        }
+        $link = $url . $data['fn'] . '?vkey=' . $data['fvkey'];
+
+        return $link;
+    }
+
+    //docker run jrottenberg/ffmpeg -i http://125.39.7.23/vhot2.qqvideo.tc.qq.com/ABeZbme1SX8-pYwYN_hPTYHdjJsGJiLeTu6P2YfrUsto/j0515xuxz37.m701.mp4?vkey=3EA0D99319B7D7F439F387E804AE9C87C631D0AA8EEE639266754BF3CE14AD55F79CD0239AF29518DBAF415259976CE4767E1615F80CA41B1B12F67067E8A480A95EFD4A6B06767092DFA7252AE16CEE6AC09EBEE4525F423B840B128A7F6522902C1FA8BFC48D0D -stats $ffmpeg_options  - > out.mp4
+}