Re: I need help about MP3::Tag and perl script.
by jwkrahn (Abbot) on Mar 30, 2011 at 00:41 UTC
|
| [reply] |
|
|
I got v1 too. But my perl script not working? Any idea?
Thanks.
| [reply] |
Re: I need help about MP3::Tag and perl script.
by Popcorn Dave (Abbot) on Mar 30, 2011 at 01:54 UTC
|
| [reply] |
|
|
It's Id3tag v2. I want to change all Id3tags (v1 and v2) tag automatically with this script. But how =(
| [reply] |
|
|
not tested, just quick look into doc:
$id3v1 = exists $mp3->{ID3v1}
? $mp3->{ID3v1}
: $mp3->new_tag("ID3v1")
| [reply] [d/l] |
A reply falls below the community's threshold of quality. You may see it by logging in.
|
Re: I need help about MP3::Tag and perl script.
by hawtin (Prior) on Mar 30, 2011 at 13:03 UTC
|
Oh, and cover art is a whole different challenge. Here's
how I do it (for ID3v2 and jpg images).
Update:
This defines a new subroutine called attach(). The first parameter has
no affect (its important in my script but for your purposes you can ignore
it). Suppose you want to attach a file "foo/cool.jpg" to an mp3
file called "1.mp3" as the front cover, you would just do (untested)
attach("","1.mp3","foo/cool.jpg");
This, of course, requires that you add the appropriate packages and
copy the definition of the subroutine somewhere into your script.
| [reply] [d/l] [select] |
|
|
if(!-w $mp3_file)
{
# This shouldn't happen but...
chmod 0755,$mp3_file;
}
Why do you try to make an MP3 file world executable if you can't read it? And why do you make it readable for group and world? Why do you even think about changing the mode of files that are not writeable?
There are usually good reasons for chmod -w somefile and chmod go-rw somefile: I don't want to accidentally modify a file in the first case, and I don't want others to read my files in the second case. Your hardcoded chmod 0755 ignores both. To make things worse, it sets the executable flag, possibly creating a new vulnerability.
I won't start with race conditions between stat (implied in -w) and open, because MP3::Tag has the same problem, so your code does not make it worse in this special case. Generally, one should not try to predict if open fails or succeeds by using stat. It can't work reliably (race condition), and it is not needed. open sets errno a.k.a. $! on error, and errno delivers sufficient information why open failed.
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
| [reply] [d/l] [select] |
|
|
First of all thank you very much about sharing your experiences with me. But could you please try a simple method cuz I do not understand anything at all I am learning perl now. So If you wrilte down the script again with my needs that I mention before. It wil be awesome and I would learn one thing about perl too. Waiting your support..
| [reply] |
|
|
|
|
wow that's awesome thanks. But I don't know where to edit the code. I understand logically but not enough knowledge. I try to be simple. Where should I write file name artist album song title cover picture name and location. for example: 1.mp3 will be the mp3 file imported and edited , these are the fixed edits song title is : xyz artist name:xx album:tt cover picture: /cool.jpg
so where should I write these datas on your script. Remember I will set a cron and run this script so mp3 file on my server will have id3tag changed or edited by me more clear and tidy mp3 =)
| [reply] |
Re: I need help about MP3::Tag and perl script.
by hawtin (Prior) on Mar 30, 2011 at 11:31 UTC
|
use Carp;
my $file = '1.mp3';
croak("Cannot write to file $file")
if(!-w $file);
You might like to check some of the resources here, for example Fixing mp3 tags for Android 2.0 contains
a tested script that uses MP3::Tag to set values in pretty much the way
you want.
| [reply] [d/l] |