Download Magnatune’s songs quickly

Here’s a quick bash script that gets in the argument line the URL of a Magnatune hifi.m3u playlist and automatically downloads the (freely available) 128kbps mp3 songs listed in that playlist. Save the script as magna.sh and give it executable rights. Songs are saved on the terminal’s current working directory. Do not reuse the script on another terminal window if the previous downloading operation hasn’t finished yet.

#!/bin/sh
wget $1
cat hifi.m3u | while read i ; do wget $i ; done
rm -f hifi.m3u

Example of usage:
./magna.sh http://magnatune.com/artists/albums/westexit-nocturne/hifi.m3u

Do not forget to buy the album and support its artist if you actually like what you hear.

Post a comment »

ksmc wrote on October 15th, 2006 at 3:25 AM PST:

nice. but how do you make a file executable on OSX?


ksmc wrote on October 15th, 2006 at 3:31 AM PST:

i made terminal the default app for the script, but it says permission denied even though i have read & write access to the file. do you know what i need to change?


vince wrote on October 15th, 2006 at 5:05 AM PST:

try sudo chmod +x magna.sh


This is the admin speaking...
Eugenia wrote on October 15th, 2006 at 7:02 AM PST:

No reason for sudo really as it’s a personal script, so this should do: chmod +x magna.sh


ksmc wrote on October 15th, 2006 at 10:47 AM PST:

thank you, but now i get this:

./magna.sh: line 3: wget: command not found

i thought maybe wget wasn’t installed, so i downloaded and installed it–which pushed my pathetic knowledge of bash to the max–but it still spits out the same thing. i’m obviously doing something wrong. i have both the script and the m3u in my home directory.


Carl wrote on October 15th, 2006 at 11:34 AM PST:

wget isn’t installed as default on OS X. Use curl!

#!/bin/sh
curl -LO $1
cat hifi.m3u | while read i ; do curl -LO $i ; done
rm -f hifi.m3u


This is the admin speaking...
Eugenia wrote on October 16th, 2006 at 1:15 AM PST:

No, wget is not installed by default on OSX. You have to find and put the “wget” binary on either /usb/bin or /usr/local/bin/ and then run the script, or put the wget binary on your home folder and edit the script to call wget from your ~/ folder, or just use CURL as Carl suggests.


Ludovic Hirlimann wrote on October 16th, 2006 at 9:59 AM PST:

>binary on either /usb/bin or /usr/local/bin/

I would put it in the local , where non OS installed bins are suposed to live.


Comments are closed as this blog post is now archived.

Lines, paragraphs break automatically. HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

The URI to TrackBack this blog entry is this. And here is the RSS 2.0 for comments on this post.