For a recent video editing project, I really wanted to have some mellow classical music playing in the background. Due to licensing restrictions, the classical music needed to be either in the Public Domain
or released under a very permissive Creative Commons
Fortunately, the United States Air Force Band
has quite a few Public Domain recordings, of Public Domain works, on their website. Unfortunately, the Air Force website leaves a lot to be desired regarding listening to and downloading tunes.
What this means, is that I need only sift through the source of the page containing links to audio files and pull out the URL strings that start with "http://" and end with ".mp3". This sounds like a job for a non-greedy Regular Expression
Enter the PHP: What? you don't
write command line scripts in PHP?
if ( count($argv)>1 )
$file = $argv;
$text = file_get_contents( $file );
foreach($matches as $match)
The script (which I named echo_mp3.php) takes the URL of a webpage as an argument and prints out the URLs of the mp3s that are found in the webpages code. For my usage, I wrote the list of mp3s to a file by executing
./echo_mp3.php http://example.com/some/file.htm >> mp3list.txt
and then used wget
to batch download the files in the list.
Now stop reading, and go listen to some Vivaldi