Ejemplo n.º 1
0
 function formVideoList($rawList, &$firstvideo)
 {
     $getinfomethod = YouTubeGalleryMisc::getSettingValue('getinfomethod');
     $gallery_list = array();
     $main_ordering = 10000;
     //10000 step
     foreach ($rawList as $b) {
         $datalink = '';
         $playlistid = '';
         $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);
         if (isset($listitem[4])) {
             $specialparams = $listitem[4];
         } else {
             $specialparams = '';
         }
         if ($vsn == 'youtubeplaylist') {
             require_once 'youtubeplaylist.php';
             $newlist = VideoSource_YoutubePlaylist::getVideoIDList($theLink, $specialparams, $playlistid, $datalink);
         } elseif ($vsn == 'youtubechannel') {
             require_once 'youtubechannel.php';
             $newlist = VideoSource_YoutubeChannel::getVideoIDList($theLink, $specialparams, $playlistid, $datalink);
         } elseif ($vsn == 'youtubeshow') {
             require_once 'youtubeshow.php';
             $newlist = VideoSource_YoutubeShow::getVideoIDList($theLink, $specialparams, $playlistid, $datalink);
         } elseif ($vsn == 'youtubeuserfavorites') {
             require_once 'youtubeuserfavorites.php';
             $newlist = VideoSource_YoutubeUserFavorites::getVideoIDList($theLink, $specialparams, $playlistid, $datalink);
         } elseif ($vsn == 'youtubeuseruploads') {
             require_once 'youtubeuseruploads.php';
             $newlist = VideoSource_YoutubeUserUploads::getVideoIDList($theLink, $specialparams, $playlistid, $datalink);
         } elseif ($vsn == 'youtubestandard') {
             require_once 'youtubestandard.php';
             $newlist = VideoSource_YoutubeStandard::getVideoIDList($theLink, $specialparams, $playlistid, $datalink);
         } elseif ($vsn == 'youtubesearch') {
             require_once 'youtubesearch.php';
             $newlist = VideoSource_YoutubeSearch::getVideoIDList($theLink, $specialparams, $playlistid, $datalink);
             if (!is_array($newlist)) {
                 echo 'Youtube Search: ' . $newlist;
                 die;
             }
         } elseif ($vsn == 'vimeouservideos') {
             require_once 'vimeouservideos.php';
             $newlist = VideoSource_VimeoUserVideos::getVideoIDList($theLink, $specialparams, $playlistid, $datalink);
         } elseif ($vsn == 'vimeochannel') {
             require_once 'vimeochannel.php';
             $newlist = VideoSource_VimeoChannel::getVideoIDList($theLink, $specialparams, $playlistid, $datalink);
         } elseif ($vsn == 'vimeoalbum') {
             require_once 'vimeoalbum.php';
             $newlist = VideoSource_VimeoAlbum::getVideoIDList($theLink, $specialparams, $playlistid, $datalink);
         } elseif ($vsn == 'dailymotionplaylist') {
             require_once 'dailymotionplaylist.php';
             $newlist = VideoSource_DailymotionPlaylist::getVideoIDList($theLink, $specialparams, $playlistid, $datalink);
         }
         $channels_youtube = array('youtubeuseruploads', 'youtubestandard', 'youtubeplaylist', 'youtubeshow', 'youtubeuserfavorites', 'youtubesearch', 'youtubechannel');
         $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];
             }
             //
             if (is_array($newlist)) {
                 foreach ($newlist as $theLinkItem) {
                     $item = $this->GrabVideoData($theLinkItem, $video_source, '', $getinfomethod);
                     if ($item['videoid'] != '') {
                         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('datalink' => $datalink, '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';
                     $datalink = $item['datalink'];
                     $user_info = VideoSource_YoutubeUserUploads::getUserInfo($theLink, $item);
                     if ($user_info != '') {
                         $item['channel_title'] = $user_info;
                     }
                     $item['datalink'] = $datalink . ',' . $item['datalink'];
                 }
                 $gallery_list[] = $item;
                 $gallery_list = array_merge($gallery_list, $new_List_Clean);
             }
             //for
         } elseif ($vsn == 'videolist') {
             $linkPair = explode(':', $theLink);
             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];
                 }
                 $item = array('videosource' => $vsn, 'videoid' => $vID, 'isvideo' => "0", 'imageurl' => '', 'title' => '', 'description' => '', 'specialparams' => '', 'count' => '', 'link' => '', 'ordering' => '');
                 $gallery_list[] = $item;
             }
         } else {
             $item = $this->GrabVideoData($listitem, $vsn, '', $getinfomethod);
             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;
 }
Ejemplo n.º 2
0
 public static function getVideoIDList($youtubeURL, $optionalparameters, &$playlistid, &$datalink)
 {
     //not ready yet
     //return array();
     //************************************************************************************************************************************
     $base_url = 'https://www.googleapis.com/youtube/v3';
     //https://developers.google.com/youtube/v3/docs/search/list
     /*
     		*videoType 	string 	The videoType parameter lets you restrict a search to a particular type of videos. If you specify a value for this parameter, you must also set the type parameter's value to video.
     
     		Acceptable values are:
     
     		any – Return all videos.
     		episode – Only retrieve episodes of shows.
     		movie – Only retrieve movies.
     */
     $optionalparameters_arr = explode(',', $optionalparameters);
     $videolist = array();
     $season = VideoSource_YoutubeShow::getValueOfParameter($optionalparameters_arr, 'season');
     $content_type = VideoSource_YoutubeShow::getValueOfParameter($optionalparameters_arr, 'content');
     if ($content_type == '') {
         $content_type = 'episodes';
     }
     $season = explode(':', $season);
     if (count($season) == 4) {
         $season_id = $season[2];
     } else {
         return $videolist;
     }
     //season id not found
     $optionalparameters_arr = VideoSource_YoutubeShow::deleteParameter($optionalparameters_arr, 'season');
     $optionalparameters_arr = VideoSource_YoutubeShow::deleteParameter($optionalparameters_arr, 'content');
     $part = 'id,snippet';
     $spq = implode('&', $optionalparameters_arr);
     $spq = str_replace('max-results', 'maxResults', $spq);
     $datalink = 'http://gdata.youtube.com/feeds/api/seasons/' . $season_id . '/' . $content_type . '?v=3' . ($spq != '' ? '&' . $spq : '');
     $opt = "";
     $count = YouTubeGalleryMisc::getMaxResults($spq, $opt);
     if ($count < 1) {
         $maxResults = 1;
     } elseif ($count > 50) {
         $maxResults = 50;
     } else {
         $maxResults = $count;
     }
     $videos_found = 0;
     $nextPageToken = '';
     while ($videos_found < $count) {
         $newspq = str_replace($opt, 'maxResults=' . $maxResults, $spq);
         $url = $base_url . '/playlistItems?part=' . $part . '&key=' . $api_key . '&playlistId=' . $playlistid . ($newspq != '' ? '&' . $newspq : '');
         if ($nextPageToken != '') {
             $url .= '&pageToken=' . $nextPageToken;
         }
         $htmlcode = YouTubeGalleryMisc::getURLData($url);
         if ($htmlcode == '') {
             return $videolist;
         }
         $j = json_decode($htmlcode);
         if (!$j) {
             return 'Connection Error';
         }
         $nextPageToken = $j->nextPageToken;
         $pageinfo = $j->pageInfo;
         if ($pageinfo->totalResults < $count) {
             $count = $pageinfo->totalResults;
         }
         $items = $j->items;
         if (count($items) < $maxResults) {
             $maxResults = count($items);
         }
         foreach ($xml->entry as $entry) {
             $link = $entry->link->attributes();
             $videolist[] = $link['href'];
         }
     }
     $videos_found += $maxResults;
     if ($count - $videos_found < 50) {
         $maxResults = $count - $videos_found;
     }
     return $videolist;
 }