Example #1
0
 protected function _getCountryList()
 {
     return Common::getCountryList();
 }
Example #2
0
 /**
  https://www.youtube.com/feeds/videos.xml?channel_id=CHANNELID
  https://www.youtube.com/feeds/videos.xml?user=USERNAME
  https://www.youtube.com/feeds/videos.xml?playlist_id=YOUR_YOUTUBE_PLAYLIST_NUMBER
 */
 public function rssUser()
 {
     foreach (YoutubeUser::find()->where('updated_at <=:sevenDay', [':sevenDay' => $this->sevenDaysAgo])->limit(10)->each() as $user) {
         $user->updateAttributes(['updated_at' => time()]);
         try {
             $i = 0;
             $content = @file_get_contents('https://www.youtube.com/feeds/videos.xml?user='******'entry'])) {
                 foreach ($youtube['entry'] as $value) {
                     if (isset($value['id'])) {
                         $id = $this->trimVideoId($value['id']);
                         $title = ArrayHelper::getValue($value, 'title', '');
                         if (!VideoSource::find()->where('code=:id', [':id' => $id])->exists()) {
                             $i++;
                             list($chanel, $category) = $this->getChannel($user->username, $value['author']['name'], $value['author']['uri']);
                             $model = new VideoSource();
                             $model->attributes = ['title' => $title, 'slug' => Common::renderSlug($title), 'code' => $id, 'category' => 0, 'channel' => $chanel, 'feature' => CmDefine::no, 'popular' => CmDefine::no, 'show_index' => 0, 'total_view' => rand(100, 10000), 'total_comment' => CmDefine::zeroNumber, 'total_like' => CmDefine::zeroNumber, 'total_dislike_number' => CmDefine::zeroNumber, 'avatar' => "//i.ytimg.com/vi/{$id}/mqdefault.jpg", 'tags' => '', 'description' => '', 'seo_title' => $title, 'seo_keyworks' => $title, 'seo_description' => $title, 'status' => CmDefine::status_pending, 'type' => VideoSource::TYPE_YOUTUBE];
                             $model->save();
                         }
                     }
                 }
             }
             $user->updateAttributes(['count_video' => $i]);
         } catch (Exception $exc) {
         }
     }
 }