Jump to content

ID3 UDF ID3v1 & ID3v2 MP3 Tags


joeyb1275
 Share

Recommended Posts

Updated ID3.au3 (see first post)

New Function:

_ID3GetTagField($Filename, $sFieldIDRequest)

It will read all the tag info into a buffer and return the requested tag info. If called again it checks the buffer to see if the tag data is there and returns the requested tag info. The file is still only opened once. See the comments for return values and @error and @extended values.

Here is some example code to use it:

$Filename = FileOpenDialog ( "Select Mp3 File", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "Muisc (*.mp3)")


$Title = _ID3GetTagField($Filename, "TIT2") ;gets ID3v2 Title
$err = @error
$ext = @extended
MsgBox(0,"$Title",$Title)
MsgBox(0,"Error & Extended", "Error: " & $err & @CRLF & "Extended: " & $ext)


$Title = _ID3GetTagField($Filename, "Title") ;gets ID3v1 Title
$err = @error
$ext = @extended
MsgBox(0,"$Title",$Title)
MsgBox(0,"Error & Extended", "Error: " & $err & @CRLF & "Extended: " & $ext)


$Comm = _ID3GetTagField($Filename, "COMM")
$err = @error
$ext = @extended
MsgBox(0,"$Comm",$Comm)
MsgBox(0,"Error & Extended", "Error: " & $err & @CRLF & "Extended: " & $ext)


_ID3DeleteFiles()

Let me know if there are any bugs.

Link to comment
Share on other sites

  • 4 weeks later...

In regards to id3 tags....

Anyone know what tag WMP writes to when you enable the global rating scheme...this is your personal rating that it writes to the file so your ratings don't get lost if you format your system and lose your WMP database.

Also need to know how to read/write it.

Thanks.

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

  • 1 month later...

Hi, I have just written a script for writing ID3v1 and ID3v2 tags using the ID3COM.DLL library. I have found there are more versions of this dll available on the net, so the one i have used was downloaded from http://mysite.wanadoo-members.co.uk/johnadcock/ID3COM.htm.

After downloading you will need to register the dll using "regsvr32 id3com.dll" from the command line.

Here is the sample code, maybe it will be useful for someone.

CODE
$tag = ObjCreate("Id3com.ID3comTag")

If Not IsObj($tag) Then

MsgBox (0,"error","error")

Exit

EndIf

$tag.link("testfile.mp3")

$tag.title = "Sample song"

$tag.Artist = "Some great artist"

$tag.Album = "The best of"

$tag.year = "1981"

$tag.comment = "Some comments..."

$tag.track = 11

$tag.Genre = 12

$tag.Savev1Tag

$tag.Savev2Tag

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...
  • 2 weeks later...

Sorry for the bump.. But I was having trouble getting this going...

821,43) : ERROR: BinaryString(): undefined function. $ImageHdr = BinaryString("0x" & $ImageHdr)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Know how I can get this going ?

This UDF was originally written using AutoIt v3.2.2. I am working on updating it for the latest version of AutoIt and adding some new Tag fields from ID3v2.4.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

I try to get the album art, and every single song I have it says found but not jpg.

I have added my latest ID3 UDF (See the first post for the latest file.). It should work with the latest Autoit. Let me know if you have problems. I am still working on making it better but it works now. I have added my writing functions for ID3v2 tags. You can try those too.

Please only test this on copies of you mp3 file for now, if there is an error it could possible corrupt the mp3 file.

Link to comment
Share on other sites

Thanks for sharing. :)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • 2 weeks later...

Am i missing something? I always get this error

C:\Program Files\AutoIt3\Include\ID3.au3 (492) : ==> Variable used without being declared.:

FileWrite($TagFile,$ZPAD)

FileWrite($TagFile,^ ERROR

->18:20:56 AutoIT3.exe ended.rc:1

I am using autoitversion 3.3.0.0

Edited by Arterie
Link to comment
Share on other sites

  • 1 month later...
  • 4 months later...

Am i missing something? I always get this error

C:\Program Files\AutoIt3\Include\ID3.au3 (492) : ==> Variable used without being declared.:

FileWrite($TagFile,$ZPAD)

FileWrite($TagFile,^ ERROR

->18:20:56 AutoIT3.exe ended.rc:1

I am using autoitversion 3.3.0.0

i have the same problem..

Link to comment
Share on other sites

  • 1 month later...

Sorry to dig up an old post, but I could use a little guidance on this if possible.

The following code should simply set Artist,TPE1, and TPE2 to "test artist", yet I only see this working for the TPE1 and TPE2, not Artist. Any idea how to get the ID3V1 artist to change easily with this?

$Filename = "C:\test.mp3"
$readArray = _ID3ReadTag( $Filename, 0, -1, 0 )


_ID3SetTagField("Artist", "test artist")
_ID3SetTagField("TPE1", "test artist")
_ID3SetTagField("TPE2", "test artist")
_ID3WriteTag($Filename)
MsgBox(0, "Artist", _ID3GetTagField("Artist"))
MsgBox(0, "TPE1", _ID3GetTagField("TPE1"))
MsgBox(0, "TPE2", _ID3GetTagField("TPE2"))

EDIT: I have this working now.

The UDF seems incomplete and required some tweaking. When setting the tag field vie _ID3SetTagField, the function does not actually parse many of the fields. The fix was to add the artist field there and adjust the ID3buffer to be written back to the file. All is working well now.

Thanks.

Edited by danwilli
Link to comment
Share on other sites

Is there any way to get and edit ID3 tags from M4a files? I'm too newbie in autoit. help me pls

You can either research the little information out there on the iTunes style meta data tags used in Mpeg-4 or you can use a command line utility that already works to power your application.

After a quick google search, I have found that atomicparsley can tag your mp4 files via command line.

Good luck.

Link to comment
Share on other sites

  • 4 weeks later...

Sorry to dig up an old post, but I could use a little guidance on this if possible.

The following code should simply set Artist,TPE1, and TPE2 to "test artist", yet I only see this working for the TPE1 and TPE2, not Artist. Any idea how to get the ID3V1 artist to change easily with this?

$Filename = "C:\test.mp3"
$readArray = _ID3ReadTag( $Filename, 0, -1, 0 )


_ID3SetTagField("Artist", "test artist")
_ID3SetTagField("TPE1", "test artist")
_ID3SetTagField("TPE2", "test artist")
_ID3WriteTag($Filename)
MsgBox(0, "Artist", _ID3GetTagField("Artist"))
MsgBox(0, "TPE1", _ID3GetTagField("TPE1"))
MsgBox(0, "TPE2", _ID3GetTagField("TPE2"))

EDIT: I have this working now.

The UDF seems incomplete and required some tweaking. When setting the tag field vie _ID3SetTagField, the function does not actually parse many of the fields. The fix was to add the artist field there and adjust the ID3buffer to be written back to the file. All is working well now.

Thanks.

Hi sorry to make you trouble. I also have same problem with this UDF and unable to set v1 tags. I would like to check the fixed u made more details or would u mind post you updated script in this forum? thanks a lot
Link to comment
Share on other sites

Hi sorry to make you trouble. I also have same problem with this UDF and unable to set v1 tags. I would like to check the fixed u made more details or would u mind post you updated script in this forum? thanks a lot

can anybody help me with this? pls. thanks a lot guys..........

Link to comment
Share on other sites

can anybody help me with this? pls. thanks a lot guys..........

I added the following to the end of the _ID3SetTagField function

Switch $FrameID ;this is added for v1 support (allows creation of v1 tag if not already present)
                Case "Title"
                    $ID3BufferArray[$ArrayIndex] = $FrameID & "|" &$sFieldValue
                Case "Artist"
                    $ID3BufferArray[$ArrayIndex] = $FrameID & "|" &$sFieldValue
                Case "Album"
                    $ID3BufferArray[$ArrayIndex] = $FrameID & "|" &$sFieldValue
                Case "Year"
                    $ID3BufferArray[$ArrayIndex] = $FrameID & "|" &$sFieldValue
                Case "Comment"
                    $ID3BufferArray[$ArrayIndex] = $FrameID & "|" &$sFieldValue
                Case "Track"
                    $ID3BufferArray[$ArrayIndex] = $FrameID & "|" &$sFieldValue
                Case "Genre"
                    $ID3BufferArray[$ArrayIndex] = $FrameID & "|" &$sFieldValue
            EndSwitch

note: Never remove the id3.1 fields....set them to blank instead (or " " for Year).

I am trying to make a func that removes version 2.2 tags.

If some kind soul has gotton somewhere with this...please post some info.

Link to comment
Share on other sites

I am trying to make a func that removes version 2.2 tags.

If some kind soul has gotten somewhere with this...please post some info.

I got it now. It reads 3_2.2 very well. My actual problem was that I have several files with multiple same tags.

It looks like iTunes tagged 3 COM tags to several files. ID3.AU3 looks for each tag once and then writes in version 3.3.

This will leave a 3.3 tag set with 3_2.2 COM tags that will not get read because it is no longer a 3_2.2 tag set.

I remove all tags 3 times before setting my own tag data and now the tags look clean as a sterilized whistle. :D

Link to comment
Share on other sites

  • 1 month later...

Hello.

Anyone know why this message box pops up every time I try to use this:

MsgBox Title: $FrameID Unknown

MsbBox Text: Version

I've tried it on a file that had ID3v1 and v2.3.

[EDIT]

Have found a way to make it work right.

The fourth parameter of the function "_ID3ReadTag" called "$iReturnArray" has a third, undocumented option --- "2".

I would still like to know what is wrong with using "1".

Edited by lee321987
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...