YouTube Video Convert To Mp3 Php Script
Page 1 of 1
YouTube Video Convert To Mp3 Php Script
- Code:
<?php
if(!empty($_POST)){
$urls = explode("n",$_POST['urls']);
foreach($urls as $url){
$file = file_get_contents($url);
preg_match("/?v=([^&]+)/",$url,$found);
$id = $found[1];
preg_match('/<meta name="title" content="([^"]+)">/',$file,$found);
$title = $found[1];
echo "Downloading " . $title . "... <br />n"; exec("youtube-dl ".$url);
echo "Converting ". $title. " to audio ... <br />n";
exec('mplayer -dumpaudio '.$id.'.flv -dumpfile "'.$title.'.mp3"');
echo "Cleaning temporary files ... <br />n"; exec('rm '.$id.'.flv');
}
}
?>
<html>
<head>
<title>Downloader</title>
</head>
<body>
<form action="<?php $PHP_SELF ?>" method="post">
<table>
<tr>
<td>
List:<br />
<textarea rows="10" cols="40" name="urls"></textarea><br />
<input type="submit" value="Download" />
</td>
</tr>
</table>
<ul><?php foreach(glob('*.mp3') as $file) { ?>
<li><a href="<?php $file; ?>"><?php $file ?></a></li><?php } ?>
</ul>
</form>
</body>
</html>
don.1- members
- Posts : 9
Join date : 2011-10-16
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum