<?php $youtube = new BigTreeYouTubeAPI(); $channels = $youtube->searchChannels($_POST["query"]); if (is_array($channels->Results)) { foreach ($channels->Results as $channel) { $cached_info = htmlspecialchars(json_encode(array("image" => $channel->Images->Default, "name" => $channel->Title))); ?> <a class="with_image" href="#" data-id="<?php echo $channel->ID; ?> " data-image="<?php echo $channel->Images->Default; ?> " data-name="<?php echo $channel->Title; ?> " data-cache="<?php echo $cached_info; ?> "><?php echo $channel->Title; ?> <img src="<?php echo $channel->Images->Default; ?> " alt="" /></a> <?php } }
| /v/ # or /v/ | .*v= # or /watch\\?v= ) # End path alternatives. ) # End host alternatives. ([\\w-]{10,12}) # Allow 10-12 for 11 char youtube id. ($|&).* # if additional parameters are also in query string after video id. $%x'; $result = preg_match($pattern, $url, $matches); // No ID match? Bad URL. if ($result === false) { $bigtree["errors"][] = array("field" => $field["title"], "error" => "The URL you entered is not a valid YouTube URL."); $field["ignore"] = true; // Got our YouTube ID } else { $video_id = $matches[1]; $youtube = new BigTreeYouTubeAPI(); $video = $youtube->getVideo($video_id); // Invalid YouTube video :( if (!$video) { $bigtree["errors"][] = array("field" => $field["title"], "error" => "The YouTube URL provided is invalid."); $field["ignore"] = true; } else { // Try for max resolution first, then high, then default $source_image = $video->Images->Maxres ? $video->Images->Maxres : $video->Images->High; $source_image = $source_image ? $source_image : $video->Images->Default; $field["output"] = array("service" => "youtube", "id" => $video_id, "height" => false, "width" => false, "duration" => $video->Duration->Hours * 3600 + $video->Duration->Minutes * 60 + $video->Duration->Seconds, "embed" => $video->Embed); } } // Vimeo } elseif (strpos($url, "vimeo.com") !== false) { $url_pieces = explode("/", $url);