Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Fixing mp3 tags for Android 2.0

by hossman (Prior)
on Feb 17, 2010 at 19:45 UTC ( #823797=note: print w/ replies, xml ) Need Help??


in reply to Fixing mp3 tags for Android 2.0

Some comments on your code...

  1. # We parse the command line to pick a directory, # this is easier my $start_dir = ".";

    How is that easier then my $start_dir = shift; ???

  2. Since $id3v1 and $id3v2 are both going to be objects, the distinction between undef and 0 isn't really relevant, so you should be able to simplify about 20 lines of initialization with something like...
    $id3v1 = $mp3->{ID3v1} || $mp3->new_tag("ID3v1"); $id3v2 = $mp3->{ID3v2} || $mp3->new_tag("ID3v2");
  3. Assigning default values like this...
    $artist = "Artist of $file_name";
    ...seems like the worst possible behavior you could have as a fallback. If instead you leave the fields blank, you can at least easily identify them later and you leave it up to the application to decide what to do about it (ie: display some string like "Unknown Artist", or prompty you, or try to fetch the metadata from an external music identification site).
  4. File::Find is your friend. It's been a core module for a while now, so you don't even need to worry about installing it.


Comment on Re: Fixing mp3 tags for Android 2.0
Select or Download Code
Re^2: Fixing mp3 tags for Android 2.0
by hawtin (Prior) on Feb 18, 2010 at 13:19 UTC

    1. ...How is that easier then...

    Writing the script is not much more complex but invoking it (on a Windows machine) is easier if you don't have to pass the extra argument.

    2. ...you should be able to simplify about 20 lines of initialization with something like...

    True. I find mine easier to understand, but I can see yours has its benefits.

    3. ...seems like the worst possible behavior you could have as a fallback...

    You are right. In my case these sections are never invoked, so its not an issue.

    4. File::Find is your friend.

    Yes, OK. But I had the subroutine already written so rather than spend time looking at the existing package I just grabbed it. Pure lazyness I admit.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://823797]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2015-07-03 11:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (51 votes), past polls