Jump to content

getID3Tag and setID3Tag


Xenobiologist
 Share

Recommended Posts

Hi,

so what did you change? What was the problem? Problem in my code, or your fault?

Mega

What? I didn't change anything. That code worked on one mp3 file then all the sudden I started getting an error.

C:\Source\Autoit\ID3 Fixer\ID3 Fixer.au3 (62) : ==> The requested action with this object has failed.:

$oId3.SaveToFile ($h_file)

$oId3.SaveToFile ($h_file)^ ERROR

[size="1"]Please stop confusing "how to" with "how do"[/size]

Link to comment
Share on other sites

  • Replies 45
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Couldn't figure it out?

I do not get any error - sorry!

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Ok I got it to work. For some reason your startup and shutdown functions didn't work and I had to manually register and unregister the dll.

[size="1"]Please stop confusing "how to" with "how do"[/size]

Link to comment
Share on other sites

  • 1 month later...

Hi,

I changed them. Thanks!

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • 3 months later...

Hi,

use something like this to get the array of mp3 files which you can iterate through to change the files.

#include<array.au3>

Global $StartPfad = @ScriptDir 
Global $FileTyp = 'mp3'
$aFiles = _GetFilesFolder_Rekursiv($StartPfad, $FileTyp, 0)

_ArrayDisplay($aFiles)

;==================================================================================================
; Function Name:   _GetFilesFolder_Rekursiv($sPath [, $sExt='*' [, $iDir=-1 [, $iRetType=0 ,[$sDelim='0']]]])
; Description:     Rekursive Auflistung von Dateien und/oder Ordnern
; Parameter(s):    $sPath     der Basispfad für die Auflistung ('.' -aktueller Pfad, '..' -Parentpfad)
;                  $sExt      Erweiterung für Dateiauswahl '*' oder -1 für alle (Standard)
;                  $iDir      -1 Dateien+Ordner(Standard), 0 nur Dateien, 1 nur Ordner
;      optional:   $iRetType  0 gibt Array, 1 gibt String zurück
;      optional:   $sDelim    legt Trennzeichen für Stringrückgabe fest
;                             0 -@CRLF (Standard); 1 -@CR; 2 -@LF; oder beliebiges Zeichen
; Return Value(s): Array (Standard) od. String mit den gefundenen Pfaden der Dateien und/oder Ordner
;                  Array[0] enthält die Anzahl der gefundenen Dateien/Ordner
; Author(s):       BugFix (bugfix@autoit.de)
;==================================================================================================
Func _GetFilesFolder_Rekursiv($sPath, $sExt='*', $iDir=-1, $iRetType=0, $sDelim='0')
    Global $oFSO = ObjCreate('Scripting.FileSystemObject')
    Global $strFiles = ''
    Switch $sDelim
        Case '1'
            $sDelim = @CR
        Case '2'
            $sDelim = @LF
        Case Else
            $sDelim = @CRLF
    EndSwitch
    If ($iRetType < 0) Or ($iRetType > 1) Then $iRetType = 0
    If $sExt = -1 Then $sExt = '*'
    If ($iDir < -1) Or ($iDir > 1) Then $iDir = -1
    _ShowSubFolders($oFSO.GetFolder($sPath),$sExt,$iDir,$sDelim)
    If $iRetType = 0 Then
        Local $aOut
        $aOut = StringSplit(StringTrimRight($strFiles,1), $sDelim, 1)
        If $aOut[1] = '' Then 
            ReDim $aOut[1]
            $aOut[0] = 0
        EndIf
        Return $aOut
    Else
        Return StringTrimRight($strFiles,1)
    EndIf
EndFunc

Func _ShowSubFolders($Folder, $Ext='*', $Dir=-1, $Delim=@CRLF)
    If Not IsDeclared("strFiles") Then Global $strFiles = ''
    If ($Dir = -1) Or ($Dir = 0) Then 
        For $file In $Folder.Files
            If $Ext <> '*' Then
                If StringRight($file.Name, StringLen($Ext)) = $Ext Then _
                    $strFiles &= $file.Path & $Delim
            Else
                $strFiles &= $file.Path & $Delim
            EndIf
        Next
    EndIf
    For $Subfolder In $Folder.SubFolders
        If ($Dir = -1) Or ($Dir = 1) Then $strFiles &= $Subfolder.Path & '\' & $Delim
        _ShowSubFolders($Subfolder, $Ext, $Dir, $Delim)
    Next
EndFunc

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

use something like this to get the array of mp3 files which you can iterate through to change the files.

#include<array.au3>

Global $StartPfad = @ScriptDir 
Global $FileTyp = 'mp3'
$aFiles = _GetFilesFolder_Rekursiv($StartPfad, $FileTyp, 0)

_ArrayDisplay($aFiles)

;==================================================================================================
; Function Name:   _GetFilesFolder_Rekursiv($sPath [, $sExt='*' [, $iDir=-1 [, $iRetType=0 ,[$sDelim='0']]]])
; Description:     Rekursive Auflistung von Dateien und/oder Ordnern
; Parameter(s):    $sPath     der Basispfad für die Auflistung ('.' -aktueller Pfad, '..' -Parentpfad)
;                  $sExt      Erweiterung für Dateiauswahl '*' oder -1 für alle (Standard)
;                  $iDir      -1 Dateien+Ordner(Standard), 0 nur Dateien, 1 nur Ordner
;      optional:   $iRetType  0 gibt Array, 1 gibt String zurück
;      optional:   $sDelim    legt Trennzeichen für Stringrückgabe fest
;                             0 -@CRLF (Standard); 1 -@CR; 2 -@LF; oder beliebiges Zeichen
; Return Value(s): Array (Standard) od. String mit den gefundenen Pfaden der Dateien und/oder Ordner
;                  Array[0] enthält die Anzahl der gefundenen Dateien/Ordner
; Author(s):       BugFix (bugfix@autoit.de)
;==================================================================================================
Func _GetFilesFolder_Rekursiv($sPath, $sExt='*', $iDir=-1, $iRetType=0, $sDelim='0')
    Global $oFSO = ObjCreate('Scripting.FileSystemObject')
    Global $strFiles = ''
    Switch $sDelim
        Case '1'
            $sDelim = @CR
        Case '2'
            $sDelim = @LF
        Case Else
            $sDelim = @CRLF
    EndSwitch
    If ($iRetType < 0) Or ($iRetType > 1) Then $iRetType = 0
    If $sExt = -1 Then $sExt = '*'
    If ($iDir < -1) Or ($iDir > 1) Then $iDir = -1
    _ShowSubFolders($oFSO.GetFolder($sPath),$sExt,$iDir,$sDelim)
    If $iRetType = 0 Then
        Local $aOut
        $aOut = StringSplit(StringTrimRight($strFiles,1), $sDelim, 1)
        If $aOut[1] = '' Then 
            ReDim $aOut[1]
            $aOut[0] = 0
        EndIf
        Return $aOut
    Else
        Return StringTrimRight($strFiles,1)
    EndIf
EndFunc

Func _ShowSubFolders($Folder, $Ext='*', $Dir=-1, $Delim=@CRLF)
    If Not IsDeclared("strFiles") Then Global $strFiles = ''
    If ($Dir = -1) Or ($Dir = 0) Then 
        For $file In $Folder.Files
            If $Ext <> '*' Then
                If StringRight($file.Name, StringLen($Ext)) = $Ext Then _
                    $strFiles &= $file.Path & $Delim
            Else
                $strFiles &= $file.Path & $Delim
            EndIf
        Next
    EndIf
    For $Subfolder In $Folder.SubFolders
        If ($Dir = -1) Or ($Dir = 1) Then $strFiles &= $Subfolder.Path & '\' & $Delim
        _ShowSubFolders($Subfolder, $Ext, $Dir, $Delim)
    Next
EndFunc

Mega

i am also interested in setting MP3 files information but i how can i combine your first script with this one to set Tags to all files of my computer?

Aladdin

_______________________________
Link to comment
Share on other sites

i am also interested in setting MP3 files information but i how can i combine your first script with this one to set Tags to all files of my computer?

Aladdin

Hi,

try this:

#include<array.au3>

Global $StartPfad = @ScriptDir
Global $FileTyp = 'mp3'
$aFiles = _GetFilesFolder_Rekursiv($StartPfad, $FileTyp, 0)

;~ _ArrayDisplay($aFiles)

_DLLstartup()

For $i = 1 To UBound($aFiles) - 1
    ConsoleWrite($aFiles[$i] & @CRLF)
    _setID3Tag($aFiles[$i], 'Genre', 'Mega')
    ConsoleWrite($i & @CRLF)
    If @error Then MsgBox(0, 'Error', 'Error - setID3Tag', 5)
Next

For $i = 1 To UBound($aFiles) - 1
    $re = _getID3Tag($aFiles[$i])
    If @error Then
        MsgBox(0, 'Error', 'Error - no array returned', 5)
        Exit (0)
    EndIf
    _ArrayDisplay($re, $aFiles[$i])
Next

_DLLshutdown()

;===================================================================================================
; 'TitleAlbum', 'Movie', 'Title', 'CopyrightYear', 'CopyrightHolder', 'Comments', 'Label',
; 'BeatsPerMinute', 'LeadArtist', 'PartOfSet', 'TrackPosition', 'Year', 'Genre', 'FileId', 'ISRC'
;===================================================================================================
Func _setID3Tag($h_file, $detail, $value)
    Local $oId3 = ObjCreate("CDDBControl.CddbID3Tag")
    If Not IsObj($oId3) Then
        SetError(1)
        Return 0
    EndIf
    ; False means open for read-write
    $oId3.LoadFromFile($h_file, False)

    Switch $detail
        Case 'TitleAlbum'
            $oId3.Album = $value
        Case 'LeadArtist'
            $oId3.LeadArtist = $value
        Case 'Title'
            $oId3.Title = $value
        Case 'TrackPosition'
            $oId3.TrackPosition = $value
        Case 'Year'
            $oId3.Year = $value
        Case 'Genre'
            $oId3.Genre = $value
        Case 'Comments'
            $oId3.Comments = $value
        Case 'Label'
            $oId3.Label = $value
        Case 'FileID'
            $oId3.FileId = $value
        Case 'IRSC'
            $oId3.ISRC = $value
        Case 'CopyrightHolder'
            $oId3.CopyrightHolder = $value
        Case 'CopyrightYear'
            $oId3.CopyrightYear = $value
        Case 'PartOfSet'
            $oId3.PartOfSet = $value
        Case 'Movie'
            $oId3.Movie = $value
        Case 'BeatsPerMinute'
            $oId3.BeatsPerMinute = $value
        Case Else
            SetError(2)
            Return 0
    EndSwitch
    $oId3.SaveToFile($h_file)
    Return 1
EndFunc   ;==>_setID3Tag

Func _getID3Tag($h_file)
    Local $oId3 = ObjCreate("CDDBControl.CddbID3Tag")
    If Not IsObj($oId3) Then
        SetError(1)
        Return 0
    EndIf
    $oId3.LoadFromFile($h_file, False)
    Local $idTag_A[15][2]
    $idTag_A[0][0] = 'Title'
    $idTag_A[0][1] = $oId3.Title
    $idTag_A[1][0] = 'LeadArtist'
    $idTag_A[1][1] = $oId3.LeadArtist
    $idTag_A[2][0] = 'Album'
    $idTag_A[2][1] = $oId3.Album
    $idTag_A[3][0] = 'TrackPosition'
    $idTag_A[3][1] = $oId3.TrackPosition
    $idTag_A[4][0] = 'Year'
    $idTag_A[4][1] = $oId3.Year
    $idTag_A[5][0] = 'Genre'
    $idTag_A[5][1] = $oId3.Genre
    $idTag_A[6][0] = 'Comments'
    $idTag_A[6][1] = $oId3.Comments
    $idTag_A[7][0] = 'Label'
    $idTag_A[7][1] = $oId3.Label
    $idTag_A[8][0] = 'FileId'
    $idTag_A[8][1] = $oId3.FileId
    $idTag_A[9][0] = 'ISRC'
    $idTag_A[9][1] = $oId3.ISRC
    $idTag_A[10][0] = 'CopyrightHolder'
    $idTag_A[10][1] = $oId3.CopyrightHolder
    $idTag_A[11][0] = 'CopyrightYear'
    $idTag_A[11][1] = $oId3.CopyrightYear
    $idTag_A[12][0] = 'PartOfSet'
    $idTag_A[12][1] = $oId3.PartOfSet
    $idTag_A[13][0] = 'Movie'
    $idTag_A[13][1] = $oId3.Movie
    $idTag_A[14][0] = 'BeatsPerMinute'
    $idTag_A[14][1] = $oId3.BeatsPerMinute
    Return $idTag_A
EndFunc   ;==>_getID3Tag

Func _DLLstartup($DLLpath = '')
    If $DLLpath = Default Or $DLLpath = '' Then $DLLpath = @ScriptDir & '\cddbcontrol.dll'
    RunWait('regsvr32 /s ' & '"' & $DLLpath & '"')
EndFunc   ;==>_DLLstartup

Func _DLLshutdown($DLLpath = '')
    If $DLLpath = Default Or $DLLpath = '' Then $DLLpath = @ScriptDir & '\cddbcontrol.dll'
    RunWait('regsvr32 /u /s ' & '"' & $DLLpath & '"')
EndFunc   ;==>_DLLshutdown

;==================================================================================================
; Function Name:   _GetFilesFolder_Rekursiv($sPath [, $sExt='*' [, $iDir=-1 [, $iRetType=0 ,[$sDelim='0']]]])
; Description:     Rekursive Auflistung von Dateien und/oder Ordnern
; Parameter(s):    $sPath     der Basispfad für die Auflistung ('.' -aktueller Pfad, '..' -Parentpfad)
;                  $sExt      Erweiterung für Dateiauswahl '*' oder -1 für alle (Standard)
;                  $iDir      -1 Dateien+Ordner(Standard), 0 nur Dateien, 1 nur Ordner
;      optional:   $iRetType  0 gibt Array, 1 gibt String zurück
;      optional:   $sDelim    legt Trennzeichen für Stringrückgabe fest
;                             0 -@CRLF (Standard); 1 -@CR; 2 -@LF; oder beliebiges Zeichen
; Return Value(s): Array (Standard) od. String mit den gefundenen Pfaden der Dateien und/oder Ordner
;                  Array[0] enthält die Anzahl der gefundenen Dateien/Ordner
; Author(s):       BugFix (bugfix@autoit.de)
;==================================================================================================
Func _GetFilesFolder_Rekursiv($sPath, $sExt = '*', $iDir = -1, $iRetType = 0, $sDelim = '0')
    Global $oFSO = ObjCreate('Scripting.FileSystemObject')
    Global $strFiles = ''
    Switch $sDelim
        Case '1'
            $sDelim = @CR
        Case '2'
            $sDelim = @LF
        Case Else
            $sDelim = @CRLF
    EndSwitch
    If ($iRetType < 0) Or ($iRetType > 1) Then $iRetType = 0
    If $sExt = -1 Then $sExt = '*'
    If ($iDir < -1) Or ($iDir > 1) Then $iDir = -1
    _ShowSubFolders($oFSO.GetFolder($sPath), $sExt, $iDir, $sDelim)
    If $iRetType = 0 Then
        Local $aOut
;~         $aOut = StringSplit(StringTrimRight($strFiles, 1), $sDelim, 1)
        $aOut = StringSplit(StringStripWS($strFiles, 2), $sDelim, 1)
        If $aOut[1] = '' Then
            ReDim $aOut[1]
            $aOut[0] = 0
        EndIf
        Return $aOut
    Else
;~         Return StringTrimRight($strFiles, 1)
        Return StringStripWS($strFiles, 2)
    EndIf
EndFunc   ;==>_GetFilesFolder_Rekursiv

Func _ShowSubFolders($Folder, $Ext = '*', $Dir = -1, $Delim = @CRLF)
    If Not IsDeclared("strFiles") Then Global $strFiles = ''
    If ($Dir = -1) Or ($Dir = 0) Then
        For $file In $Folder.Files
            If $Ext <> '*' Then
                If StringRight($file.Name, StringLen($Ext)) = $Ext Then _
                        $strFiles &= $file.Path & $Delim
            Else
                $strFiles &= $file.Path & $Delim
            EndIf
        Next
    EndIf
    For $Subfolder In $Folder.SubFolders
        If ($Dir = -1) Or ($Dir = 1) Then $strFiles &= $Subfolder.Path & '\' & $Delim
        _ShowSubFolders($Subfolder, $Ext, $Dir, $Delim)
    Next
EndFunc   ;==>_ShowSubFolders

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

A little off topic...maybe....just came across this, can you set the album image in an mp3 using this...or is there another script here that can do that?

Hi,

I don't think that dll can handle it, but maybe somebody can write a wrapper for : http://www.audiogenie.de/

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • 3 months later...

Is there a way to use the _setID3Tag function to clear a specific tag? I've tried > _setID3Tag($file,'TrackPosition'.'') but it still leaves the current value in. I'd prefer not to clear it by using a space character.

Thanks

Link to comment
Share on other sites

Hi,

seems there no way to get it done that way. Maybe you find something here: ID3-Impl.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Is there a way to use the _setID3Tag function to clear a specific tag? I've tried > _setID3Tag($file,'TrackPosition'.'') but it still leaves the current value in. I'd prefer not to clear it by using a space character.

Thanks

You might take a look at the command-line ID3.EXE program at http://home.wanadoo.nl/squell/id3.html

It's old and has some limitations, but does allow reading/writing/deleting of specific tags.

Link to comment
Share on other sites

Your ID3 expert has arrived. You guys DO realize that all this can be done without the use of a DLL? Including these functions as they stand, you'd need to include the DLL or is the DLL a windows provided one?

I'll be porting over my ID3v1 read/write and my ID3v2 reading script from the other languages I have it written in to AutoIt this evening to give you guys a DLL free alternative that can be used, and you can study to further understand the ID3 tagging.

A basic ID3 primer to get you started:

ID3v1 was, obviously, the first iteration of tagging to be defined. It is RIFF compatible, given that it comes at the end of the file/datastream. It's implementation was to satisfy the need to tag any RIFF files on a system to store more detailed information about the file. Publication year, artist, track name, etc, but was limited in size to help keep files from being bloated with too much metadata. That's where ID3v2 comes in.

ID3v2.x is the next and presumably final iteration of the tagging format. This format differs from ID3v1 in that it comes BEFORE the datastream, and can contain an almost infinite number of tags. Also, there is no set position for tags such as there is for ID3v1 (more on that later), and new forms of information can be added through the use of new four letter tag codes. Originally album art jpeg files weren't embedded in the mp3s, not until the 4 letter tag code for it came out and it was widely accepted among audio players. Also with this format, any tags that a player does not understand/recognize, are to be preserved rather than dumped upon a tagging update, as well as ignored.

Blah, blah, blah... lip service... lip service.Working on a number of projects right now, just waiting for my time to post them here on AutoIt forums.

Link to comment
Share on other sites

Your ID3 expert has arrived. You guys DO realize that all this can be done without the use of a DLL? Including these functions as they stand, you'd need to include the DLL or is the DLL a windows provided one?

I'll be porting over my ID3v1 read/write and my ID3v2 reading script from the other languages I have it written in to AutoIt this evening to give you guys a DLL free alternative that can be used, and you can study to further understand the ID3 tagging.

A basic ID3 primer to get you started:

ID3v1 was, obviously, the first iteration of tagging to be defined. It is RIFF compatible, given that it comes at the end of the file/datastream. It's implementation was to satisfy the need to tag any RIFF files on a system to store more detailed information about the file. Publication year, artist, track name, etc, but was limited in size to help keep files from being bloated with too much metadata. That's where ID3v2 comes in.

ID3v2.x is the next and presumably final iteration of the tagging format. This format differs from ID3v1 in that it comes BEFORE the datastream, and can contain an almost infinite number of tags. Also, there is no set position for tags such as there is for ID3v1 (more on that later), and new forms of information can be added through the use of new four letter tag codes. Originally album art jpeg files weren't embedded in the mp3s, not until the 4 letter tag code for it came out and it was widely accepted among audio players. Also with this format, any tags that a player does not understand/recognize, are to be preserved rather than dumped upon a tagging update, as well as ignored.

Well, I for one will be interested to see your efforts!

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

Well, I for one will be interested to see your efforts!

I'm actually going all the way this time with the ID3v2 tagger. I'm relearning the structure so I can fully edit the ID3v2 tags, and I've got a solid idea of how to pull it off, i've just run into a few slight snags. I need to convert 32bit of data to 28bit by dropping the 8th (and final) bit on every byte, I'm working on that now. This script is going to have to be heavily commented so I can come back to it later. The original script I wrote 6 years ago in another language was VERY simplistic, I'm doing a complete rewrite to support ID3v2 fully, not just reading.

Edited by Cynagen

Blah, blah, blah... lip service... lip service.Working on a number of projects right now, just waiting for my time to post them here on AutoIt forums.

Link to comment
Share on other sites

Here's the ID3v1 tagging UDFs, reading and writing functionality, full support. As you can see I researched and did this work originally almost 6 years ago. Wasn't too hard to port, just that having to write up a tag reader was a slight pain in the ass. The ID3v2 has a lot of little technical things that need to be done in order to operate properly, so I'm working on that still, but this is just a sampler to get your fingers busy, and get rid of that DLL.

;ID3v1 Writer by Cynagen
;Original Date: 11-13-2003
;Use: _id3v1w(Filename,Artist,Title,Album,Year,Comment,Track#,Genre#)
;Ported to AutoIt May 25, 2009
func _id3v1w($file,$tit,$art,$alb,$yer,$com,$trk,$gnr)
    $trk=number($trk)
    $gnr=number($gnr)
    $yer=number($yer)
    if ($tit) then
        $id3 = stringtobinary(stringleft($tit,30))
        if stringlen($tit) < 30 then $id3 &= binary("0x"&str("00",30-stringlen($tit)))
    else
        $id3 = binary("0x"&str("00",30))
    EndIf
    if ($art) Then
        $id3 &= stringtobinary(stringleft($art,30))
        if stringlen($art) < 30 then $id3 &= binary("0x"&str("00",30-stringlen($art)))
    Else
        $id3 &= binary("0x"&str("00",30))
    EndIf
    if ($alb) Then
        $id3 &= stringtobinary(stringleft($alb,30))
        if stringlen($alb) < 30 then $id3 &= binary("0x"&str("00",30-stringlen($alb)))
    Else
        $id3 &= binary("0x"&str("00",30))
    EndIf
    if ($yer) Then
        if stringlen($yer) < 4 then $id3 &= binary("0x"&str("00",4-stringlen($yer)))
        $id3 &= stringtobinary(stringleft($yer,4))
    Else
        $id3 &= binary("0x00000000")
    EndIf
    if ($com) then
        $id3 &= stringtobinary(stringleft($com,29))
        if stringlen($com) < 29 then $id3 &= binary("0x"&str("00",29-stringlen($com)))
    Else
        $id3 &= binary("0x"&str("00",29))
    EndIf
    if $trk AND isnumber($trk) AND $trk > 0 AND $trk <= 256 then 
        $id3 &= binary(stringleft(binary($trk),4))
    Else
        $id3 &= binary("0x00")
    EndIf
    if $gnr AND isnumber($gnr) AND $gnr > 0 AND $trk <= 256 Then
        $id3 &= binary(stringleft(binary($gnr),4))
    Else
        $id3 &= binary("0x00")
    EndIf
    $id3=stringtobinary("TAG")&$id3
    $tagchk = fileopen($file,16)
    $checktag = fileread($tagchk)
    fileclose($tagchk)
    if binarytostring(binarymid($checktag,filegetsize($file)-127,3)) <> "TAG" Then
        consolewrite("notag "&binarytostring(binarymid($checktag,filegetsize($file)-127,3)))
        $tagwrite = fileopen($file,17)
        filewrite($tagwrite,$id3)
        fileclose($tagwrite)
        return 1
    Else
        consolewrite("istag "&binarytostring(binarymid($checktag,filegetsize($file)-127,3)))
        $size=filegetsize($file)-127
        $tagwrite = fileopen($file,18)
        filewrite($tagwrite,binarymid($checktag,1,$size))
        filewrite($tagwrite,$id3)
        fileclose($tagwrite)
        return 1
    EndIf
endfunc

func str($str,$x)
    $out=""
    for $r=1 to $x
        $out&=$str
    Next
    return $out
EndFunc

;ID3v1 Reader by Cynagen
;Written May 28, 2009
;Usage: _id3v1r($Filename)
;Returns: Array($sTitle,$sArtist,$sAlbum,$nYear,$sComment,$nTrack,$nGenre)
;Error returns 0
func _id3v1r($file)
    $tagchk = fileopen($file,16)
    $id3 = binarymid(fileread($tagchk),filegetsize($file)-127,128)
    fileclose($tagchk)
    dim $out[7]
    if binarytostring(binarymid($id3,1,3)) = "TAG" then 
        $out[0]=binarytostring(Binarymid($id3,4,30))
        $out[1]=binarytostring(binarymid($id3,34,30))
        $out[2]=binarytostring(binarymid($id3,64,30))
        $out[3]=binarytostring(binarymid($id3,94,4))
        $out[4]=binarytostring(binarymid($id3,98,29))
        $out[5]=binarytostring(binarymid($id3,127,1))
        $out[6]=binarytostring(binarymid($id3,128,1))
    EndIf
    return $out
EndFunc

EDIT: Fixed FileSize->FileGetSize in _id3v1r function.

Edited by Cynagen

Blah, blah, blah... lip service... lip service.Working on a number of projects right now, just waiting for my time to post them here on AutoIt forums.

Link to comment
Share on other sites

I've been testing the reader and I get a error?

ERROR: filesize(): undefined function.

$id3 = binarymid(fileread($tagchk),filesize($file)

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

C:\Users\nend\Desktop\Nieuw - AutoIt v3 Script.au3 - 1 error(s), 0 warning(s)

It looks like there are something missing?

Here's the ID3v1 tagging UDFs, reading and writing functionality, full support. As you can see I researched and did this work originally almost 6 years ago. Wasn't too hard to port, just that having to write up a tag reader was a slight pain in the ass. The ID3v2 has a lot of little technical things that need to be done in order to operate properly, so I'm working on that still, but this is just a sampler to get your fingers busy, and get rid of that DLL.

;ID3v1 Writer by Cynagen
;Original Date: 11-13-2003
;Use: _id3v1w(Filename,Artist,Title,Album,Year,Comment,Track#,Genre#)
;Ported to AutoIt May 25, 2009
func _id3v1w($file,$tit,$art,$alb,$yer,$com,$trk,$gnr)
    $trk=number($trk)
    $gnr=number($gnr)
    $yer=number($yer)
    if ($tit) then
        $id3 = stringtobinary(stringleft($tit,30))
        if stringlen($tit) < 30 then $id3 &= binary("0x"&str("00",30-stringlen($tit)))
    else
        $id3 = binary("0x"&str("00",30))
    EndIf
    if ($art) Then
        $id3 &= stringtobinary(stringleft($art,30))
        if stringlen($art) < 30 then $id3 &= binary("0x"&str("00",30-stringlen($art)))
    Else
        $id3 &= binary("0x"&str("00",30))
    EndIf
    if ($alb) Then
        $id3 &= stringtobinary(stringleft($alb,30))
        if stringlen($alb) < 30 then $id3 &= binary("0x"&str("00",30-stringlen($alb)))
    Else
        $id3 &= binary("0x"&str("00",30))
    EndIf
    if ($yer) Then
        if stringlen($yer) < 4 then $id3 &= binary("0x"&str("00",4-stringlen($yer)))
        $id3 &= stringtobinary(stringleft($yer,4))
    Else
        $id3 &= binary("0x00000000")
    EndIf
    if ($com) then
        $id3 &= stringtobinary(stringleft($com,29))
        if stringlen($com) < 29 then $id3 &= binary("0x"&str("00",29-stringlen($com)))
    Else
        $id3 &= binary("0x"&str("00",29))
    EndIf
    if $trk AND isnumber($trk) AND $trk > 0 AND $trk <= 256 then 
        $id3 &= binary(stringleft(binary($trk),4))
    Else
        $id3 &= binary("0x00")
    EndIf
    if $gnr AND isnumber($gnr) AND $gnr > 0 AND $trk <= 256 Then
        $id3 &= binary(stringleft(binary($gnr),4))
    Else
        $id3 &= binary("0x00")
    EndIf
    $id3=stringtobinary("TAG")&$id3
    $tagchk = fileopen($file,16)
    $checktag = fileread($tagchk)
    fileclose($tagchk)
    if binarytostring(binarymid($checktag,filegetsize($file)-127,3)) <> "TAG" Then
        consolewrite("notag "&binarytostring(binarymid($checktag,filegetsize($file)-127,3)))
        $tagwrite = fileopen($file,17)
        filewrite($tagwrite,$id3)
        fileclose($tagwrite)
        return 1
    Else
        consolewrite("istag "&binarytostring(binarymid($checktag,filegetsize($file)-127,3)))
        $size=filegetsize($file)-127
        $tagwrite = fileopen($file,18)
        filewrite($tagwrite,binarymid($checktag,1,$size))
        filewrite($tagwrite,$id3)
        fileclose($tagwrite)
        return 1
    EndIf
endfunc

func str($str,$x)
    $out=""
    for $r=1 to $x
        $out&=$str
    Next
    return $out
EndFunc

;ID3v1 Reader by Cynagen
;Written May 28, 2009
;Usage: _id3v1r($Filename)
;Returns: Array($sTitle,$sArtist,$sAlbum,$nYear,$sComment,$nTrack,$nGenre)
;Error returns 0
func _id3v1r($file)
    $tagchk = fileopen($file,16)
    $id3 = binarymid(fileread($tagchk),filesize($file)-127,128)
    fileclose($tagchk)
    dim $out[7]
    if binarytostring(binarymid($id3,1,3)) = "TAG" then 
        $out[0]=binarytostring(Binarymid($id3,4,30))
        $out[1]=binarytostring(binarymid($id3,34,30))
        $out[2]=binarytostring(binarymid($id3,64,30))
        $out[3]=binarytostring(binarymid($id3,94,4))
        $out[4]=binarytostring(binarymid($id3,98,29))
        $out[5]=binarytostring(binarymid($id3,127,1))
        $out[6]=binarytostring(binarymid($id3,128,1))
    EndIf
    return $out
EndFunc
Edited by nend
Link to comment
Share on other sites

Hi,

filsize must be FileGetSize.

Maybe here something else to have a look at : http://www.autoitscript.com/forum/index.ph...c=95786&hl=

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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