DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Download Mp3's From A Password Protected Site Using A M3u File

04.08.2005
| 15859 views |
  • submit to reddit
        
<?php
// simple script to download mp3's from a password protected site using a playlist file 
//remote username
$username = 'username';
// remote password
$password = 'password';

// m3u file
$get = file("file.m3u"); // m3u (playlist) file contains paths to  remote files

foreach($get as $url){
        $trim_url = rtrim($url); // trim newline
        $explode_url = explode("//", $trim_url); //explode url so you can insert username:password for wget
        $fixed_url = 'http://' . $username . ':' . $password . '@' . $explode_url[1];

        exec("wget $fixed_url"); // downloads to current directory
}



?>