Never been to DZone Snippets before?

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

Download mp3's from a password protected site using a m3u file (See related posts)

<?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
}



?>

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts