How to find free mp3 using google
Posted in Google, PHP, Programming by sandaruwan on July 4th, 2007Most probably, you are using file sharing apps(Limewire, Bearshare, even Bittorrent) to download music. But do you know there are thousand of free mp3 hosted on internet, and those are directly accessible by normal browsers?
Sometimes, people upload mp3 files to their web servers thinking that no one will find them. But when someone enters the url of the folder which contains the music, the web server uses directly listing to show the files in that folder (Directory listing can be turned off).
Basically, if you can find some web servers with mp3 files, you can download those. The problem is finding those. You can use google advance queries to find them. The title of apache directly listing starts with the phrase “Index of”. So, you can use google to search pages with “Index of” in title. Then, you need “mp3″ files. So, just append mp3 to the query. Lets say you want Beatles. Then, append Beatles. Here is an example : intitle:”Index of” mp3 Beatles
There is a possibility that some of those url might not work. But keep on searching, there are lots of working urls.
When there is a lot of sub directories and files, you might want to get a list of urls. So, i wrote a simple PHP script. You can execute this script in command line. I have put some sample URLs. The sample pages given there will generate more than 1000 direct links for mp3s.
<?
$stderr = fopen('php://stderr', 'w');
set_time_limit(0);
error_reporting(0);
$urls[] = "http://www.mcgees.org/mp3/pearl_jam/";
$urls[] = "http://www.xieish.net/Collective%20Soul/";
$urls[] = "http://www.asilentflute.com/mp3/";
$urls[] = "http://www.semret.org/music/";
$urls[] = "http://www.koreangirlssuck.com/emotion/mp3/";
$urls[] = "http://www.vrees.net/mp3/";
$urls[] = "http://www.webpiri.net/Mp3/";
$urls[] = "http://pierre33200.free.fr/Music/";
$done = array();
for($i=0;$i<count($urls);$i++) {
$url = $urls[$i];
$done[strtolower($url)] = true;
$temp = parse_url($url);
$path = pathinfo($temp['path']);
$domain = $temp['host'];
if ($path['extension']!="") {
if (strtolower($path['extension'])=="mp3"
|| strtolower($path['extension'])=="wma") {
echo $url."\n";
continue;
} else {
fwrite($stderr,"Escaping $url : Not mp3\n");
continue;
}
}
fwrite($stderr,"Proccessing $url\n");
$html = file_get_contents($url);
$direct = preg_match("/index of/i",$html);
if ($direct==false) {
fwrite($stderr,"Error : Not a directy index\n");
continue;
}
$count = preg_match_all("/<a href=\"(.*?)\">.*?<\/a>/i",
$html,$matches);
foreach ($matches[1] as $match) {
// Ignore the pages link to same url
if ($match[0] == "?")
continue;
if (substr($match,0,7)=="http://")
$cur = $match;
else if ($match[0] == "/")
$cur = "http://".$domain.$match;
else
$cur = $url.$match;
if (!isset($done[strtolower($cur)]))
$urls[]=$cur;
}
}
fclose($stderr);
?>
Save the above script(”mp3.php”), then execute it(”php mp3.php > urls.txt”). Then, it will show you what it’s doing and all the urls will be written to “urls.txt”. If you are in linux, you can use “wget -i urls.txt” to download the songs. If you are in windows, download Free Download Manager and use File -> Import List of Downloads.
You can also download the list of generated links.


Joshua McGee of mcgees.org here. Not only was this not a case of “thinking that no one will find them”, but I actively publicize the Pearl Jam files. Pearl Jam have an open taping policy. The mp3s are all of live shows. Download and trade away! You have the band’s blessing!
And while you’re on mcgees.org, go up a level. There’s Queensryche there, too.
Another quick way, if you’re using Firefox, is to use the extension called “DownThemAll”. Just go to the directory listing, click a button, and your browser saves every media file on the page (it’s highly configurable.)
July 6th, 2007 at 1:27 am
The piece of code that you have given is wonderful still it needs to be compiled in the terminal can you help us do this on a webpage it self and, hence send the filtered results to a DB.
Hamza(Archmage)IIT
September 3rd, 2007 at 2:00 am
Sorry to leave the comment here out of place but I am using the plugin you built for picasa photos to play random - any thought to include a place to select the gallery so I can keep those phicture from a current gallery rather than really old stuff as well?
January 5th, 2008 at 11:04 pm
Hello Craig,
Please look at this post : http://www.sandaru1.com/2007/07/11/picasa-widget-updated/
It’ll say how to configure your widget only to display one album.
Regards,
Sandaruwan.
January 5th, 2008 at 11:46 pm