taz742 0 Report post Posted March 3, 2008 (edited) These function is based on Lazycat's UDF _MP3GetTag()I'll fix and rewrite it because his version wasn't fully support v1.0 and v1.1 ID3 TAG_MP3GetID3v1Tag()expandcollapse popup#include-once ;=============================================================================== ; Function Name: _MP3GetID3v1Tag($sFile) ; Description: Retrive MP3 ID3Tag v1.0 & v1.1 ; Parameter(s): $sFile = FileFullPath ; Requirement(s): Autoit v3.2.0 ; Return Value(s): On Success - array with data: ; 0 - Title ; 1 - Artist ; 2 - Album ; 3 - Year ; 4 - Comment ; 5 - Track number ; 6 - Genre ; 7 - Tag version ; On Failure empty string and sets @ERROR: ; -1 - File not found ; 1 - TAG not found ; Version : 2.6.0 ; Author(s): taz742 based on Lazycat's UDF _MP3GetTag() ;=============================================================================== ; Func _MP3GetID3v1Tag($sFile) Local $ret = DllCall("kernel32.dll", "int", "CreateFile", _ "str", $sFile, _ "int", 0x80000000, _ "int", 0, _ "ptr", 0, _ "int", 3, _ "int", 0x80, _ "ptr", 0), $error = 0 If @error Or Not $ret[0] Then $error = -1 Else Local $aID3v1 Local $pTag = _FileReadToStruct("char[3];char[30];char[30];char[30];char[4];char[28];byte[2];byte", $ret[0], FileGetSize($sFile) - 128) ;TAG Header|Title|Artist|Album|Year|Comment|Track|Genre If Not (DllStructGetData($pTag, 1) == "TAG") Then $error = 1 Else Dim $aID3v1[8] $aID3v1[0] = DllStructGetData($pTag, 2) ;Title $aID3v1[1] = DllStructGetData($pTag, 3) ;Artist $aID3v1[2] = DllStructGetData($pTag, 4) ;Album $aID3v1[3] = DllStructGetData($pTag, 5) ;Year If DllStructGetData($pTag, 7, 1) = 0 Then ;ID3Tag is v1.1 -> Track $aID3v1[4] = DllStructGetData($pTag, 6) ;Comment $aID3v1[5] = DllStructGetData($pTag, 7, 2) ;Track $aID3v1[7] = "1.1" ;version info Else ;ID3Tag is v1.0 -> Not Track $aID3v1[4] = DllStructGetData($pTag, 6) & String(BinaryToString(DllStructGetData($pTag, 7))) ;Comment $aID3v1[5] = "" ;Track is empty because not yet implanted in ID3v1.0 $aID3v1[7] = "1.0" ;version info EndIf $aID3v1[6] = _MP3GetGenreByID(DllStructGetData($pTag, 8)) ;Genre EndIf EndIf DllCall("kernel32.dll", "int", "CloseHandle", "int", $ret[0]) If Not $error Then Return $aID3v1 SetError($error) Return "" EndFunc ;==>_MP3GetID3v1Tag Func _MP3GetGenreByID($iID) Local $asGenre = StringSplit("Blues,Classic Rock,Country,Dance,Disco,Funk,Grunge,Hip-Hop," & _ "Jazz,Metal,New Age,Oldies,Other,Pop,R&B,Rap,Reggae,Rock,Techno,Industrial,Alternative," & _ "Ska,Death Metal,Pranks,Soundtrack,Euro-Techno,Ambient,Trip-Hop,Vocal,Jazz+Funk,Fusion," & _ "Trance,Classical,Instrumental,Acid,House,Game,Sound Clip,Gospel,Noise,Alternative Rock," & _ "Bass,Soul,Punk,Space,Meditative,Instrumental Pop,Instrumental Rock,Ethnic,Gothic,Darkwave," & _ "Techno-Industrial,Electronic,Pop-Folk,Eurodance,Dream,Southern Rock,Comedy,Cult,Gangsta," & _ "Top 40,Christian Rap,Pop/Funk,Jungle,Native US,Cabaret,New Wave,Psychadelic,Rave,Showtunes," & _ "Trailer,Lo-Fi,Tribal,Acid Punk,Acid Jazz,Polka,Retro,Musical,Rock & Roll,Hard Rock,Folk," & _ "Folk-Rock,National Folk,Swing,Fast Fusion,Bebob,Latin,Revival,Celtic,Bluegrass,Avantgarde," & _ "Gothic Rock,Progressive Rock,Psychedelic Rock,Symphonic Rock,Slow Rock,Big Band,Chorus," & _ "Easy Listening,Acoustic,Humour,Speech,Chanson,Opera,Chamber Music,Sonata,Symphony,Booty Bass," & _ "Primus,Porn Groove,Satire,Slow Jam,Club,Tango,Samba,Folklore,Ballad,Power Ballad,Rhytmic Soul," & _ "Freestyle,Duet,Punk Rock,Drum Solo,Acapella,Euro-House,Dance Hall,Goa,Drum & Bass,Club-House," & _ "Hardcore,Terror,Indie,BritPop,Negerpunk,Polsk Punk,Beat,Christian Gangsta,Heavy Metal,Black Metal," & _ "Crossover,Contemporary C,Christian Rock,Merengue,Salsa,Thrash Metal,Anime,JPop,SynthPop", ",") If ($iID >= 0) And ($iID < 148) Then Return $asGenre[$iID + 1] Return ("") EndFunc ;==>_MP3GetGenreByID Func _FileReadToStruct($vStruct, $hFile, $nOffset) If Not DllStructGetSize($vStruct) Then $vStruct = DllStructCreate($vStruct) Local $nLen = DllStructGetSize($vStruct) Local $ret = DllCall("kernel32.dll", "int", "SetFilePointer", _ "int", $hFile, _ "int", $nOffset, _ "int", 0, _ "int", 0) ; FILE_BEGIN Local $pRead = DllStructCreate("dword") $ret = DllCall("kernel32.dll", "int", "ReadFile", _ "int", $hFile, _ "ptr", DllStructGetPtr($vStruct), _ "int", $nLen, _ "ptr", DllStructGetPtr($pRead), _ "ptr", 0) If @error Then SetError(1) EndIf Local $nRead = DllStructGetData($pRead, 1) $pRead = 0 SetExtended($nRead) If Not ($nRead = $nLen) Then SetError(2) Return $vStruct EndFunc ;==>_FileReadToStruct_MP3GetID3v1Tag.rar Edited March 3, 2008 by taz742 Share this post Link to post Share on other sites
blitzkrg 1 Report post Posted March 3, 2008 These function is based on Lazycat's UDF _MP3GetTag()I'll fix and rewrite it because his version wasn't fully support v1.0 and v1.1 ID3 TAGThanks for the update!! Share this post Link to post Share on other sites