macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Learning the Mac OS X Terminal, Part 4
Pages: 1, 2, 3

The second option in the Save dialog box allows you to choose that the term file opens when Terminal starts up. You can also make this choice using Terminal's Preference palette, from the Startup pane.



Once the file is saved, you'll see it listed under the Shell-->Library menu item. Each time you select it from the Library, a new window will open with the exact same settings specified in the term file. Try it! Remember, the placement of each window is the same, so they will open stacked on top of each other. (This is but one way to quickly access your term files.)

Before installing Streamripper, you'll first need to make sure the directory it will go into actually exists. The mkdir command with its -p flag will create the bin directory and any intermediate directories if they don't already exist. Use sudo since these need to be root-owned:


[localhost:~] chris% sudo mkdir -p /usr/local/bin

It's now time to download and install Streamripper. Clicking this link will download the source code as a zip-compressed "tarball":

http://streamripper.sourceforge.net/dl/streamripper-1.0.5.tar.gz

A tarball is a single archive file the tar utility produces by combining the many files contained in the typical Unix source code distribution. Since the files are only combined, not compressed, tarballs are then usually zip-compressed as well, thus the ".tar.gz" extensions.

The latest version of Aladdin Expander will happily post-process this file (and might have done so automatically after download). You can also unpack zipped tarballs from the command line with this command, which will both decompress the zip file, and recreate the full directory structure from the tar archive, using tar:

[localhost:~/Desktop] chris% tar xzvf streamripper-1.0.5.tar.gz

Whether Expander does the job, or tar, you will end up with a streamripper-1.0.5 directory in the same directory as the downloaded file. (Remember, of course, that the version number in the name could be newer.)

Now step into that folder from the command line:

[localhost:~/Desktop] chris% cd streamripper-1.0.5

As you install more Unix software, you'll find the next three commands to be a familiar part of the process. There's quite a bit behind these commands, but I can give you some of the basics of what's going on.

Run this command first:

[localhost:~/Desktop/streamripper-1.0.5] chris% ./configure

What you're doing is executing a shell script that discovers your machine and OS properties (remember this is the same portable source code that will work on most other Unix machines) in preparation for actually compiling the code in the next step, which you're ready to perform once you get a new prompt:

[localhost:~/Desktop/streamripper-1.0.5] chris% make

The compile will take a few moments while you watch the lines of output from each step roll by. Once your prompt returns, you might want to have a new look in the directory; you'll see the newly hatched Streamripper binary, the actual application file that now just needs to be placed in the proper directory. You'll do this with the next command, which requires sudo since the file is going into /usr/local/bin/ (a directory only writable by root):

[localhost:~/Desktop/streamripper-1.0.5] chris% sudo make install - Installing streamripper

And that's it! Streamripper is now installed, and you can take it for a quick spin. Entering just its name gets you some usage information:


[localhost:~/Desktop/streamripper-1.0.5] chris% streamripper
Usage: streamripper URL [OPTIONS]
Options:
        -d <dir>       - The destination directory
        -s             - Don't create a directory for each stream
        -r <base port> - Create a relay server on base port, defaults to port 8000
        -z             - Don't scan for free ports if base port is not avail
        -p <url>       - Use HTTP proxy server at <url>
        -o             - Write over tracks from incomplete
        -c             - Don't auto-reconnect
        -v             - Print version info and quite
        -l <seconds>   - number of seconds to run, otherwise runs forever
        -q             - add sequence number to output file
        -i             - dont add ID3V1 Tags to output file
[localhost:~/Desktop/streamripper-1.0.5] chris%

If typing streamripper instead results in Command not found, run the rehash command, which will force the shell to rebuild its list of known executables:


[localhost:~] chris% streamripper
streamripper: Command not found.
[localhost:~] chris% rehash
[localhost:~] chris% streamripper
Usage: streamripper URL [OPTIONS]
...

There are a few options, as you can see, but for our purposes only a URL and target directory are necessary. In fact, finding a URL might be the hardest part. The easiest way to find one is by going to SHOUTcast (a popular portal for streaming MP3 stations), finding a station, and control-clicking on its "Tune In!" button. Choose to copy the link to the clipboard, paste that text somewhere, and copy out just the part of it containing an IP and port number. For example, from this URL:

http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=9035&addr=205.188.234.36:8046&file=filename.pls

you would want to extract 205.188.234.36:8046. Once you have it, you can use it in the Streamripper command like this:

[localhost:~] chris% streamripper 205.188.234.36:8046 -d ~/Music/

The directory following the -d flag is where the ripped files will end up, in this case my home directory's Music folder.

This is what you'll see after pressing Return:


Connecting...
stream: Japan-A-Radio - Anime Music & Japanese Pop (JPOP / Anime)
server name: SHOUTcast/SolarisSparc v1.8.8
bitrate: 128
meta interval: 24576

[ripping...    ] SES - Love isDay By Day [  120kb]

To stop the rip, press Control + C:


shuting down
bye..
[localhost:~] chris% 

If you let Streamripper run long enough, you'll see the song files start to fill up your selected destination directory, nicely named with the song titles. You'll learn lots more about Streamripper just by playing with it, from its README file in its source directory, and also from its home page.

But it's now time to return to our term file and add the Streamripper command (and one other nice touch). As you might know, the official preference file format for Mac OS X is the XML plist. I won't go too much into XML here, but what's important to note is that all of these files are plain text, editable from any text editor. Even more relevant is the fact that term files are also written in XML, exactly like plist files.

Pages: 1, 2, 3

Next Pagearrow