Jump to content

PHP YouTube -> MP3 Script


``Yousef

Recommended Posts

Hey guys. I found this script on the internet, however it doesn't seem to be working for me. Here's the coding

 

<?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_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><? foreach(glob('*.mp3') as $file) { ?>
      <li><a href="<?= $file ?>"><?= $file ?></a></li><? } ?>
         </ul>
       </form>
  </body>
</html>

 

However, it doesn't seem to be working. There is another file that is meant to be attached.

 

The script above and file can be found at: http://www.protocoder.com/php/create-your-own-youtube-video-to-mp3-converter/

 

It also says that PHP needs to have the ability to use command line.

 

I'm running on a GoDaddy Linux server, however this doesn't have Python CGI support. I know thats a problem as its required, but is the script itself fine?

 

When I try to run the script I get the error

 

Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 0 in /home/content/p/o/w/powerbutton/html/test.php on line 7

Downloading How To Fix A Xbox 360 E74 And RROD...

nConverting How To Fix A Xbox 360 E74 And RROD to audio ...

nCleaning temporary files ...

n

 

Any help would be great :)

Link to comment
https://forums.phpfreaks.com/topic/153784-php-youtube-mp3-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.