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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.