Slashdot Mirror


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."

17 of 55 comments (clear)

  1. Mmm Perl by Michael.Forman · · Score: 4, Informative

    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 :: VW : Mercedes
    1. Re:Mmm Perl by addaon · · Score: 4, Informative

      I wasn't the original poster, but I can tell you why it bothers me. Using spaces and other non-normal characters in filenames means that the files actual name is different from the typed representation of the file name. So "My File" needs to be referred to as "My\ File". Now, this isn't so big a deal if all you ever do is use the command line. But I tend to interact with guis at times. And the two major operations I perform between guis and clis is copy and paste and drag and drop. Both fail with filenames with spaces. If I copy a file name "My File" and paste it to the terminal (or drag and drop the file there, which has exactly the same effect), the text that is automatically entered does not represent what I intended it to. This is broken behavior and, while it could be worked around (especially in the drag and drop case, there's no reason for the gui not to make the correction if it knows it's being dropped in a terminal), it's easier just to avoid it entirely.

      --

      I've had this sig for three days.
    2. Re:Mmm Perl by metamatic · · Score: 4, Insightful

      Personally I'd just type " before and after pasting the filename with the spaces in.

      Filenames are for humans, fix the broken software that doesn't allow filenames with spaces in.

      --
      GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
    3. Re:Mmm Perl by Michael.Forman · · Score: 2, Interesting


      I'm the original poster and I agree with you totally! I do not tollerate spaces in my Unix filenames with the sole exception of mp3 files.

      As a matter of fact, that's one of the main reasons I wrote my ren-regexp perl script. For files with unsightly spaces I simply type:
      ren-regexp "s/ /-/g" *\ *
      and my files are sane again.

      Isn't that strange that I prefer my mp3 file names with spaces? I never really thought about it until now. :)

      Michael.

      --
      Linux : Mac :: VW : Mercedes
    4. Re:Mmm Perl by arkanes · · Score: 4, Interesting

      DnD not working with filenames with spaces in them is because broken applications don't correctly or fully implement XDnD. You're limiting yourself because of flaws in your software and claiming the moral high ground?

    5. Re:Mmm Perl by Just+Some+Guy · · Score: 4, Funny
      there's no reason for the gui not to make the correction if it knows it's being dropped in a terminal

      In other words, you wish that all combinations of X apps and terminal programs worked like kwin plus konsole? Whenever I drag an icon into a konsole window, I get a context menu to paste, cd, cp, ln, or mv the specified path into my current shell directory.

      In fact, the quickest way I know of to copy a single MP3 from home to the office (assuming I'm currently using X) is to:

      1. Open Konqueror and select the bookmark for "sftp://myhomeserver/usr/share/media/music/singles ",
      2. Type "cd /tmp" (or wherever) in my konsole window, and
      3. Drag the desired icon into that same konsole window.

      Within a couple of minutes, I have the file in my local /tmp directory. Now that is how GUIs and CLIs are supposed to work together.

      Oh, if you're my boss: just kidding ha! ha!

      --
      Dewey, what part of this looks like authorities should be involved?
    6. Re:Mmm Perl by DrSkwid · · Score: 2, Insightful

      #!/usr/local/bin/rc

      for (mp3 in *.mp3) mpg123 $mp3

      fails if the filename contains a space

      ls -l *.mp3 | awk ' { print "%s is %d bytes\n", $9, $5 } '

      fails if the filename contains a space

      etc.

      spaces in filenames should be illegal

      --
      There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
    7. Re:Mmm Perl by Smallpond · · Score: 2, Funny

      I think in Linear A, you insensitive clod.

      it actually looks a lot like Perl:
      sample

      - !//!!1\\\!!!

    8. Re:Mmm Perl by damballah · · Score: 2, Insightful

      Software problem. Software that do not allow spaces in filenames should be illegal.

  2. Musicbrainz? by magnum3065 · · Score: 4, Informative

    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.

    1. Re:Musicbrainz? by windex82 · · Score: 2, Informative

      Informative, bah! Magnum forgot the most important part!


      Latest Version

      The MusicBrainz tagger is currently only available for Windows.

    2. Re:Musicbrainz? by DrSkwid · · Score: 2, Informative

      If anyone was interested they should know the code is in C++

      oh well.

      http://cvs.musicbrainz.org/cvs/mb_tagger/

      --
      There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
    3. Re:Musicbrainz? by TedZ · · Score: 2, Informative

      Please read the comments for the first article. And/or the article itself.

      I tried MusicBrainz and didn't like the interface to it, or its capabilities. FreeDB was much better for my purpose.

      Ted (article author)

    4. Re:Musicbrainz? by Darth23 · · Score: 2, Insightful
      Sounds like something worht trying out. In all my years of P2P experience I've learned that there a re a lot of music fans out there who have no clue about what artist performed which songs.

      I just wish there was a way to tell them all that just because a song is a parody, doesn't necesarrily mean it was written and performend by Weird Al.

      --

      -------- In Soviet Russia, "Soviet Russia" sigs hate Slashdot.

  3. This is exactly what I need. by BrookHarty · · Score: 3, Informative

    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.

  4. another rite of passage in perl. by j_d · · Score: 2, Funny

    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"

    1. Re:another rite of passage in perl. by haystor · · Score: 2, Insightful

      It is a testament to the effectiveness of these various languages that just anyone can produce something useful.

      --
      t