'yes'));
}else
echo json_encode(array('err'=>'Invalid remote url'));
exit();
}
//error_reporting(E_ALL); /**/
/**
* Call back function of cURL handlers
* when it downloads a file, it works with php >= 5.3.0
* @param $download_size total file size of the file
* @param $downloaded total file size that has been downloaded
* @param $upload_size total file size that has to be uploaded
* @param $uploadsed total file size that is uploaded
*
* Writes the log in file
*/
if(!isCurlInstalled())
{
exit(json_encode(array("error"=>"Sorry, we do not support remote upload")));
}
//checking if user is logged in or not
if(!userid())
exit(json_encode(array('error'=>'You are not logged in')));
if(isset($_POST['youtube']))
{
$youtube_url = $_POST['file'];
$filename = $_POST['file_name'];
$ParseUrl = parse_url($youtube_url);
parse_str($ParseUrl['query'], $youtube_url_prop);
$YouTubeId = isset($youtube_url_prop['v']) ? $youtube_url_prop['v'] : '';
if(!$YouTubeId)
{
exit(json_encode(array("error"=>"Invalid youtube url")));
}
########################################
# YouTube Api 3 Starts #
########################################
/**
* After deprecation of YouTube Api 2, ClipBucket is now evolving as
* it allos grabbing of youtube videos with API 3 now.
* @author Saqib Razzaq
*
* Tip: Replace part between 'key' to '&' to use your own key
*/
// grabs video details (snippet, contentDetails)
$youtube_content = file_get_contents('https://www.googleapis.com/youtube/v3/videos?id='.$YouTubeId.'&key=AIzaSyDOkg-u9jnhP-WnzX5WPJyV1sc5QQrtuyc&part=snippet,contentDetails');
$content = json_decode($youtube_content);
//$content = xml2array('http://gdata.youtube.com/feeds/api/videos/'.$YouTubeId);
// getting things such as title out of Snippet
$data = $content->items[0]->snippet;
// getting time out of contentDetails
$time = $content->items[0]->contentDetails->duration;
/**
* Converting YouTube Time in seconds
*/
$total = yt_time_convert($time);
/* $match_arr =
array
(
"title"=>"//",
"description"=>"//",
"tags" =>"//",
"embed_code" => "//",
"duration" => "/([0-9\:]+)<\/span>/"
);
$vid_array = array();
foreach($match_arr as $title=> $match)
{
preg_match($match,$content,$matches);
$vid_array[$title] = $matches[1];
}*/
$vid_array['title'] = $data->title;
$vid_array['description'] = $data->description;
$vid_array['tags'] = $data->title;
$vid_array['duration'] = $total;
$thumbs_array = $data->thumbnails;
$vid_array['thumbs'] =
array($thumbs_array->high->url, $thumbs_array->medium->url);
#pex($vid_array['thumbs'],true);
$vid_array['embed_code'] = '