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) { $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, &$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; }