Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

ID3 UDF ID3v1 & ID3v2 MP3 Tags


  • Please log in to reply
151 replies to this topic

#21 joeyb1275

joeyb1275

    Wayfarer

  • Active Members
  • Pip
  • 61 posts

Posted 09 May 2007 - 11:59 AM

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:
AutoIt         
$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.







#22 sshrum

sshrum

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 538 posts

Posted 01 June 2007 - 03:34 AM

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 :: Shrum Consultingsean[at]shrum[dot]net :: http://www.shrum.net---------------Skinner: 'Oh, brandishing your buttocks is only making me angrier!'Me: 'Make it idiot-proof, and someone will make a better idiot'Me (sort of): 'Give a man a fish and you feed him for a day. Teach a man to fish and he'll snag some part of his body with a rusty hook, get tetanus, and surely die'---------------All my published AU3-based apps and utilities

#23 dandz

dandz

    Seeker

  • New Members
  • 2 posts

Posted 12 July 2007 - 03:30 PM

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


#24 fabs

fabs

    Seeker

  • New Members
  • 4 posts

Posted 08 August 2008 - 06:14 PM

Is it possible to read out the interpreter of the mp3 file? Your example does just return twice the title, but the third msgbox is empty.

#25 Ghost21

Ghost21

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 387 posts

Posted 30 September 2008 - 06:19 AM

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 ?

#26 joeyb1275

joeyb1275

    Wayfarer

  • Active Members
  • Pip
  • 61 posts

Posted 13 October 2008 - 04:47 PM

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.

#27 TehWhale

TehWhale

    Whalee..

  • Banned (NOT IN USE)
  • 1,482 posts

Posted 23 October 2008 - 12:26 AM

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

#28 joeyb1275

joeyb1275

    Wayfarer

  • Active Members
  • Pip
  • 61 posts

Posted 15 December 2008 - 01:13 AM

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.

#29 TheSaint

TheSaint

    *** Knight Templar ***

  • MVPs
  • 5,443 posts

Posted 15 December 2008 - 10:25 PM

Thanks for sharing. :)

Make sure brain is in gear before opening mouth! Ignoring those who try to divert conversation with irrelevancies. If I put effort into communication, I expect you to read properly & fully, or just not comment. 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


#30 Arterie

Arterie

    Wayfarer

  • Active Members
  • Pip
  • 79 posts

Posted 28 December 2008 - 05:21 PM

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, 28 December 2008 - 05:23 PM.


#31 Achilles

Achilles

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,897 posts

Posted 31 January 2009 - 06:11 AM

This looks like it will work AMAZINGLY for a script I was thinking of writing. Thanks!!

#32 Gianni

Gianni

    Seeker

  • New Members
  • 2 posts

Posted 24 June 2009 - 07:33 AM

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

#33 DW1

DW1

    Central Scrutinizer

  • Active Members
  • PipPipPipPipPipPip
  • 2,107 posts

Posted 12 August 2009 - 06:56 PM

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, 12 August 2009 - 08:53 PM.


#34 KaungSan

KaungSan

    Seeker

  • Active Members
  • 5 posts

Posted 13 August 2009 - 09:20 AM

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

#35 DW1

DW1

    Central Scrutinizer

  • Active Members
  • PipPipPipPipPipPip
  • 2,107 posts

Posted 13 August 2009 - 03:24 PM

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.

#36 KaungSan

KaungSan

    Seeker

  • Active Members
  • 5 posts

Posted 08 September 2009 - 08:18 AM

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

#37 KaungSan

KaungSan

    Seeker

  • Active Members
  • 5 posts

Posted 09 September 2009 - 05:14 AM

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

#38 Tungsten

Tungsten

    Seeker

  • Normal Members
  • 6 posts

Posted 14 September 2009 - 04:27 AM

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.

#39 Tungsten

Tungsten

    Seeker

  • Normal Members
  • 6 posts

Posted 15 September 2009 - 03:31 PM

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

#40 lee321987

lee321987

    Seeker

  • Active Members
  • 47 posts

Posted 01 November 2009 - 02:07 PM

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, 03 November 2009 - 06:30 PM.





1 user(s) are reading this topic

1 members, 0 guests, 0 anonymous users


    D0KT0Ri