Streamripping in Linux!
Posted by Scott August 19th, 2006 | 5,253 words | No Comments »
Streamripping in Linux
grabbing mp3s like a pro!
What is this tutorial?
This tutorial will teach you how to amass an incredible wealth
of Mp3s by recording them off of a streaming internet radio station! Schoutcast.com
has thousands of radio stations you can tune in to from all over the world!
This tutorial will tech you the art of streamripping. With this tutorial,
you can create a dedicated (constantly running) streamripper that listens
to a radio station of your choice all day and all night recording the stream
and dividing it up per song and saving each song as a .mp3 file with the song
title as the filename! Yes, there are streamrippers for Windows. However,
a dedicated streamripper on a linux machine is much more powerful and reliable.
In a few weeks’ time, you can have thousands of great mp3s of your favorite
music! Ok, let’s get started.
Linux? Why linux?
Well, linux is faster, liter, more stable, and will run on almost any incredibly
old (otherwise useless) computer. Also, the streamripper software has more
features and bug fixes for the linux versions than the windows versions.
For this tutorial…
you’re expected to already have a running linux server. If you do not have
a linux server, check out my tutorial on how to set one up. It only takes
about 15 to 30 minutes to install linux on an old computer. Also, streamripping
requires bandwidth. Do not expect to get much use out of this tutorial if
you’re on a 56k dialup modem. You need a dsl or cable modem to make this work
right. Streamripping a 128k radio station (most common) usually uses about
13KB of download bandwidth per second. It’s pretty lite and unnoticeable if
left running on a broadband connection, yet it keeps running day and night
to get your music!
Step One
installing the streamripper
SSH your linux server
- use putty (for windows) to connect to it, logging in as
a normal user.
good to know: If you’ve forgotten it’s ip, hook up a
monitor and keyboard to it, login as root, and run ‘ifconfig’. The ip will
be in there. now remember it!

SU to root and download the program
– type su and press enter, then type your root password and hit enter again.
You’re now logged in as root. To run the streamripper, you first need to have
it! At the time of this writing, the streamripper is located at "http://streamripper.sourceforge.net/files/streamripper-1.32.tar.gz".
To download it in linux, type wget, followed by a space and the url. Hit enter
and wait for it to download…
good to know: files ending in .tar.gz are like zip files
for linux! A .tar will combine a bunch of files into one big one, and a .gz
file will compress that big file into a little one. So, .tar.gz is a compressed
archive of many files! Compressed .tar files are called TARBALLS

Extract the tarball – Once the file
completed downloading, it’ll spit you back at the # prompt. Next, we need
to decompress our tarball. To decompress it, type "tar zvxf stre"
and hit tab, followed by enter.
good to know: when we typed ’stre’ and pressed tab, the
tab autocompleted the filename for you! using tab to autocomplete filenames
saves you tons of time while moving around in a console!

Compile and install the program
– after decompressing, a new directory will be created that holds all the
tarball’s files. Type "cd stre" and hit tab (autocomplete) and press
enter. You’re now in the streamripper’s directory. Type "./configure
&& make && make install" to configure, compile, and install
this program. Make sure you’re still logged in as root or it will not work.
good to know: what is all that ./configure stuff? Well,
installing linux apps from their sources is a common way to install linux
programs. After decompressing the tarball and entering it’s directory, we
can run ./configure to launch its configuration script. This’ll look through
your system to see how it works and optimize the rest of the files for your
specific system! the && means "if there are no errors, then".
So, ./configure && make && make install means "configure,
if there are no errors then make, if there are no errors then make install"
Make will take the customized source code and make the actual (binary) program
from it. It’s usually the longest (most cpu intensive) part of the installation
process. Make install will just copy the completed files to the areas of the
system they need to go. Tada! A linux install process explained.
Step Two
tell the ripper where to save

Mount your network drive – If you’re
still logged in as root (# prompt, not a $), then stay that way. If you’re
logged in as a normal user ($ prompt), type ’su’ and enter the root password
to login as root. Now, type "mkdir /mnt/tmp" to make a ‘tmp’ directory
in the ‘/mnt/’ folder. Type "mount -t smbfs //storageip/sharename /mnt/tmp"
to mount your network share on /mnt/tmp (replacing storageip and sharename
with your custom values from above)

Verify it mounted correctly – type
"cd /mnt/tmp" to change directory to /mnt/tmp. Type ls
to list the files. They should match-up with the ones in the shared folder
of the computer ip you gave it to mount. If so, continue to the next step.
If not, "umount /mnt/tmp" and try again.

Make the directory to store the mp3s in – here, I want my finished files to
go in //computer/share/80g/streamrips. So, I "mkdir /mnt/tmp/80g/streamrips"
to create that directory. Make whatever directory you want (inside your network
share). Dang, we’re all ready to go to the final step!
tip: test out to see if you have the permissions it takes
to write to that directory. If you don’t, it’ll stink! To test it, you can
use a program called ‘touch’ to make an empty file in the directory. "touch
/mnt/tmp/80g/streamrips/test". If you get an error, you need to adjust
permissions. If you don’t get an error, it worked! remove that file with the
rm command, "rm /mnt/tmp/80g/streamrips/test".
Step Three
start streamripping!

Find the station you want to rip – for my example, I’m going to be listening
to some mp3s from a certain shoutcast station. I found it on www.ShoutCast.com
Instead of clicking the "listen now" button to load it in my audio
player (winamp, for example), I want to try to save the radio station file
(something.pls) so I can look at it. I can right-click "listen now",
select "save target as", and save the .pls to my desktop. I then
will open it up in wordpad and examine it… Inside, you should fine at least
on URL. Copy it (highlight, edit, copy) so we can use it later.
good to know: in windows, you can copy anywhere with
control+c and paste anywhere with control+v. In linux, highlighting text copies,
and middle clicking (pr pressing both R and L mouse buttons at the same time)
pastes.

connect, mount, screen – You should
reboot your linux machine (type ‘reboot’ as root) before this step. Linux
doesn’t need the rebooting, but it will represent what it’ll be like to start
the streamripper from scratch (if the power goes out or you trip on the cord
or something). So, after rebooting, If you haven’t already, connect to your
linux machine with ssh. su to root. mount your network share. type screen
and hit enter.
good to know: if you start a program (like streamripper)
inside a ssh session, then close the ssh session, it’ll also close all the
programs you started (like streamripper). To avoid this, we can use the ’screen’
program to launch a ”fake” screen that does not close when ssh closes. When
you run screen, it gives you a new blank terminal screen. To close screen
w/o exiting any programs – just click the X to close ssh! screen will still
run.

rip baby rip! - once you’re in screen
and are at a blank console, it’s time to start ripping! Type "streamripper
url -d directory -s &" to start ripping! Replace
url with the station url (that you copied earlier) and replace directory
with the custom spot where you’d like to put your mp3s. If you’d like, you
can add the -r flag to create a relay station. Once it’s running, when you
confirm it’s working (it will spit mp3 files in the directory you mounted),
you can click the X to close the window and leave the streamripper running!
tip: the extra -r flag is really cool! adding -r before the & will
create a relay station. This means, if you want to hear what you’re ripping,
you can open up a program like winamp and in the playlist click "add"
and select "url" and type in http://streamripperLanIP:8000 and bam!
It’ll play you exactly what you’re recording. (whereas if you just tuned into
the radio station in winamp, it’d be sending the same songs to your network
TWICE, and take more bandwidth). Awesome!
Ideas
– the ways you can use this program are almost limitless. Let’s say you have
a bunch of comps in a bunch of rooms. Using the -r (relay) feature, you can
all listen to the same station without a bunch of different streams (instead
of each comp having its own connection, just one connection goes to the linux
machine, the internal pcs get it from there). That’ll save you TONS of bandwidth.
Also, consider putting the mounted directory in a password-locked section
of your website. As mp3s download, they’ll be on your website ready for listening!
Store your favorite songs in your p2p shared directory and leave your p2p
upload at full at nighttime to make some people happy (especially if your
fav. types of music is somewhat difficult to find). And all of this from a
crappy 75mhz computer with 16megs of ram!!! You can use this program in tons
of ways, I encourage you to play with it and make it work for you. Check out
my other tutorials for more cool things you can do with a linux server!
Postnote: See how in the last
screenshot some of the information is blurred? In my example I used one of
my favorite internet radio stations just to demonstrate how it works. I didn’t
mean to promote the practice of radio station stream ripping or leeching from
that one radio station, but I guess it doesn’t matter. I got contacted by
the admins and they requested I make it anonymous… sorry ’bout that guys!