Browse Source

fix #888 采集支持指定多个播放组

magicblack 3 years ago
parent
commit
e7f0f58906
3 changed files with 24 additions and 12 deletions
  1. 22 10
      application/api/controller/Provide.php
  2. 1 1
      application/lang/zh-cn.php
  3. 1 1
      application/lang/zh-tw.php

+ 22 - 10
application/api/controller/Provide.php

@@ -89,13 +89,22 @@ class Provide extends Base
                 }
                 $where['vod_year'] = ['in', explode(',', $year)];
             }
-            if (empty($GLOBALS['config']['api']['vod']['from']) && !empty($this->_param['from'])) {
+            if (empty($GLOBALS['config']['api']['vod']['from']) && !empty($this->_param['from']) && strlen($this->_param['from']) > 2) {
                 $GLOBALS['config']['api']['vod']['from'] = $this->_param['from'];
             }
+            // 采集播放组支持多个播放器
+            // https://github.com/magicblack/maccms10/issues/888
             if (!empty($GLOBALS['config']['api']['vod']['from'])) {
-                $where['vod_play_from'] = ['eq', trim($GLOBALS['config']['api']['vod']['from'])];
+                $vod_play_from_list = explode(',', trim($GLOBALS['config']['api']['vod']['from']));
+                $vod_play_from_list = array_unique($vod_play_from_list);
+                $vod_play_from_list = array_filter($vod_play_from_list);
+                if (!empty($vod_play_from_list)) {
+                    $where['vod_play_from'] = ['or'];
+                    foreach ($vod_play_from_list as $vod_play_from) {
+                        array_unshift($where['vod_play_from'], ['like', '%' . trim($vod_play_from) . '%']);
+                    }
+                }
             }
-
             if (!empty($GLOBALS['config']['api']['vod']['datafilter'])) {
                 $where['_string'] .= ' ' . $GLOBALS['config']['api']['vod']['datafilter'];
             }
@@ -148,7 +157,7 @@ class Provide extends Base
         for ($i=0;$i<$arr2count;$i++){
             if ($arr1count >= $i){
                 if($from!=''){
-                    if($arr2[$i]==$from){
+                    if($arr2[$i]==$from || str_contains($from, $arr2[$i])){
                         $res_xml .=  '<dd flag="'. $arr2[$i] .'"><![CDATA[' . $arr1[$i]. ']]></dd>';
                         $res_json[$arr2[$i]] = $arr1[$i];
                     }
@@ -184,18 +193,21 @@ class Provide extends Base
                     $arr_url = explode('$$$',$v['vod_play_url']);
                     $arr_server = explode('$$$',$v['vod_play_server']);
                     $arr_note = explode('$$$',$v['vod_play_note']);
-
-                    $key = array_search($GLOBALS['config']['api']['vod']['from'],$arr_from);
-                    $res['list'][$k]['vod_play_from'] = $GLOBALS['config']['api']['vod']['from'];
+                    if (str_contains($GLOBALS['config']['api']['vod']['from'], ',')) {
+                        $key = 0;
+                    } else {
+                        $key = array_search($GLOBALS['config']['api']['vod']['from'],$arr_from);
+                        $key = $key > 0 ? $key : 0;
+                    }
+                    $res['list'][$k]['vod_play_from'] = $arr_from[$key];
                     $res['list'][$k]['vod_play_url'] = $arr_url[$key];
                     $res['list'][$k]['vod_play_server'] = $arr_server[$key];
                     $res['list'][$k]['vod_play_note'] = $arr_note[$key];
-
                 }
 
             }
             else {
-                if ($GLOBALS['config']['api']['vod']['from'] != '') {
+                if ($GLOBALS['config']['api']['vod']['from'] != '' && !str_contains($GLOBALS['config']['api']['vod']['from'], ',')) {
                     $res['list'][$k]['vod_play_from'] = $GLOBALS['config']['api']['vod']['from'];
                 } else {
                     $res['list'][$k]['vod_play_from'] = str_replace('$$$', ',', $v['vod_play_from']);
@@ -262,7 +274,7 @@ class Provide extends Base
                 $xml .= '<des><![CDATA['.$v['vod_content'].']]></des>';
             }
             else {
-                if ($GLOBALS['config']['api']['vod']['from'] != ''){
+                if ($GLOBALS['config']['api']['vod']['from'] != '' && !str_contains($GLOBALS['config']['api']['vod']['from'], ',')){
                     $xml .= '<dt>' . $GLOBALS['config']['api']['vod']['from'] . '</dt>';
                 }
                 else{

+ 1 - 1
application/lang/zh-cn.php

@@ -973,7 +973,7 @@ https://www.baidu.com/123.jpg
     'admin/system/configapi/cachetime'=>'数据缓存时间',
     'admin/system/configapi/cachetime_tip'=>'数据缓存时间',
     'admin/system/configapi/from'=>'指定播放组',
-    'admin/system/configapi/from_tip'=>'指定播放组例如youku',
+    'admin/system/configapi/from_tip'=>'多个用,号分隔,如: youku,iqiyi,qvod',
     'admin/system/configapi/auth'=>'授权域名',
     'admin/system/configapi/art_tip'=>'提示信息:<br>
                             1,文章列表地址/api.php/provide/art/?ac=list<br>

+ 1 - 1
application/lang/zh-tw.php

@@ -973,7 +973,7 @@ https://www.baidu.com/123.jpg
     'admin/system/configapi/cachetime'=>'數據緩存時間',
     'admin/system/configapi/cachetime_tip'=>'數據緩存時間',
     'admin/system/configapi/from'=>'指定播放組',
-    'admin/system/configapi/from_tip'=>'指定播放組例如youku',
+    'admin/system/configapi/from_tip'=>'多個用,號分隔,如: youku,iqiyi,qvod',
     'admin/system/configapi/auth'=>'授權域名',
     'admin/system/configapi/art_tip'=>'提示信息:<br>
                             1,文章列表地址/api.php/provide/art/?ac=list<br>