This post is in response to the recent surge in traffic to my previous post find free music with a python script.
As some of you pointed out in the comments of my previous post, scraping Google result pages for MP3s often doesn’t produce the best quality results e.g. spam, html source. Not to mention that specific Google search relied on the music files to be located in a publicly available web directory. Just go ahead and search Google for:
-inurl:"htm" -inurl:"html" intitle:"index of" "Last modified" <some artist name> mp3
This does a decent job of finding music. But there are definitely other services out there that can do it better. For example: Skreemr claims to be the best MP3 search engine on the web. Pretty big claim, but I’m not gonna argue. Luckily for us, since they are basically just ‘bookmarking’ music files, the URLs can be found in the page source.
So after reworking a few things, I’ve updated my original script to now scrape MP3 files from Skreemr’s results, which does an amazing job of finding music. The script will go through all of the result pages found so I’ve added the ability to skip tracks by hitting CTRL+C – and pressing this repeatedly will stop the script completely.
Download the new script here skreemr.py (right click and save) or use wget:
me@localhost:~ $ wget http://random.noflashlight.com/scripts/skreemr.py
Now make the script executable:
me@localhost:~ $ chmod +x skreemr.py

I’ve been diving into Cocoa/Objective-C lately and I feel like things are finally starting to click. Like every other language I know, over time I try to build a library of useful utilities, components and subclasses to be reused in future projects – as well as to share with the public. Here is one that talks to the TinyURL API.
//
// TinyURL.h
// @author Nick Jensen
//
#import
extern NSString * const MAKE_TINY_SERVICE;
@interface TinyURL : NSObject
+ (NSString *) makeTiny:(NSString *)aLongURL;
@end
…and here is the implementaion.
//
// TinyURL.m
// @author Nick Jensen
//
#import "TinyURL.h"
#import "NSString+URLEncoding.h"
NSString * const MAKE_TINY_SERVICE = @"http://tinyurl.com/api-create.php";
@implementation TinyURL
+ (NSString *) makeTiny:(NSString *)aLongURL
{
NSMutableString *urlString = [[NSMutableString alloc] initWithString:MAKE_TINY_SERVICE];
[urlString appendString:[NSString stringWithFormat:@"?url=%@", [aLongURL URLEncodedString]]];
NSURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:30.0];
NSURLResponse *response;
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:nil];
if (data)
{
NSString *shortURL = [[NSString alloc] initWithData:data
encoding:NSASCIIStringEncoding];
[shortURL autorelease];
return shortURL;
}
else
{
return nil;
}
}
@end
Also required are:
NSString+URLEncoding.h
NSString+URLEncoding.m
It turns out that Objective-C is lacking in the ability to URLEncode a string properly. NSString has the method stringByAddingPercentEscapesUsingEncoding, but since the & and / chars are valid URL characters they will not be encoded… This is definitely a problem if the data you’re sending IS a URL
After reading many different articles about how you can use Google to find free mp3s, I just couldn’t help but think… I should script this. The result actually turned out to be a somewhat sophisticated little program. Check it out.
musicfinder.py (right click and save) or use wget:
me@localhost:~ $ wget http://random.noflashlight.com/scripts/musicfinder.py
Now make the script executable:
me@localhost:~ $ chmod +x musicfinder.py
Now fire up a terminal and run the program like so…

The first argument is always the search terms. If you want to search more than one word be sure to wrap them in quotes.

If you would like to skip a file that is downloading, hit CTRL+C. By default the program will only search 10 google result pages. If you would like to search more, use the -r flag. Acceptable values are 5, 10, 25, 50, and 100.

One last thing to note is that by default the strict flag is turned on. What this means is that the program won’t download a file unless the search term is found somewhere in the URL to the file. I found that this produced MUCH better results. For example, if I searched for Radiohead a page might come back that has Radiohead songs on it but also had hundreds of other songs by random obscure artists that I’m not interested in downloading. However if you would like to turn off the strict flag you can pass the –non-strict argument. I have tried to test this the best I can, but I’m sure there are still some bugs that I’ve missed. I am open to and welcome additions and improvements to this script. Enjoy!
I bet you wished that you had a sweet script that could tell you the status of your dominos pizza order in real time. Well today is your lucky day.
dominos.py (right-click and save)

Instructions:
First download dominos.py. You can right-click the link and select save, or use wget:
me@localhost:~ $ wget http://random.noflashlight.com/scripts/dominos.py
me@localhost:~ $ chmod +x dominos.py
That’s it. Now all you have to do is order a pizza, and then execute this script from the command line like this:
me@localhost:~ $ ./dominos.py 'your phone number'
Be sure to keep running the script periodically for the real time status of:
- When the pizza is being made.
- When the pizza is in the oven.
- When the pizza is cooked and waiting.
- When the pizza is on its way.
- When the pizza was delivered.