dever 6 gadi atpakaļ
vecāks
revīzija
115bf4b230
2 mainītis faili ar 27 papildinājumiem un 18 dzēšanām
  1. 2 0
      video/lib/Live.php
  2. 25 18
      video/lib/Vod.php

+ 2 - 0
video/lib/Live.php

@@ -37,6 +37,8 @@ class Live
             if (!$data['url']) {
                 # 回放生成中
                 $data['status'] = 3;
+            } else {
+                $data = Dever::load('video/lib/vod')->avinfo($data, 'url', 'video/live');
             }
         }
 

+ 25 - 18
video/lib/Vod.php

@@ -20,10 +20,33 @@ class Vod
 
         $data['video'] = convert($data['video'], 'mp4', 'video/vod', $data['id'], 'video');
 
+        $data = $this->avinfo($data);
+        
+        return $data;
+    }
+
+
+    # 获取相关推荐
+    public function getRelation($info)
+    {
+        $where['noid'] = $info['id'];
+        $where['cate_id'] = $info['cate_id'];
+        return Dever::db('video/vod')->getRelation($where);
+    }
+
+    # 增加浏览量
+    public function addView($id)
+    {
+        Dever::db('video/vod')->addView($id);
+    }
+
+    # 解析元信息
+    public function avinfo($data, $url = 'video', $table = 'video/vod')
+    {
         # 解析视频元信息
         if (!$data['video_info']) {
-            $video_info = Dever::curl($data['video'] . '?avinfo');
-            Dever::db('video/vod')->update(array('where_id' => $data['id'], 'video_info' => $video_info));
+            $video_info = Dever::curl($data[$url] . '?avinfo');
+            Dever::db($table)->update(array('where_id' => $data['id'], 'video_info' => $video_info));
             $video_info = Dever::json_decode($video_info);
         } else {
             $video_info = Dever::json_decode($data['video_info']);
@@ -50,23 +73,7 @@ class Vod
                 }
             }
         }
-        
 
         return $data;
     }
-
-
-    # 获取相关推荐
-    public function getRelation($info)
-    {
-        $where['noid'] = $info['id'];
-        $where['cate_id'] = $info['cate_id'];
-        return Dever::db('video/vod')->getRelation($where);
-    }
-
-    # 增加浏览量
-    public function addView($id)
-    {
-        Dever::db('video/vod')->addView($id);
-    }
 }