Exemplo n.º 1
0
 public static function getVideoIDList($vimeo_user_link, $optionalparameters)
 {
     $videolist = array();
     $optionalparameters_arr = explode(',', $optionalparameters);
     $channel_id = VideoSource_VimeoChannel::extractVimeoUserID($vimeo_user_link);
     //-------------- prepare our Consumer Key and Secret
     require_once JPATH_SITE . DS . 'components' . DS . 'com_youtubegallery' . DS . 'includes' . DS . 'misc.php';
     $consumer_key = YouTubeGalleryMisc::getSettingValue('vimeo_api_client_id');
     $consumer_secret = YouTubeGalleryMisc::getSettingValue('vimeo_api_client_secret');
     if ($consumer_key == '' or $consumer_secret == '') {
         return $videolist;
     }
     //--------------
     require_once 'vimeo_api.php';
     if (!isset($_SESSION)) {
         session_start();
     }
     if (isset($_SESSION['oauth_access_token'])) {
         $s_oauth_access_token = $_SESSION['oauth_access_token'];
     } else {
         $s_oauth_access_token = '';
     }
     if (isset($_SESSION['oauth_access_token_secret'])) {
         $s_oauth_access_token_secret = $_SESSION['oauth_access_token_secret'];
     } else {
         $s_oauth_access_token_secret = '';
     }
     $vimeo = new phpVimeo($consumer_key, $consumer_secret, $s_oauth_access_token, $s_oauth_access_token_secret);
     $params = array();
     $params['channel_id'] = $channel_id;
     foreach ($optionalparameters_arr as $p) {
         $pair = explode('=', $p);
         if ($pair[0] == 'page') {
             $params['page'] = (int) $pair[1];
         }
         if ($pair[0] == 'per_page') {
             $params['per_page'] = (int) $pair[1];
         }
     }
     $videos = $vimeo->call('vimeo.channels.getVideos', $params);
     foreach ($videos->videos->video as $video) {
         $videolist[] = 'http://vimeo.com/' . $video->id;
     }
     return $videolist;
 }
Exemplo n.º 2
0
 function formVideoList($rawList, &$firstvideo)
 {
     //print_r ($rawList);
     //die;
     $gallery_list = array();
     $main_ordering = 10000;
     //10000 step
     foreach ($rawList as $b) {
         $b = str_replace("\n", '', $b);
         $b = trim(str_replace("\r", '', $b));
         $listitem = $this->csv_explode(',', $b, '"', false);
         $theLink = trim($listitem[0]);
         if (!(strpos($theLink, '/embed/') === false)) {
             //Convert Embed links to Address bar version
             $theLink = str_replace('www.youtube.com/embed/', 'youtu.be/', $theLink);
             $theLink = str_replace('youtube.com/embed/', 'youtu.be/', $theLink);
         }
         $vsn = $this->getVideoSourceName($theLink);
         //echo $vsn='$vsn='.$vsn.'<br/>';
         //die;
         if (isset($listitem[4])) {
             $specialparams = $listitem[4];
         } else {
             $specialparams = '';
         }
         if ($vsn == 'youtubeplaylist') {
             require_once 'youtubeplaylist.php';
             $newlist = VideoSource_YoutubePlaylist::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'youtubeuserfavorites') {
             require_once 'youtubeuserfavorites.php';
             $newlist = VideoSource_YoutubeUserFavorites::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'youtubeuseruploads') {
             require_once 'youtubeuseruploads.php';
             $newlist = VideoSource_YoutubeUserUploads::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'youtubestandard') {
             require_once 'youtubestandard.php';
             $newlist = VideoSource_YoutubeStandard::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'youtubesearch') {
             require_once 'youtubesearch.php';
             $newlist = VideoSource_YoutubeSearch::getVideoIDList($theLink, $specialparams, $playlistid);
             if (!is_array($newlist)) {
                 echo 'Youtube Search: ' . $newlist;
                 die;
             }
         } elseif ($vsn == 'vimeouservideos') {
             require_once 'vimeouservideos.php';
             $newlist = VideoSource_VimeoUserVideos::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'vimeochannel') {
             require_once 'vimeochannel.php';
             $newlist = VideoSource_VimeoChannel::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'vimeoalbum') {
             require_once 'vimeoalbum.php';
             $newlist = VideoSource_VimeoAlbum::getVideoIDList($theLink, $specialparams, $playlistid);
         } elseif ($vsn == 'dailymotionplaylist') {
             require_once 'dailymotionplaylist.php';
             $newlist = VideoSource_DailymotionPlaylist::getVideoIDList($theLink, $specialparams, $playlistid);
         }
         //echo '$vsn='.$vsn.'<br/>';
         //die;
         $channels_youtube = array('youtubeuseruploads', 'youtubestandard', 'youtubeplaylist', 'youtubeuserfavorites', 'youtubesearch');
         $channels_other = array('vimeouservideos', 'vimeochannel', 'vimeoalbum', 'dailymotionplaylist');
         $channels_vimeo = array('vimeouservideos', 'vimeochannel', 'vimeoalbum');
         if (in_array($vsn, $channels_youtube) or in_array($vsn, $channels_other)) {
             if (in_array($vsn, $channels_youtube)) {
                 $video_source = 'youtube';
             }
             if (in_array($vsn, $channels_vimeo)) {
                 $video_source = 'vimeo';
             }
             if ($vsn == 'dailymotionplaylist') {
                 $video_source = 'dailymotion';
             }
             $new_List_Clean = array();
             $ordering = 1;
             $startsecond = 0;
             $endsecond = 0;
             if (isset($listitem[5])) {
                 $startsecond = $listitem[5];
             }
             if (isset($listitem[6])) {
                 $endsecond = $listitem[6];
             }
             foreach ($newlist as $theLinkItem) {
                 $item = $this->GrabVideoData($theLinkItem, $video_source);
                 if ($item['videoid'] != '') {
                     //echo 'd:videoid='.$item['videoid'].'<br/>';
                     if ($firstvideo == '') {
                         $firstvideo = $item['videoid'];
                     }
                     $item['ordering'] = $main_ordering + $ordering;
                     if (isset($listitem[1])) {
                         $item['title'] = $listitem[1];
                         $item['custom_title'] = $listitem[1];
                     }
                     if (isset($listitem[2])) {
                         $item['description'] = $listitem[2];
                         $item['custom_description'] = $listitem[2];
                     }
                     if (isset($listitem[3])) {
                         if (strpos($listitem[3], '#') === false) {
                             $item['imageurl'] = $listitem[3];
                         }
                         $item['custom_imageurl'] = $listitem[3];
                     }
                     $item['startsecond'] = $startsecond;
                     $item['endsecond'] = $endsecond;
                     $new_List_Clean[] = $item;
                     $ordering++;
                 }
             }
             $item = array('videosource' => $vsn, 'videoid' => $playlistid, 'imageurl' => '', 'title' => '', 'description' => '', 'specialparams' => $specialparams, 'count' => count($new_List_Clean), 'link' => '', 'ordering' => $main_ordering, 'channel_username' => '', 'channel_title' => '', 'channel_subscribers' => '', 'channel_subscribed' => '', 'channel_location' => '', 'channel_commentcount' => '', 'channel_viewcount' => '', 'channel_videocount' => '', 'channel_description' => '', 'channel_totaluploadviews' => '');
             if ($vsn == 'youtubeuseruploads' and !(strpos($specialparams, 'moredetails=true') === false)) {
                 //Try to get channel info
                 require_once 'youtubeuseruploads.php';
                 $user_info = VideoSource_YoutubeUserUploads::getUserInfo($theLink, $item);
                 if ($user_info != '') {
                     $item['channel_title'] = $user_info;
                 }
             }
             $gallery_list[] = $item;
             $gallery_list = array_merge($gallery_list, $new_List_Clean);
             //print_r($gallery_list);
             //die;
         } elseif ($vsn == 'videolist') {
             $linkPair = explode(':', $theLink);
             //echo '$linkPair='.$linkPair.'<br/>';
             if (isset($linkPair[1])) {
                 if (trim($linkPair[1]) == 'all') {
                     $vID = -1;
                 } elseif (trim($linkPair[1]) == 'category') {
                     if (isset($linkPair[2])) {
                         $vID = 'category=' . $linkPair[2];
                     }
                 } elseif (trim($linkPair[1]) == 'catid') {
                     if (isset($linkPair[2])) {
                         $vID = 'catid=' . (int) $linkPair[2];
                     }
                 } else {
                     $vID = (int) $linkPair[1];
                     //echo '$vID='.$vID.'<br/>';
                     //die;
                 }
                 $item = array('videosource' => $vsn, 'videoid' => $vID, 'isvideo' => "0", 'imageurl' => '', 'title' => '', 'description' => '', 'specialparams' => '', 'count' => '', 'link' => '', 'ordering' => '');
                 $gallery_list[] = $item;
             }
         } else {
             $item = $this->GrabVideoData($listitem, $vsn);
             if (isset($item['videoid']) and $item['videoid'] != '') {
                 if ($firstvideo == '') {
                     $firstvideo = $item['videoid'];
                 }
                 $item['ordering'] = $main_ordering;
                 $gallery_list[] = $item;
             }
         }
         $main_ordering += 10000;
     }
     //foreach($rawList as $b)
     return $gallery_list;
 }