Return to Snippet

Revision: 49200
at July 19, 2011 00:46 by mattneary


Updated Code
function serveFile( $file ){ 	  

	    $output = '';	    

	    $prep = `cd /Applications/XAMPP/xamppfiles/htdocs/download`;

	    $fp = popen('./youtube-dl -c -w '.$file.' 2>&1', "r"); 

	    while(!feof($fp)) 

	    { 	        

	        $myLine = fread($fp, 1024);

	        $buffer = $myLine;

	        echo $myLine; 	        

		$output .= $buffer."...\n";	       	       

	    } 

	    fclose($fp); 

	    return $output;

}

Revision: 49199
at July 18, 2011 13:07 by mattneary


Updated Code
function serveFile( $file ){ 	  
	    //@readfile( $file ); 	
	    $output = '';
	    
	    flush(); 
	    $prep = `cd /Applications/XAMPP/xamppfiles/htdocs/download`;
	    $fp = popen('./youtube-dl -c -w '.$file.' 2>&1', "r"); 
	    $count = 0;
	    while(!feof($fp)) 
	    { 	        
	        $myLine = fread($fp, 1024);
	        $buffer = $myLine;
	        echo $myLine; 	        
		$output .= $buffer."...\n";	       	       
	    } 
	    fclose($fp); 
	    
	    return $output;
	}

Revision: 49198
at July 18, 2011 10:39 by mattneary


Updated Code
wget "http://www.youtube.com/watch?v=dQw4w9WgXcQ" -qO- | awk '/fmt_url_map/{gsub(/[\|\"]/,"\n");print}' | sed -n "/^fmt_url_map/,/videoplayback/p" | sed -e :a -e '$q;N;2,$D;ba' | tr -d '\n' | sed -e "s/\(.*\),\(.\)\{1,3\}/\1/;s/\\\//g" | wget -i - -O surprise.flv

Revision: 49197
at July 18, 2011 10:34 by mattneary


Updated Code
<?php
$url = trim($_REQUEST['url']);
if (strpos($url, 'http://www.youtube.com/watch?v=') === 0)
{
    $ch = curl_init();
 
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
    $info = curl_exec($ch);
 
    $pos1 = strpos($info, "&amp;video_id=", $pos1);
    $pos2 = strpos($info, "&amp;t=", $pos2);
 
    $video_id = substr($info, $pos1 + 10, 11);
    $tag_t = substr($info, $pos2 + 3, 32);
 
    $response  = '';
    $response .= '' . $video_id . '';
    $response .= '' . $tag_t . '';
    $response .= '';
 
    header("Content-type: text/xml");
    echo $response;
 
    curl_close($ch);
} else
{
    die("Wrong URL / Parameters");
}
?>

Revision: 49196
at July 18, 2011 09:28 by mattneary


Initial Code
wget "http://www.youtube.com/watch?v=dQw4w9WgXcQ" -qO- | awk '/fmt_url_map/{gsub(/[\|\"]/,"\n");print}' | sed -n "/^fmt_url_map/,/videoplayback/p" | sed -e :a -e '$q;N;2,$D;ba' | tr -d '\n' | sed -e "s/\(.*\),\(.\)\{1,3\}/\1/;s/\\\//g" | wget -i - -O surprise.flv

Initial URL

                                

Initial Description
Requires youtube-dl to be in the directory.

Initial Title
Youtube Downloader

Initial Tags
Bash

Initial Language
PHP