Cultured Perl: Fun with MP3 and Perl, Part 2
Ted writes "I continues to look at manipulating and guessing MP3 tags with Perl, FreeDB, and various CPAN models via my autotag.pl application. Writing autotag.pl was grueling but fun. I used fuzzy string matching, FreeDB searches, ID3 versions 1 and 2, and lots of text-mode user interactions. It all came together in an application that I tested thoroughly over the course of a month. Info and Slashdot comments about Part One can be seen here, which was posted in December."
if the next news item refers to undersea stuff (third in a row), I swear....
As long as we're on the topic of useful perl scripts for manipulating metadata, let me offer some other scripts as well.
- ren-regexp
- A perl script that renames many files in parallel
using a series of regular expressions from the command line.
It's a profoundly useful script for those who are command-line and regexp power users.
-
mp3-ren-nice
- A perl script that attemts to clean up munged mp3 file names downloaded
from P2P networks. For example running the script on
"artist-title_title.2.MP3" will yield "Artist - Title Title.mp3".
-
newpl
- A perl script that creates an empty perl script template complete
with GetOptions code and a POD skeleton for writing more
scripts that manipulate mp3 files.
That and more here. Now wasn't that informative?Michael.
Linux : Mac
Isn't this the kind of thing MusicBrainz was invented for. For those who don't know about it MusicBrainz is like CDDB, but you can look up files based on an audio fingerprint as well as the tag information. This means that files could be tagged completely wrong and you can still match them in the database. They provide open-source software for generating the fingerprints, interfacing with the server, and the server software (should you, for some strange reason want to run your own site). There's a pretty easy-to-use client for Windows, and I've been considering writing my own client for Linux.
I copied all my cd's to mp3s on my harddrive, one thing, no ID3 tags.
Lucky, what I did do, is named them all with tracknumber-band-song.mp3 in each subdirectory.
Now that I have like 200 some directories, I don't want to go in with id3master on windows and make a id3 version1/2 tags on every file.
This is exactly what I need! I use cygwin to write small perl scripts to generate reports, so this should be a snap. He even has examples on how to use his perl modules.
Wow, nice for IBM to have a linux developers forum.
MP3 renaming scripts now rank right up there with the image/ comic downloader and the templating system. Every perl programmer thinks, at some time, "I could get the funnies this way" or "this would be good to use as a templater", and now we're seeing a lot of scripts for MP3 renaming. It's like there's a perl hive-mind or something where we all think "yeah! social software networks in perl! or, yeah! tiny webservers in perl! wooo"
I've been totally planning on doing this myself in the past few weeks, as sort of a next project to teach myself some more perl.
cool.
Bill
Correct.
fix the broken software that doesn't allow filenames with spaces in.
Utterly wrong. According to the philosophy that software should help humans, and bend over backwards if necessary to do so, it should only present humans with filenames that are easy to parse at a glance. That means sticking to the "filenames are separated by spaces" system:
Is that "a", "b.mp3", and "c", or "a b.mp3" and "c", or "a" and "b.mp3 c"(, etc.)? It's only obvious if- The "filenames are separated by spaces" system is used.
- ...or the UI is hobbled by displaying only 1 file per line, or attaching a big icon to each file, drastically reducing the number of files that can be displayed in a given screen area.
Another poster pointed out how spaces in filenames can break awk 1-liners, etc., and was told to write a smarter script. The point of a 1-liner is that it's off the cuff and saves time. Writing a "smarter" (really, more robust) script is simply not smart in such cases.You could argue that humans prefer to put spaces instead of _ or UpperCase in filenames at creation time, but filenames tend to be write once, read many. Avoiding spaces to begin with, or running a space removal script in a directory (tree) is better than dealing with the spaces over and over again.
Personally I'd just type " before and after pasting the filename with the spaces in.
It's often easier to type the first few letters and let tab completion fill in the escaping for you.
If we were ants living on a Rubik's cube, differential geometry would be a little more confusing.
Just a note: that still works if you type " first.
Dewey, what part of this looks like authorities should be involved?