public static function getVideoIDList($youtubeURL, $optionalparameters, &$userid)
 {
     $optionalparameters_arr = explode(',', $optionalparameters);
     $videolist = array();
     $spq = implode('&', $optionalparameters_arr);
     $userid = VideoSource_YoutubeUserFavorites::extractYouTubeUserID($youtubeURL);
     if ($userid == '') {
         return $videolist;
     }
     //user id not found
     //alteracoes projeto portal padrao
     require_once JPATH_ADMINISTRATOR . '/components/com_youtubegallery/google/_videos.php';
     $videos = new YoutubeVideos();
     $channelID = $videos->getChannelId($userid);
     @($channelID = $channelID[0]);
     $video_raw = $videos->getVideosFromChannel($channelID, 30, 'date');
     if ($userid == '' || empty($channelID)) {
         return $videolist;
     }
     //user id not found
     for ($i = 0, $limit = count($video_raw); $i < $limit; $i++) {
         $videolist[] = 'https://www.youtube.com/watch?v=' . $video_raw[$i]['id']['videoId'];
     }
     return $videolist;
 }
 public static function getVideoIDList($youtubeURL, $optionalparameters, &$userid)
 {
     $optionalparameters_arr = explode(',', $optionalparameters);
     $videolist = array();
     $spq = implode('&', $optionalparameters_arr);
     $userid = VideoSource_YoutubeUserFavorites::extractYouTubeUserID($youtubeURL);
     if ($userid == '') {
         return $videolist;
     }
     //user id not found
     $url = 'http://gdata.youtube.com/feeds/api/users/' . $userid . '/favorites?v=2' . ($spq != '' ? '&' . $spq : '');
     //&max-results=10
     $xml = false;
     $htmlcode = YouTubeGalleryMisc::getURLData($url);
     if (strpos($htmlcode, '<?xml version') === false) {
         if (strpos($htmlcode, 'Invalid id') === false) {
             return 'Cannot load data, Invalid id';
         }
         return 'Cannot load data, no connection';
     }
     $xml = simplexml_load_string($htmlcode);
     if ($xml) {
         foreach ($xml->entry as $entry) {
             $attr = $entry->link[0]->attributes();
             if (isset($entry->link[0]) && $attr['rel'] == 'alternate') {
                 $videolist[] = $attr['href'];
             } else {
                 $attr = $entry->link[1]->attributes();
                 $videolist[] = $attr['href'];
             }
         }
     }
     return $videolist;
 }
 public static function getVideoIDList($youtubeURL, $optionalparameters, &$userid, &$datalink)
 {
     $videolist = array();
     $base_url = 'https://www.googleapis.com/youtube/v3';
     $api_key = YouTubeGalleryMisc::getSettingValue('youtube_api_key');
     if ($api_key == '') {
         return $videolist;
     }
     $userid = VideoSource_YoutubeUserFavorites::extractYouTubeUserID($youtubeURL);
     if ($userid == '') {
         return $videolist;
     }
     //user id not found
     //------------- step 1 get user favorites plylist id
     $part = 'contentDetails';
     $url = $base_url . '/channels?forUsername='******'&key=' . $api_key . '&part=' . $part;
     $htmlcode = YouTubeGalleryMisc::getURLData($url);
     //echo '$htmlcode='.$htmlcode.'</br>';
     if ($htmlcode == '') {
         return $videolist;
     }
     $j = json_decode($htmlcode);
     if (!$j) {
         return 'Connection Error';
     }
     $items = $j->items;
     $playlistid = '';
     if (isset($items[0]->contentDetails->relatedPlaylists->uploads)) {
         $playlistid = $items[0]->contentDetails->relatedPlaylists->favorites;
         if ($playlistid == '') {
             return $videolist;
         }
         //user not found or no files uploaded
     }
     //echo '$playlistid='.$playlistid.'</br>';
     // ----------------------- step 2 - get videos
     $videolist = VideoSource_YoutubePlaylist::getPlaylistVideos($playlistid, $datalink, $api_key, $optionalparameters);
     //print_r($videolist);
     //die;
     return $videolist;
 }
示例#4
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;
 }