示例#1
0
 public function index()
 {
     $modelSinger = new Model_Singers();
     $singers = $modelSinger->getSingers();
     $this->template->content = $this->template->factory('singers/index', ['singers' => $singers]);
     $this->template->display();
 }
示例#2
0
 /**
  *
  */
 public function parseYoutube()
 {
     //query db singers list model
     $singersModel = new Singers();
     $authors = $singersModel->getSingers();
     // query db video list model
     $videoModel = new VideoList();
     foreach ($authors as $author) {
         /** @var object $videoListArr */
         $videoListArr = $this->parse($author['singer_name']);
         if (!empty($videoListArr->pageInfo['totalResults'])) {
             foreach ($videoListArr as $item) {
                 $videoInfo = $this->parseVideoInfo($item->id['videoId']);
                 // set arr
                 $video = ['author' => $author['id'], 'title' => $videoInfo->items[0]->snippet->title, 'uid' => $item->id['videoId'], 'date_public' => $videoInfo->items[0]->snippet->publishedAt, 'view_count' => $videoInfo->items[0]->statistics->viewCount];
                 // write to db
                 $videoModel->setList($video);
             }
         }
     }
     //display result
     $this->listing();
 }