Example #1
0
 public function actionView()
 {
     try {
         $array = array('conditions' => array('status' => array('equals' => 0)), 'limit' => 10, 'offset' => 0, 'sort' => array('_id' => EMongoCriteria::SORT_ASC));
         $tubeLink = TubeVideoLink::model()->findAll($array);
         $i = 0;
         $f = 0;
         foreach ($tubeLink as $vimeo) {
             if ($vimeo->code != '' && !empty($vimeo->link)) {
                 echo $url = 'https://vimeo.com' . $vimeo->link;
                 echo "\n";
                 $html = file_get_html($url);
                 if (is_object($html)) {
                     $description = $html->find('#info p.first', 0)->plaintext;
                     $tubeVideo = new TubeVideo();
                     $tubeVideo->name = $vimeo->title;
                     $tubeVideo->code = $vimeo->code;
                     $tubeVideo->type = $vimeo->type;
                     $tubeVideo->thumb = $vimeo->thumb;
                     $tubeVideo->description = trim($description);
                     $tubeVideo->status = 3;
                     $tubeVideo->cat_id = 1;
                     $tubeVideo->views = 0;
                     $tubeVideo->link_id = $vimeo->_id;
                     $tubeVideo->created_datetime = date('Y-m-d H:i:s');
                     $tubeVideo->updated_datetime = date('Y-m-d H:i:s');
                     $author = rand(1, 10);
                     $tubeVideo->created_by = $author;
                     $res = $tubeVideo->save();
                     if ($res) {
                         $i++;
                     } else {
                         $f++;
                     }
                 }
             }
             //update tube link
             $tubeLinkUpdate = TubeVideoLink::model()->findByPk($vimeo->_id);
             $tubeLinkUpdate->status = 1;
             $tubeLinkUpdate->updated_datetime = date('Y-m-d H:i:s');
             $res2 = $tubeLinkUpdate->save();
             var_dump($res2);
         }
         echo $i . ' videos added success, ' . $f . ' videos fail';
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
Example #2
0
 public function actionIndex($genre = '')
 {
     $crit = array('conditions' => array('status' => array('equals' => 3)), 'limit' => 10, 'sort' => array('_id' => EMongoCriteria::SORT_ASC));
     if ($genre != '') {
         $crit['conditions']['genre'] = array('equals' => $genre);
     }
     $data = TubeVideo::model()->findAll($crit);
     if ($data) {
         foreach ($data as $video) {
             $model = TubeVideo::model()->findByPk($video->_id);
             $model->updated_datetime = date('Y-m-d H:i:s');
             $model->status = 1;
             $res = $model->save();
             echo $res ? "Update status success!" : "Update fail";
             echo "\n";
             echo $video->_id;
         }
     } else {
         echo 'Not found content to active' . "\n";
     }
 }
Example #3
0
 public function actionView()
 {
     try {
         $array = array('conditions' => array('status' => array('equals' => 0)), 'limit' => 10, 'offset' => 0, 'sort' => array('_id' => EMongoCriteria::SORT_ASC));
         $tubeLink = TubeVideoLink::model()->findAll($array);
         $i = 0;
         $f = 0;
         foreach ($tubeLink as $tube) {
             if ($tube->code != '') {
                 echo $link = 'https://www.youtube.com/watch?v=' . $tube->code;
                 $html = file_get_html($link);
                 if (is_object($html)) {
                     echo 'name:' . ($name = $html->find('#eow-title', 0)->plaintext);
                     echo "\n";
                     //echo 'desc:'.$description = $html->find('#eow-description', 0)->innertext;
                     // The Regular Expression filter
                     /*$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
                                             $reg_exUrl2 = "/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
                                             $reg_exTag = "/<a ?.*>(.*)<\/a>/";
                                             //remove tag a in description
                                             if(preg_match($reg_exUrl2, $description, $tag)){
                                                 $description = preg_replace($reg_exUrl2, 'http://fan2clip.com ', $description);
                                             }
                     
                                             if(preg_match($reg_exTag, $description, $tag)){
                                                 $description = preg_replace($reg_exTag, 'http://fan2clip.com ', $description);
                                             }
                     
                                             // Check if there is a url in the text
                                             if(preg_match($reg_exUrl, $description, $url)) {
                                                 // make the urls hyper links
                                                 $description = preg_replace($reg_exUrl, '<a href="http://fan2clip.com/">Fan2Clip.com</a> ', $description);
                                             }*/
                     $description = '';
                     $tubeVideo = new TubeVideo();
                     $tubeVideo->name = trim($tube->title);
                     $tubeVideo->code = trim($tube->code);
                     $tubeVideo->thumb = $tube->thumb;
                     $tubeVideo->description = trim($description);
                     $tubeVideo->type = $tube->type;
                     $tubeVideo->tags = $tube->tags;
                     $tubeVideo->genre = isset($tube->genre) ? $tube->genre : 'news';
                     $tubeVideo->status = 3;
                     $tubeVideo->cat_id = 1;
                     $tubeVideo->views = 0;
                     $tubeVideo->link_id = $tube->_id;
                     $tubeVideo->created_datetime = date('Y-m-d H:i:s');
                     $tubeVideo->updated_datetime = date('Y-m-d H:i:s');
                     $author = rand(1, 20);
                     $tubeVideo->created_by = $author;
                     $res = $tubeVideo->save();
                     if ($res) {
                         $i++;
                     } else {
                         $f++;
                     }
                     $errors = $tubeVideo->getErrors();
                     echo '<pre>';
                     print_r($errors);
                     echo "\n";
                     var_dump($res);
                     echo '-----------' . "\n";
                     echo "\n";
                 }
             }
             //update tube link
             $tubeLinkUpdate = TubeVideoLink::model()->findByPk($tube->_id);
             $tubeLinkUpdate->status = 1;
             $tubeLinkUpdate->updated_datetime = date('Y-m-d H:i:s');
             $res2 = $tubeLinkUpdate->save();
             var_dump($res2);
         }
         echo $i . ' videos added success, ' . $f . ' videos fail';
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }