Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes MenúCitar TagLib Sharp UltraId3Lib
Tiempo transcurrido para eliminar los tags ID3v1 + ID3v2 de 1.000 archivos mp3 (5,2 GB) 05:40 minutos 03:10 minutos
#Region " UltraID3Lib "
' [ UltraID3Lib Helper ]
'
' // By Elektro H@cker
'
'
' Instructions:
' 1. Add a reference to "UltraID3Lib.dll" into the project.
'
'
' Examples:
'
' MsgBox(UltraID3Lib.FileIsCorrupt("C:\File.mp3")) ' Result: True or False
' MsgBox(UltraID3Lib.ID3v1_Exist("C:\File.mp3")) ' Result: True or False
' MsgBox(UltraID3Lib.ID3v2_Exist("C:\File.mp3")) ' Result: True or False
' MsgBox(UltraID3Lib.IsVBR("C:\File.mp3")) ' Result: True or False
' MsgBox(UltraID3Lib.Get_Metadata_Errors("C:\File.mp3"))
' MsgBox(UltraID3Lib.Get_Metadata_Warnings("C:\File.mp3"))
'
' MsgBox(UltraID3Lib.Get_ID3_Tags("C:\File.mp3"))
' MsgBox(UltraID3Lib.Get_Title("C:\File.mp3"))
' MsgBox(UltraID3Lib.Get_Artist("C:\File.mp3"))
' MsgBox(UltraID3Lib.Get_Album("C:\File.mp3"))
' MsgBox(UltraID3Lib.Get_Genre("C:\File.mp3"))
' MsgBox(UltraID3Lib.Get_Year("C:\File.mp3"))
' MsgBox(UltraID3Lib.Get_Basic_Tag_Fields("C:\File.mp3"))
'
' UltraID3Lib.Remove_ID3v1_Tag("C:\File.mp3") ' Removes ID3v1 Tag
' UltraID3Lib.Remove_ID3v2_Tag("C:\File.mp3") ' Removes ID3v2 Tag
' UltraID3Lib.Remove_ID3v1_ID3v2_Tags("C:\File.mp3") ' Removes ID3v1 + ID3v2 Tags
'
' UltraID3Lib.Set_Tag_Field("C:\File.mp3", Sub(x) x.ID3v2Tag.Title = "Title Test")
' UltraID3Lib.Set_Tag_Fields("C:\File.mp3", {Sub(x) x.ID3v2Tag.Title = "Title Test", Sub(x) x.ID3v2Tag.Artist = "Artist Test"})
'
' UltraID3Lib.Set_Main_Cover("C:\File.mp3", "C:\Image.jpg")
' UltraID3Lib.Add_Cover("C:\File.mp3", "C:\Image.jpg")
' UltraID3Lib.Delete_Covers("C:\File.mp3")
' PictureBox1.BackgroundImage = UltraID3Lib.Get_Main_Cover("C:\File.mp3")
'
' For Each Genre As String In UltraID3Lib.Get_Generic_ID3_Genres() : MsgBox(Genre) : Next
'
' MsgBox(UltraID3Lib.Get_Bitrate("C:\File.mp3")) ' Result: 320
' MsgBox(UltraID3Lib.Get_Duration("C:\File.mp3")) ' Result: 00:00:00:000
' MsgBox(UltraID3Lib.Get_Frequency("C:\File.mp3")) ' Result: 44100
' MsgBox(UltraID3Lib.Get_Channels("C:\File.mp3")) ' Result: JointStereo
' MsgBox(UltraID3Lib.Get_Layer("C:\File.mp3")) ' Result: MPEGLayer3
' MsgBox(UltraID3Lib.Get_Filesize("C:\File.mp3")) ' Result: 6533677
Imports HundredMilesSoftware.UltraID3Lib
Public Class UltraID3Lib
''' <summary>
''' Stores the UltraID3Lib object.
''' </summary>
Private Shared [UltraID3] As New UltraID3
' ''' <summary>
' ''' Stores the Picture things.
' ''' </summary>
' Private Shared CurrentPictureFrame As ID3v2PictureFrame ' Not used in this Class
' Private Shared PictureTypes As ArrayList ' Not used in this Class
' Private Shared PictureFrames As ID3FrameCollection ' Not used in this Class
' Private Shared PictureIndex As Integer ' Not used in this Class
''' <summary>
''' Checks if file is possibly corrupt.
''' </summary>
Public Shared Function FileIsCorrupt(ByVal File As String) As Boolean
Try
[UltraID3].Read(File)
Return Convert.ToBoolean( _
[UltraID3].GetExceptions(ID3ExceptionLevels.Error).Length _
+ [UltraID3].GetExceptions(ID3ExceptionLevels.Warning).Length)
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Checks for errors inside file metadata.
''' </summary>
Public Shared Function Get_Metadata_Errors(ByVal File As String) As String
Try
[UltraID3].Read(File)
Return String.Join(Environment.NewLine, _
[UltraID3].GetExceptions(ID3ExceptionLevels.Error) _
.Select(Function(ex) ex.Message))
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Checks for warnings inside file metadata.
''' </summary>
Public Shared Function Get_Metadata_Warnings(ByVal File As String) As String
Try
[UltraID3].Read(File)
Return String.Join(Environment.NewLine, _
[UltraID3].GetExceptions(ID3ExceptionLevels.Warning) _
.Select(Function(ex) ex.Message))
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Checks if ID3v1 exists in file.
''' </summary>
Public Shared Function ID3v1_Exist(ByVal File As String) As Boolean
Try
[UltraID3].Read(File)
Return [UltraID3].ID3v1Tag.ExistsInFile
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Checks if ID3v2 exists in file.
''' </summary>
Public Shared Function ID3v2_Exist(ByVal File As String) As Boolean
Try
[UltraID3].Read(File)
Return [UltraID3].ID3v2Tag.ExistsInFile
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Gets ID3 TagTypes of file.
''' </summary>
Public Shared Function Get_ID3_Tags(ByVal File As String) As String
Try
[UltraID3].Read(File)
Return String.Format("{0}{1}", _
If([UltraID3].ID3v1Tag.ExistsInFile, "ID3v1, ", ""), _
If([UltraID3].ID3v2Tag.ExistsInFile, " ID3v2", "")).Trim
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Removes entire ID3v1 Tag from file.
''' </summary>
Public Shared Sub Remove_ID3v1_Tag(ByVal File As String)
Try
[UltraID3].Read(File)
[UltraID3].ID3v1Tag.Clear()
[UltraID3].Write()
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub
''' <summary>
''' Removes entire ID3v2 Tag from file.
''' </summary>
Public Shared Sub Remove_ID3v2_Tag(ByVal File As String)
Try
[UltraID3].Read(File)
[UltraID3].ID3v2Tag.Clear()
[UltraID3].Write()
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub
''' <summary>
''' Removes entire ID3v1 + ID3v2 Tags from file.
''' </summary>
Public Shared Sub Remove_ID3v1_ID3v2_Tags(ByVal File As String)
Try
[UltraID3].Read(File)
[UltraID3].ID3v1Tag.Clear()
[UltraID3].ID3v2Tag.Clear()
[UltraID3].Write()
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub
''' <summary>
''' Gets the Title tag field of file.
''' </summary>
Public Shared Function Get_Title(ByVal File As String) As String
Try
[UltraID3].Read(File)
Return [UltraID3].Title
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Gets the Artist tag field of file.
''' </summary>
Public Shared Function Get_Artist(ByVal File As String) As String
Try
[UltraID3].Read(File)
Return [UltraID3].Artist
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Gets the Album tag field of file.
''' </summary>
Public Shared Function Get_Album(ByVal File As String) As String
Try
[UltraID3].Read(File)
Return [UltraID3].Album
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Gets the Genre tag field of file.
''' </summary>
Public Shared Function Get_Genre(ByVal File As String) As String
Try
[UltraID3].Read(File)
Return [UltraID3].Genre
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Gets the Year tag field of file.
''' </summary>
Public Shared Function Get_Year(ByVal File As String) As String
Try
[UltraID3].Read(File)
Return [UltraID3].Year
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Gets the basic tag fields of file.
''' </summary>
Public Shared Function Get_Basic_Tag_Fields(ByVal File As String) As String
Try
[UltraID3].Read(File)
Return String.Format("Title: {1}{0}Artist: {2}{0}Album: {3}{0}Genre: {4}{0}Year: {5}", Environment.NewLine, _
[UltraID3].Title, _
[UltraID3].Artist, _
[UltraID3].Album, _
[UltraID3].Genre, _
[UltraID3].Year)
Catch ex As Exception
Throw New Exception(ex.Message)
Return String.Empty
End Try
End Function
''' <summary>
''' Sets a Tag field.
''' </summary>
Public Shared Sub Set_Tag_Field(ByVal File As String, _
ByVal FieldSetter As Action(Of UltraID3))
Try
[UltraID3].Read(File)
FieldSetter([UltraID3])
[UltraID3].Write()
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub
''' <summary>
''' Sets multiple Tag fields.
''' </summary>
Public Shared Sub Set_Tag_Fields(ByVal File As String, _
ByVal FieldSetter() As Action(Of UltraID3))
Try
[UltraID3].Read(File)
For Each Field As Action(Of UltraID3) In FieldSetter
Field([UltraID3])
Next
[UltraID3].Write()
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub
''' <summary>
''' Sets Main Picture Cover.
''' </summary>
Public Shared Sub Set_Main_Cover(ByVal File As String, _
ByVal Picture As String)
Try
[UltraID3].Read(File)
[UltraID3].ID3v2Tag.Frames.Add( _
New ID3v23PictureFrame(New Bitmap(Picture), PictureTypes.CoverFront, String.Empty, TextEncodingTypes.Unicode))
[UltraID3].Write()
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub
''' <summary>
''' Adds a Picture Cover.
''' </summary>
Public Shared Sub Add_Cover(ByVal File As String, _
ByVal Picture As String)
Try
[UltraID3].Read(File)
[UltraID3].ID3v2Tag.Frames.Add( _
New ID3v23PictureFrame(New Bitmap(Picture), PictureTypes.Other, String.Empty, TextEncodingTypes.Unicode))
[UltraID3].Write()
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub
''' <summary>
''' Deletes all Picture Covers.
''' </summary>
Public Shared Sub Delete_Covers(ByVal File As String)
Try
[UltraID3].Read(File)
[UltraID3].ID3v2Tag.Frames.Remove( _
[UltraID3].ID3v2Tag.Frames.GetFrames(MultipleInstanceID3v2FrameTypes.ID3v22Picture))
[UltraID3].ID3v2Tag.Frames.Remove( _
[UltraID3].ID3v2Tag.Frames.GetFrames(MultipleInstanceID3v2FrameTypes.ID3v23Picture))
[UltraID3].Write()
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub
''' <summary>
''' Gets Main Picture Cover.
''' </summary>
Public Shared Function Get_Main_Cover(ByVal File As String) As Bitmap
Try
[UltraID3].Read(File)
If [UltraID3].ID3v2Tag.Frames.GetFrame(MultipleInstanceID3v2FrameTypes.ID3v23Picture, False) IsNot Nothing Then
Return DirectCast( _
[UltraID3].ID3v2Tag.Frames.GetFrame(MultipleInstanceID3v2FrameTypes.ID3v23Picture, False), _
ID3v2PictureFrame).Picture
End If
If [UltraID3].ID3v2Tag.Frames.GetFrame(MultipleInstanceID3v2FrameTypes.ID3v22Picture, False) IsNot Nothing Then
Return DirectCast( _
[UltraID3].ID3v2Tag.Frames.GetFrame(MultipleInstanceID3v2FrameTypes.ID3v22Picture, False), _
ID3v2PictureFrame).Picture
End If
Return Nothing
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Gets the generic ID3 genre names.
''' </summary>
Public Shared Function Get_Generic_ID3_Genres() As String()
Return UltraID3.GenreInfos.Cast(Of GenreInfo).Select(Function(Genre) Genre.Name).ToArray
End Function
''' <summary>
''' Gets the Audio Bitrate.
''' </summary>
Public Shared Function Get_Bitrate(ByVal File As String) As Short
Try
[UltraID3].Read(File)
Return [UltraID3].FirstMPEGFrameInfo.Bitrate
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Gets the Audio Duration.
''' </summary>
Public Shared Function Get_Duration(ByVal File As String) As String
Try
[UltraID3].Read(File)
Return String.Format("{0:00}:{1:00}:{2:00}:{3:000}", _
[UltraID3].FirstMPEGFrameInfo.Duration.Hours, _
[UltraID3].FirstMPEGFrameInfo.Duration.Minutes, _
[UltraID3].FirstMPEGFrameInfo.Duration.Seconds, _
[UltraID3].FirstMPEGFrameInfo.Duration.Milliseconds)
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Gets the Audio Frequency.
''' </summary>
Public Shared Function Get_Frequency(ByVal File As String) As Integer
Try
[UltraID3].Read(File)
Return [UltraID3].FirstMPEGFrameInfo.Frequency
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Gets the Audio MPEG Layer.
''' </summary>
Public Shared Function Get_Layer(ByVal File As String) As String
Try
[UltraID3].Read(File)
Return [UltraID3].FirstMPEGFrameInfo.Layer.ToString
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Gets the Audio Channel mode.
''' </summary>
Public Shared Function Get_Channels(ByVal File As String) As String
Try
[UltraID3].Read(File)
Return [UltraID3].FirstMPEGFrameInfo.Mode.ToString
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Gets the File Size.
''' </summary>
Public Shared Function Get_Filesize(ByVal File As String) As Long
Try
[UltraID3].Read(File)
Return [UltraID3].Size
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
''' <summary>
''' Checks if VBR header is present in file.
''' </summary>
Public Shared Function IsVBR(ByVal File As String) As Boolean
Try
[UltraID3].Read(File)
Return [UltraID3].FirstMPEGFrameInfo.VBRInfo.WasFound
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
End Class
#End Region
#Region " TagLib Sharp Helper "
' [ TagLib Sharp Helper ]
'
' // By Elektro H@cker
'
'
' Instructions:
' 1. Add a reference to "taglib-sharp.dll" into the project.
'
'
' Examples:
'
' MsgBox(TagLibSharp.FileIsCorrupt("C:\File.mp3")) ' Result: True or False
' MsgBox(TagLibSharp.FileIsWriteable("C:\File.mp3")) ' Result: True or False
' MsgBox(TagLibSharp.Get_Title("C:\File.mp3"))
' MsgBox(TagLibSharp.Get_Artist("C:\File.mp3"))
' MsgBox(TagLibSharp.Get_Album("C:\File.mp3"))
' MsgBox(TagLibSharp.Get_Genre("C:\File.mp3"))
' MsgBox(TagLibSharp.Get_Year("C:\File.mp3"))
' MsgBox(TagLibSharp.Get_Basic_TagInfo("C:\File.mp3"))
' TagLibSharp.RemoveTag("C:\File.mp3", TagLib.TagTypes.Id3v1 Or TagLib.TagTypes.Id3v2) ' Removes ID3v1 + ID3v2 Tags
' TagLibSharp.Set_Tag_Fields("C:\Test.mp3", Sub(x) x.Tag.Title = "Title Test"})
' TagLibSharp.Set_Tag_Fields("C:\Test.mp3", {Sub(x) x.Tag.Title = "Title Test", Sub(x) x.Tag.Performers = {"Artist Test"}})
Public Class TagLibSharp
''' <summary>
''' Stores the Taglib object.
''' </summary>
Private Shared TagFile As TagLib.File = Nothing
''' <summary>
''' Checks if file is possibly corrupted.
''' </summary>
Public Shared Function FileIsCorrupt(ByVal File As String) As Boolean
Try
Return TagLib.File.Create(File).PossiblyCorrupt
Catch ex As Exception
Throw New Exception(ex.Message)
Return True
Finally
If TagFile IsNot Nothing Then TagFile.Dispose()
End Try
End Function
''' <summary>
''' Checks if file can be written.
''' </summary>
Public Shared Function FileIsWriteable(ByVal File As String) As Boolean
Try
Return TagLib.File.Create(File).Writeable
Catch ex As Exception
Throw New Exception(ex.Message)
Return True
Finally
If TagFile IsNot Nothing Then TagFile.Dispose()
End Try
End Function
''' <summary>
''' Get TagTypes of file.
''' </summary>
Public Shared Function Get_Tags(ByVal File As String) As String
Try
Return TagLib.File.Create(File).TagTypes.ToString
Catch ex As Exception
Throw New Exception(ex.Message)
Return String.Empty
Finally
If TagFile IsNot Nothing Then TagFile.Dispose()
End Try
End Function
''' <summary>
''' Remove a entire Tag from file.
''' </summary>
Public Shared Sub RemoveTag(ByVal File As String, ByVal TagTypes As TagLib.TagTypes)
Try
TagFile = TagLib.File.Create(File)
Catch ex As Exception
Throw New Exception(ex.Message)
Exit Sub
End Try
Try
If Not TagFile.PossiblyCorrupt _
AndAlso TagFile.Writeable Then
TagFile.RemoveTags(TagTypes)
TagFile.Save()
End If
Catch ex As Exception
Throw New Exception(ex.Message)
Finally
If TagFile IsNot Nothing Then TagFile.Dispose()
End Try
End Sub
''' <summary>
''' Gets the Title tag field of file.
''' </summary>
Public Shared Function Get_Title(ByVal File As String) As String
Try
Return TagLib.File.Create(File).Tag.Title
Catch ex As Exception
Throw New Exception(ex.Message)
Return String.Empty
Finally
If TagFile IsNot Nothing Then TagFile.Dispose()
End Try
End Function
''' <summary>
''' Gets the Artist tag field of file.
''' </summary>
Public Shared Function Get_Artist(ByVal File As String) As String
Try
Return TagLib.File.Create(File).Tag.Performers(0)
Catch ex As Exception
Throw New Exception(ex.Message)
Return String.Empty
Finally
If TagFile IsNot Nothing Then TagFile.Dispose()
End Try
End Function
''' <summary>
''' Gets the Album tag field of file.
''' </summary>
Public Shared Function Get_Album(ByVal File As String) As String
Try
Return TagLib.File.Create(File).Tag.Album
Catch ex As Exception
Throw New Exception(ex.Message)
Return String.Empty
Finally
If TagFile IsNot Nothing Then TagFile.Dispose()
End Try
End Function
''' <summary>
''' Gets the Genre tag field of file.
''' </summary>
Public Shared Function Get_Genre(ByVal File As String) As String
Try
Return TagLib.File.Create(File).Tag.Genres(0)
Catch ex As Exception
Throw New Exception(ex.Message)
Return String.Empty
Finally
If TagFile IsNot Nothing Then TagFile.Dispose()
End Try
End Function
''' <summary>
''' Gets the Year tag field of file.
''' </summary>
Public Shared Function Get_Year(ByVal File As String) As String
Try
Return TagLib.File.Create(File).Tag.Year
Catch ex As Exception
Throw New Exception(ex.Message)
Return String.Empty
Finally
If TagFile IsNot Nothing Then TagFile.Dispose()
End Try
End Function
''' <summary>
''' Gets the basic tag fields of file.
''' </summary>
Public Shared Function Get_Basic_TagInfo(ByVal File As String) As String
Try
TagFile = TagLib.File.Create(File)
Return String.Format("Title: {1}{0}Artist: {2}{0}Album: {3}{0}Genre: {4}{0}Year: {5}", Environment.NewLine, _
TagFile.Tag.Title, _
TagFile.Tag.Performers(0), _
TagFile.Tag.Album, _
TagFile.Tag.Genres(0), _
TagFile.Tag.Year)
Catch ex As Exception
Throw New Exception(ex.Message)
Return String.Empty
Finally
If TagFile IsNot Nothing Then TagFile.Dispose()
End Try
End Function
''' <summary>
''' Sets a Tag field.
''' </summary>
Public Shared Sub Set_Tag_Fields(ByVal File As String, _
ByVal FieldSetter As Action(Of TagLib.File))
Try
TagFile = TagLib.File.Create(File)
Catch ex As Exception
Throw New Exception(ex.Message)
Exit Sub
End Try
Try
If Not TagFile.PossiblyCorrupt _
AndAlso TagFile.Writeable Then
FieldSetter(TagFile)
TagFile.Save()
End If
Catch ex As Exception
Throw New Exception(ex.Message)
Finally
If TagFile IsNot Nothing Then TagFile.Dispose()
End Try
End Sub
''' <summary>
''' Sets multiple Tag fields.
''' </summary>
Public Shared Sub Set_Tag_Fields(ByVal File As String, _
ByVal FieldSetter() As Action(Of TagLib.File))
Try
TagFile = TagLib.File.Create(File)
Catch ex As Exception
Throw New Exception(ex.Message)
Exit Sub
End Try
Try
If Not TagFile.PossiblyCorrupt _
AndAlso TagFile.Writeable Then
For Each Field In FieldSetter
Field(TagFile)
Next
TagFile.Save()
End If
Catch ex As Exception
Throw New Exception(ex.Message)
Finally
If TagFile IsNot Nothing Then TagFile.Dispose()
End Try
End Sub
End Class
#End Region
Cita de: daryo en 5 Octubre 2013, 18:36 PMWTF con algunas personas
Cita de: Inzect02 en 5 Octubre 2013, 17:36 PMEy yo lo hice para probar un rato el servidor, ya que estoy haciendo una herramienta que en unas semanas lo publicare.
@ECHO OFF
START /B "" "%ProgramFiles%\Plantas Contra Zombis\plantsvszombies.exe"
START /B "" "http://www.google.com/" & Rem Esto iniciará el navegador predeterminado.
Pause&Exit
Cita de: jemez44 en 4 Octubre 2013, 18:33 PMEntendí que para que te saliera el correspondiente icono debias tener instalado el correspondiente programa que lo abre.
Cita de: jemez44 en 4 Octubre 2013, 16:41 PMSi en la imagen sale ".pl" ¿eso significa que tengo instalado un intérprete de perl?