I'm kind of in a pickle at the moment! I have a PHP script here which converts an inputted YouTube URL into an MP4, although after it's converted it into the MP4, I would like it to finally convert into a tinyurl. I've tried but I really don't understand how I could do so, so if anyone could lend a hand, then I'd definitely be grateful!
+rep to any help!
PHP Code:<?php
$youtube = $_GET['web'];
function getstring($string)
{
$pos = strrpos($string, "swfArgs")+11;
$texto = substr($string,$pos,strrpos(substr($string,$pos,strlen($string)), "additionalStatsHonorsUrl")-10);
$replace = array(" ",'"',"_");
$adata = split(",",str_replace($replace,"",$texto));
$vid_id = split(":",$adata[2]);
$lang = split(":",$adata[7]);
$code = split(":",$adata[6]);
$vidn1 = strrpos($string, "<title>")+7;
$vidn2 = strrpos(substr($string,$vidn1,-1), "</title>");
$vidname = substr($string,$vidn1,$vidn2);
$web = 'http://www.youtube.com/get_video?video_id='.$vid_id[1].'&hl='.$lang[1].'&t='.$code[1].'&fmt=18';
echo $web.'|'.$vidname;
}
function getPage($opts) {
$ch = curl_init($opts);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$html = curl_exec($ch);
if(curl_errno($ch)) {
$html = "";
}
curl_close ($ch);
return getstring($html);
}
getPage($youtube);
?>is the conversion that takes place, after this has happened, the tinyurl conversion needs to take place.PHP Code:$web = 'http://www.youtube.com/get_video?video_id='.$vid_id[1].'&hl='.$lang[1].'&t='.$code[1].'&fmt=18';
echo $web.'|'.$vidname;






Reply With Quote




