elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


  Mostrar Mensajes
Páginas: 1 ... 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 [807] 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 ... 1236
8061  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 5 Octubre 2013, 23:53 pm
Un ayudante de la librería UltraId3Lib: http://home.fuse.net/honnert/UltraID3Lib/UltraID3Lib0968.zip

La diferencia entre esta librería y TagLib Sharp es que UltraID3Lib trabaja sólamente metadatos de tipo ID3v1 e ID3v2 (y las variantes de ID3v2, y los Covers)

Esta librería está optimizada para trabajar archivos MP3, de hecho sólamente trabaja archivos mp3, además hice un pequeño test de velocidad y estos fueron los resultados:

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

Ahora... si tuviera que elegir entre la lógica interna que usa cada librería, lo cierto es que no sabría por cual decidirme, por eso hice un ayudante para las dos librerías xD.

EDITO: He extendido la Class para manejar las carátulas de los mp3.

EDITO: He vuelto ha extender la Class para exprimir un poco más la librería.

Código
  1. #Region " UltraID3Lib "
  2.  
  3.  
  4.  
  5. ' [ UltraID3Lib Helper ]
  6. '
  7. ' // By Elektro H@cker
  8. '
  9. '
  10. ' Instructions:
  11. ' 1. Add a reference to "UltraID3Lib.dll" into the project.
  12. '
  13. '
  14. ' Examples:
  15. '
  16. ' MsgBox(UltraID3Lib.FileIsCorrupt("C:\File.mp3")) ' Result: True or False
  17. ' MsgBox(UltraID3Lib.ID3v1_Exist("C:\File.mp3"))   ' Result: True or False
  18. ' MsgBox(UltraID3Lib.ID3v2_Exist("C:\File.mp3"))   ' Result: True or False
  19. ' MsgBox(UltraID3Lib.IsVBR("C:\File.mp3"))         ' Result: True or False
  20. ' MsgBox(UltraID3Lib.Get_Metadata_Errors("C:\File.mp3"))
  21. ' MsgBox(UltraID3Lib.Get_Metadata_Warnings("C:\File.mp3"))
  22. '
  23. ' MsgBox(UltraID3Lib.Get_ID3_Tags("C:\File.mp3"))
  24. ' MsgBox(UltraID3Lib.Get_Title("C:\File.mp3"))
  25. ' MsgBox(UltraID3Lib.Get_Artist("C:\File.mp3"))
  26. ' MsgBox(UltraID3Lib.Get_Album("C:\File.mp3"))
  27. ' MsgBox(UltraID3Lib.Get_Genre("C:\File.mp3"))
  28. ' MsgBox(UltraID3Lib.Get_Year("C:\File.mp3"))
  29. ' MsgBox(UltraID3Lib.Get_Basic_Tag_Fields("C:\File.mp3"))
  30. '
  31. ' UltraID3Lib.Remove_ID3v1_Tag("C:\File.mp3") ' Removes ID3v1 Tag
  32. ' UltraID3Lib.Remove_ID3v2_Tag("C:\File.mp3") ' Removes ID3v2 Tag
  33. ' UltraID3Lib.Remove_ID3v1_ID3v2_Tags("C:\File.mp3") ' Removes ID3v1 + ID3v2 Tags
  34. '
  35. ' UltraID3Lib.Set_Tag_Field("C:\File.mp3", Sub(x) x.ID3v2Tag.Title = "Title Test")
  36. ' UltraID3Lib.Set_Tag_Fields("C:\File.mp3", {Sub(x) x.ID3v2Tag.Title = "Title Test", Sub(x) x.ID3v2Tag.Artist = "Artist Test"})
  37. '
  38. ' UltraID3Lib.Set_Main_Cover("C:\File.mp3", "C:\Image.jpg")
  39. ' UltraID3Lib.Add_Cover("C:\File.mp3", "C:\Image.jpg")
  40. ' UltraID3Lib.Delete_Covers("C:\File.mp3")
  41. ' PictureBox1.BackgroundImage = UltraID3Lib.Get_Main_Cover("C:\File.mp3")
  42. '
  43. ' For Each Genre As String In UltraID3Lib.Get_Generic_ID3_Genres() : MsgBox(Genre) : Next
  44. '
  45. ' MsgBox(UltraID3Lib.Get_Bitrate("C:\File.mp3")) ' Result: 320
  46. ' MsgBox(UltraID3Lib.Get_Duration("C:\File.mp3")) ' Result: 00:00:00:000
  47. ' MsgBox(UltraID3Lib.Get_Frequency("C:\File.mp3")) ' Result: 44100
  48. ' MsgBox(UltraID3Lib.Get_Channels("C:\File.mp3")) ' Result: JointStereo
  49. ' MsgBox(UltraID3Lib.Get_Layer("C:\File.mp3")) ' Result: MPEGLayer3
  50. ' MsgBox(UltraID3Lib.Get_Filesize("C:\File.mp3")) ' Result: 6533677
  51.  
  52.  
  53.  
  54. Imports HundredMilesSoftware.UltraID3Lib
  55.  
  56. Public Class UltraID3Lib
  57.  
  58.    ''' <summary>
  59.    ''' Stores the UltraID3Lib object.
  60.    ''' </summary>
  61.    Private Shared [UltraID3] As New UltraID3
  62.  
  63.    ' ''' <summary>
  64.    ' ''' Stores the Picture things.
  65.    ' ''' </summary>
  66.    ' Private Shared CurrentPictureFrame As ID3v2PictureFrame ' Not used in this Class
  67.    ' Private Shared PictureTypes As ArrayList ' Not used in this Class
  68.    ' Private Shared PictureFrames As ID3FrameCollection ' Not used in this Class
  69.    ' Private Shared PictureIndex As Integer ' Not used in this Class
  70.  
  71.    ''' <summary>
  72.    ''' Checks if file is possibly corrupt.
  73.    ''' </summary>
  74.    Public Shared Function FileIsCorrupt(ByVal File As String) As Boolean
  75.  
  76.        Try
  77.            [UltraID3].Read(File)
  78.            Return Convert.ToBoolean( _
  79.                       [UltraID3].GetExceptions(ID3ExceptionLevels.Error).Length _
  80.                     + [UltraID3].GetExceptions(ID3ExceptionLevels.Warning).Length)
  81.  
  82.        Catch ex As Exception
  83.            Throw New Exception(ex.Message)
  84.        End Try
  85.  
  86.    End Function
  87.  
  88.    ''' <summary>
  89.    ''' Checks for errors inside file metadata.
  90.    ''' </summary>
  91.    Public Shared Function Get_Metadata_Errors(ByVal File As String) As String
  92.  
  93.        Try
  94.            [UltraID3].Read(File)
  95.            Return String.Join(Environment.NewLine, _
  96.                               [UltraID3].GetExceptions(ID3ExceptionLevels.Error) _
  97.                               .Select(Function(ex) ex.Message))
  98.  
  99.        Catch ex As Exception
  100.            Throw New Exception(ex.Message)
  101.        End Try
  102.  
  103.    End Function
  104.  
  105.    ''' <summary>
  106.    ''' Checks for warnings inside file metadata.
  107.    ''' </summary>
  108.    Public Shared Function Get_Metadata_Warnings(ByVal File As String) As String
  109.  
  110.        Try
  111.            [UltraID3].Read(File)
  112.            Return String.Join(Environment.NewLine, _
  113.                               [UltraID3].GetExceptions(ID3ExceptionLevels.Warning) _
  114.                               .Select(Function(ex) ex.Message))
  115.  
  116.        Catch ex As Exception
  117.            Throw New Exception(ex.Message)
  118.        End Try
  119.  
  120.    End Function
  121.  
  122.    ''' <summary>
  123.    ''' Checks if ID3v1 exists in file.
  124.    ''' </summary>
  125.    Public Shared Function ID3v1_Exist(ByVal File As String) As Boolean
  126.  
  127.        Try
  128.            [UltraID3].Read(File)
  129.            Return [UltraID3].ID3v1Tag.ExistsInFile
  130.        Catch ex As Exception
  131.            Throw New Exception(ex.Message)
  132.        End Try
  133.  
  134.    End Function
  135.  
  136.    ''' <summary>
  137.    ''' Checks if ID3v2 exists in file.
  138.    ''' </summary>
  139.    Public Shared Function ID3v2_Exist(ByVal File As String) As Boolean
  140.  
  141.        Try
  142.            [UltraID3].Read(File)
  143.            Return [UltraID3].ID3v2Tag.ExistsInFile
  144.        Catch ex As Exception
  145.            Throw New Exception(ex.Message)
  146.        End Try
  147.  
  148.    End Function
  149.  
  150.    ''' <summary>
  151.    ''' Gets ID3 TagTypes of file.
  152.    ''' </summary>
  153.    Public Shared Function Get_ID3_Tags(ByVal File As String) As String
  154.  
  155.        Try
  156.            [UltraID3].Read(File)
  157.  
  158.            Return String.Format("{0}{1}", _
  159.                                 If([UltraID3].ID3v1Tag.ExistsInFile, "ID3v1, ", ""), _
  160.                                 If([UltraID3].ID3v2Tag.ExistsInFile, " ID3v2", "")).Trim
  161.  
  162.        Catch ex As Exception
  163.            Throw New Exception(ex.Message)
  164.  
  165.        End Try
  166.  
  167.    End Function
  168.  
  169.    ''' <summary>
  170.    ''' Removes entire ID3v1 Tag from file.
  171.    ''' </summary>
  172.    Public Shared Sub Remove_ID3v1_Tag(ByVal File As String)
  173.  
  174.        Try
  175.            [UltraID3].Read(File)
  176.            [UltraID3].ID3v1Tag.Clear()
  177.            [UltraID3].Write()
  178.  
  179.        Catch ex As Exception
  180.            Throw New Exception(ex.Message)
  181.  
  182.        End Try
  183.  
  184.    End Sub
  185.  
  186.    ''' <summary>
  187.    ''' Removes entire ID3v2 Tag from file.
  188.    ''' </summary>
  189.    Public Shared Sub Remove_ID3v2_Tag(ByVal File As String)
  190.  
  191.        Try
  192.            [UltraID3].Read(File)
  193.            [UltraID3].ID3v2Tag.Clear()
  194.            [UltraID3].Write()
  195.  
  196.        Catch ex As Exception
  197.            Throw New Exception(ex.Message)
  198.  
  199.        End Try
  200.  
  201.    End Sub
  202.  
  203.    ''' <summary>
  204.    ''' Removes entire ID3v1 + ID3v2 Tags from file.
  205.    ''' </summary>
  206.    Public Shared Sub Remove_ID3v1_ID3v2_Tags(ByVal File As String)
  207.  
  208.        Try
  209.            [UltraID3].Read(File)
  210.            [UltraID3].ID3v1Tag.Clear()
  211.            [UltraID3].ID3v2Tag.Clear()
  212.            [UltraID3].Write()
  213.  
  214.        Catch ex As Exception
  215.            Throw New Exception(ex.Message)
  216.  
  217.        End Try
  218.  
  219.    End Sub
  220.  
  221.    ''' <summary>
  222.    ''' Gets the Title tag field of file.
  223.    ''' </summary>
  224.    Public Shared Function Get_Title(ByVal File As String) As String
  225.  
  226.        Try
  227.            [UltraID3].Read(File)
  228.            Return [UltraID3].Title
  229.  
  230.        Catch ex As Exception
  231.            Throw New Exception(ex.Message)
  232.  
  233.        End Try
  234.  
  235.    End Function
  236.  
  237.    ''' <summary>
  238.    ''' Gets the Artist tag field of file.
  239.    ''' </summary>
  240.    Public Shared Function Get_Artist(ByVal File As String) As String
  241.  
  242.        Try
  243.            [UltraID3].Read(File)
  244.            Return [UltraID3].Artist
  245.  
  246.        Catch ex As Exception
  247.            Throw New Exception(ex.Message)
  248.  
  249.        End Try
  250.  
  251.    End Function
  252.  
  253.    ''' <summary>
  254.    ''' Gets the Album tag field of file.
  255.    ''' </summary>
  256.    Public Shared Function Get_Album(ByVal File As String) As String
  257.  
  258.        Try
  259.            [UltraID3].Read(File)
  260.            Return [UltraID3].Album
  261.  
  262.        Catch ex As Exception
  263.            Throw New Exception(ex.Message)
  264.  
  265.        End Try
  266.  
  267.    End Function
  268.  
  269.    ''' <summary>
  270.    ''' Gets the Genre tag field of file.
  271.    ''' </summary>
  272.    Public Shared Function Get_Genre(ByVal File As String) As String
  273.  
  274.        Try
  275.            [UltraID3].Read(File)
  276.            Return [UltraID3].Genre
  277.  
  278.        Catch ex As Exception
  279.            Throw New Exception(ex.Message)
  280.  
  281.        End Try
  282.  
  283.    End Function
  284.  
  285.    ''' <summary>
  286.    ''' Gets the Year tag field of file.
  287.    ''' </summary>
  288.    Public Shared Function Get_Year(ByVal File As String) As String
  289.  
  290.        Try
  291.            [UltraID3].Read(File)
  292.            Return [UltraID3].Year
  293.  
  294.        Catch ex As Exception
  295.            Throw New Exception(ex.Message)
  296.  
  297.        End Try
  298.  
  299.    End Function
  300.  
  301.    ''' <summary>
  302.    ''' Gets the basic tag fields of file.
  303.    ''' </summary>
  304.    Public Shared Function Get_Basic_Tag_Fields(ByVal File As String) As String
  305.  
  306.        Try
  307.            [UltraID3].Read(File)
  308.  
  309.            Return String.Format("Title: {1}{0}Artist: {2}{0}Album: {3}{0}Genre: {4}{0}Year: {5}", Environment.NewLine, _
  310.                                 [UltraID3].Title, _
  311.                                 [UltraID3].Artist, _
  312.                                 [UltraID3].Album, _
  313.                                 [UltraID3].Genre, _
  314.                                 [UltraID3].Year)
  315.  
  316.        Catch ex As Exception
  317.            Throw New Exception(ex.Message)
  318.            Return String.Empty
  319.  
  320.        End Try
  321.  
  322.    End Function
  323.  
  324.    ''' <summary>
  325.    ''' Sets a Tag field.
  326.    ''' </summary>
  327.    Public Shared Sub Set_Tag_Field(ByVal File As String, _
  328.                                    ByVal FieldSetter As Action(Of UltraID3))
  329.  
  330.        Try
  331.            [UltraID3].Read(File)
  332.            FieldSetter([UltraID3])
  333.            [UltraID3].Write()
  334.  
  335.        Catch ex As Exception
  336.            Throw New Exception(ex.Message)
  337.  
  338.        End Try
  339.  
  340.    End Sub
  341.  
  342.    ''' <summary>
  343.    ''' Sets multiple Tag fields.
  344.    ''' </summary>
  345.    Public Shared Sub Set_Tag_Fields(ByVal File As String, _
  346.                                     ByVal FieldSetter() As Action(Of UltraID3))
  347.  
  348.  
  349.        Try
  350.            [UltraID3].Read(File)
  351.  
  352.            For Each Field As Action(Of UltraID3) In FieldSetter
  353.                Field([UltraID3])
  354.            Next
  355.  
  356.            [UltraID3].Write()
  357.  
  358.        Catch ex As Exception
  359.            Throw New Exception(ex.Message)
  360.  
  361.        End Try
  362.  
  363.    End Sub
  364.  
  365.    ''' <summary>
  366.    ''' Sets Main Picture Cover.
  367.    ''' </summary>
  368.    Public Shared Sub Set_Main_Cover(ByVal File As String, _
  369.                            ByVal Picture As String)
  370.  
  371.        Try
  372.            [UltraID3].Read(File)
  373.            [UltraID3].ID3v2Tag.Frames.Add( _
  374.                       New ID3v23PictureFrame(New Bitmap(Picture), PictureTypes.CoverFront, String.Empty, TextEncodingTypes.Unicode))
  375.  
  376.            [UltraID3].Write()
  377.  
  378.        Catch ex As Exception
  379.            Throw New Exception(ex.Message)
  380.  
  381.        End Try
  382.  
  383.    End Sub
  384.  
  385.    ''' <summary>
  386.    ''' Adds a Picture Cover.
  387.    ''' </summary>
  388.    Public Shared Sub Add_Cover(ByVal File As String, _
  389.                                ByVal Picture As String)
  390.  
  391.        Try
  392.            [UltraID3].Read(File)
  393.            [UltraID3].ID3v2Tag.Frames.Add( _
  394.                       New ID3v23PictureFrame(New Bitmap(Picture), PictureTypes.Other, String.Empty, TextEncodingTypes.Unicode))
  395.            [UltraID3].Write()
  396.  
  397.        Catch ex As Exception
  398.            Throw New Exception(ex.Message)
  399.  
  400.        End Try
  401.  
  402.    End Sub
  403.  
  404.    ''' <summary>
  405.    ''' Deletes all Picture Covers.
  406.    ''' </summary>
  407.    Public Shared Sub Delete_Covers(ByVal File As String)
  408.  
  409.        Try
  410.            [UltraID3].Read(File)
  411.  
  412.            [UltraID3].ID3v2Tag.Frames.Remove( _
  413.                       [UltraID3].ID3v2Tag.Frames.GetFrames(MultipleInstanceID3v2FrameTypes.ID3v22Picture))
  414.  
  415.            [UltraID3].ID3v2Tag.Frames.Remove( _
  416.                       [UltraID3].ID3v2Tag.Frames.GetFrames(MultipleInstanceID3v2FrameTypes.ID3v23Picture))
  417.  
  418.            [UltraID3].Write()
  419.  
  420.        Catch ex As Exception
  421.            Throw New Exception(ex.Message)
  422.  
  423.        End Try
  424.  
  425.    End Sub
  426.  
  427.    ''' <summary>
  428.    ''' Gets Main Picture Cover.
  429.    ''' </summary>
  430.    Public Shared Function Get_Main_Cover(ByVal File As String) As Bitmap
  431.  
  432.        Try
  433.            [UltraID3].Read(File)
  434.  
  435.            If [UltraID3].ID3v2Tag.Frames.GetFrame(MultipleInstanceID3v2FrameTypes.ID3v23Picture, False) IsNot Nothing Then
  436.                Return DirectCast( _
  437.                       [UltraID3].ID3v2Tag.Frames.GetFrame(MultipleInstanceID3v2FrameTypes.ID3v23Picture, False),  _
  438.                       ID3v2PictureFrame).Picture
  439.            End If
  440.  
  441.            If [UltraID3].ID3v2Tag.Frames.GetFrame(MultipleInstanceID3v2FrameTypes.ID3v22Picture, False) IsNot Nothing Then
  442.                Return DirectCast( _
  443.                       [UltraID3].ID3v2Tag.Frames.GetFrame(MultipleInstanceID3v2FrameTypes.ID3v22Picture, False),  _
  444.                       ID3v2PictureFrame).Picture
  445.            End If
  446.  
  447.            Return Nothing
  448.  
  449.        Catch ex As Exception
  450.            Throw New Exception(ex.Message)
  451.  
  452.        End Try
  453.  
  454.    End Function
  455.  
  456.    ''' <summary>
  457.    ''' Gets the generic ID3 genre names.
  458.    ''' </summary>
  459.    Public Shared Function Get_Generic_ID3_Genres() As String()
  460.        Return UltraID3.GenreInfos.Cast(Of GenreInfo).Select(Function(Genre) Genre.Name).ToArray
  461.    End Function
  462.  
  463.    ''' <summary>
  464.    ''' Gets the Audio Bitrate.
  465.    ''' </summary>
  466.    Public Shared Function Get_Bitrate(ByVal File As String) As Short
  467.  
  468.        Try
  469.            [UltraID3].Read(File)
  470.            Return [UltraID3].FirstMPEGFrameInfo.Bitrate
  471.  
  472.        Catch ex As Exception
  473.            Throw New Exception(ex.Message)
  474.  
  475.        End Try
  476.  
  477.    End Function
  478.  
  479.    ''' <summary>
  480.    ''' Gets the Audio Duration.
  481.    ''' </summary>
  482.    Public Shared Function Get_Duration(ByVal File As String) As String
  483.  
  484.        Try
  485.            [UltraID3].Read(File)
  486.            Return String.Format("{0:00}:{1:00}:{2:00}:{3:000}", _
  487.                                  [UltraID3].FirstMPEGFrameInfo.Duration.Hours, _
  488.                                  [UltraID3].FirstMPEGFrameInfo.Duration.Minutes, _
  489.                                  [UltraID3].FirstMPEGFrameInfo.Duration.Seconds, _
  490.                                  [UltraID3].FirstMPEGFrameInfo.Duration.Milliseconds)
  491.  
  492.        Catch ex As Exception
  493.            Throw New Exception(ex.Message)
  494.  
  495.        End Try
  496.  
  497.    End Function
  498.  
  499.    ''' <summary>
  500.    ''' Gets the Audio Frequency.
  501.    ''' </summary>
  502.    Public Shared Function Get_Frequency(ByVal File As String) As Integer
  503.  
  504.        Try
  505.            [UltraID3].Read(File)
  506.            Return [UltraID3].FirstMPEGFrameInfo.Frequency
  507.  
  508.        Catch ex As Exception
  509.            Throw New Exception(ex.Message)
  510.  
  511.        End Try
  512.  
  513.    End Function
  514.  
  515.    ''' <summary>
  516.    ''' Gets the Audio MPEG Layer.
  517.    ''' </summary>
  518.    Public Shared Function Get_Layer(ByVal File As String) As String
  519.  
  520.        Try
  521.            [UltraID3].Read(File)
  522.            Return [UltraID3].FirstMPEGFrameInfo.Layer.ToString
  523.  
  524.        Catch ex As Exception
  525.            Throw New Exception(ex.Message)
  526.  
  527.        End Try
  528.  
  529.    End Function
  530.  
  531.    ''' <summary>
  532.    ''' Gets the Audio Channel mode.
  533.    ''' </summary>
  534.    Public Shared Function Get_Channels(ByVal File As String) As String
  535.  
  536.        Try
  537.            [UltraID3].Read(File)
  538.            Return [UltraID3].FirstMPEGFrameInfo.Mode.ToString
  539.  
  540.        Catch ex As Exception
  541.            Throw New Exception(ex.Message)
  542.  
  543.        End Try
  544.  
  545.    End Function
  546.  
  547.    ''' <summary>
  548.    ''' Gets the File Size.
  549.    ''' </summary>
  550.    Public Shared Function Get_Filesize(ByVal File As String) As Long
  551.  
  552.        Try
  553.            [UltraID3].Read(File)
  554.            Return [UltraID3].Size
  555.  
  556.        Catch ex As Exception
  557.            Throw New Exception(ex.Message)
  558.  
  559.        End Try
  560.  
  561.    End Function
  562.  
  563.    ''' <summary>
  564.    ''' Checks if VBR header is present in file.
  565.    ''' </summary>
  566.    Public Shared Function IsVBR(ByVal File As String) As Boolean
  567.  
  568.        Try
  569.            [UltraID3].Read(File)
  570.            Return [UltraID3].FirstMPEGFrameInfo.VBRInfo.WasFound
  571.  
  572.        Catch ex As Exception
  573.            Throw New Exception(ex.Message)
  574.  
  575.        End Try
  576.  
  577.    End Function
  578.  
  579. End Class
  580.  
  581. #End Region
8062  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 5 Octubre 2013, 22:23 pm
Un ayudante para manejar la librería TabLig Sharp: https://github.com/mono/taglib-sharp

La librería sirve para editar los metadatos de archivos de música, entre otros formatos como imágenes png, etc...

Mi Class está pensada para usarse con archivos MP3.

Código
  1. #Region " TagLib Sharp Helper "
  2.  
  3.  
  4. ' [ TagLib Sharp Helper ]
  5. '
  6. ' // By Elektro H@cker
  7. '
  8. '
  9. ' Instructions:
  10. ' 1. Add a reference to "taglib-sharp.dll" into the project.
  11. '
  12. '
  13. ' Examples:
  14. '
  15. ' MsgBox(TagLibSharp.FileIsCorrupt("C:\File.mp3")) ' Result: True or False
  16. ' MsgBox(TagLibSharp.FileIsWriteable("C:\File.mp3")) ' Result: True or False
  17. ' MsgBox(TagLibSharp.Get_Title("C:\File.mp3"))
  18. ' MsgBox(TagLibSharp.Get_Artist("C:\File.mp3"))
  19. ' MsgBox(TagLibSharp.Get_Album("C:\File.mp3"))
  20. ' MsgBox(TagLibSharp.Get_Genre("C:\File.mp3"))
  21. ' MsgBox(TagLibSharp.Get_Year("C:\File.mp3"))
  22. ' MsgBox(TagLibSharp.Get_Basic_TagInfo("C:\File.mp3"))
  23. ' TagLibSharp.RemoveTag("C:\File.mp3", TagLib.TagTypes.Id3v1 Or TagLib.TagTypes.Id3v2) ' Removes ID3v1 + ID3v2 Tags
  24. ' TagLibSharp.Set_Tag_Fields("C:\Test.mp3", Sub(x) x.Tag.Title = "Title Test"})
  25. ' TagLibSharp.Set_Tag_Fields("C:\Test.mp3", {Sub(x) x.Tag.Title = "Title Test", Sub(x) x.Tag.Performers = {"Artist Test"}})
  26.  
  27.  
  28. Public Class TagLibSharp
  29.  
  30.    ''' <summary>
  31.    ''' Stores the Taglib object.
  32.    ''' </summary>
  33.    Private Shared TagFile As TagLib.File = Nothing
  34.  
  35.    ''' <summary>
  36.    ''' Checks if file is possibly corrupted.
  37.    ''' </summary>
  38.    Public Shared Function FileIsCorrupt(ByVal File As String) As Boolean
  39.  
  40.        Try
  41.            Return TagLib.File.Create(File).PossiblyCorrupt
  42.  
  43.        Catch ex As Exception
  44.            Throw New Exception(ex.Message)
  45.            Return True
  46.  
  47.        Finally
  48.            If TagFile IsNot Nothing Then TagFile.Dispose()
  49.  
  50.        End Try
  51.  
  52.    End Function
  53.  
  54. ''' <summary>
  55. ''' Checks if file can be written.
  56. ''' </summary>
  57. Public Shared Function FileIsWriteable(ByVal File As String) As Boolean
  58.  
  59.    Try
  60.        Return TagLib.File.Create(File).Writeable
  61.  
  62.    Catch ex As Exception
  63.        Throw New Exception(ex.Message)
  64.        Return True
  65.  
  66.    Finally
  67.        If TagFile IsNot Nothing Then TagFile.Dispose()
  68.  
  69.    End Try
  70.  
  71. End Function
  72.  
  73. ''' <summary>
  74. ''' Get TagTypes of file.
  75. ''' </summary>
  76. Public Shared Function Get_Tags(ByVal File As String) As String
  77.  
  78.    Try
  79.        Return TagLib.File.Create(File).TagTypes.ToString
  80.  
  81.    Catch ex As Exception
  82.        Throw New Exception(ex.Message)
  83.        Return String.Empty
  84.  
  85.    Finally
  86.        If TagFile IsNot Nothing Then TagFile.Dispose()
  87.  
  88.    End Try
  89.  
  90. End Function
  91.  
  92. ''' <summary>
  93. ''' Remove a entire Tag from file.
  94. ''' </summary>
  95. Public Shared Sub RemoveTag(ByVal File As String, ByVal TagTypes As TagLib.TagTypes)
  96.  
  97.    Try
  98.        TagFile = TagLib.File.Create(File)
  99.    Catch ex As Exception
  100.        Throw New Exception(ex.Message)
  101.        Exit Sub
  102.    End Try
  103.  
  104.    Try
  105.  
  106.        If Not TagFile.PossiblyCorrupt _
  107.        AndAlso TagFile.Writeable Then
  108.  
  109.            TagFile.RemoveTags(TagTypes)
  110.            TagFile.Save()
  111.  
  112.        End If
  113.  
  114.    Catch ex As Exception
  115.        Throw New Exception(ex.Message)
  116.  
  117.    Finally
  118.        If TagFile IsNot Nothing Then TagFile.Dispose()
  119.  
  120.    End Try
  121.  
  122. End Sub
  123.  
  124. ''' <summary>
  125. ''' Gets the Title tag field of file.
  126. ''' </summary>
  127. Public Shared Function Get_Title(ByVal File As String) As String
  128.  
  129.    Try
  130.        Return TagLib.File.Create(File).Tag.Title
  131.  
  132.    Catch ex As Exception
  133.        Throw New Exception(ex.Message)
  134.        Return String.Empty
  135.  
  136.    Finally
  137.        If TagFile IsNot Nothing Then TagFile.Dispose()
  138.  
  139.    End Try
  140.  
  141. End Function
  142.  
  143. ''' <summary>
  144. ''' Gets the Artist tag field of file.
  145. ''' </summary>
  146. Public Shared Function Get_Artist(ByVal File As String) As String
  147.  
  148.    Try
  149.        Return TagLib.File.Create(File).Tag.Performers(0)
  150.  
  151.    Catch ex As Exception
  152.        Throw New Exception(ex.Message)
  153.        Return String.Empty
  154.  
  155.    Finally
  156.        If TagFile IsNot Nothing Then TagFile.Dispose()
  157.  
  158.    End Try
  159.  
  160. End Function
  161.  
  162. ''' <summary>
  163. ''' Gets the Album tag field of file.
  164. ''' </summary>
  165. Public Shared Function Get_Album(ByVal File As String) As String
  166.  
  167.    Try
  168.        Return TagLib.File.Create(File).Tag.Album
  169.  
  170.    Catch ex As Exception
  171.        Throw New Exception(ex.Message)
  172.        Return String.Empty
  173.  
  174.    Finally
  175.        If TagFile IsNot Nothing Then TagFile.Dispose()
  176.  
  177.    End Try
  178.  
  179. End Function
  180.  
  181. ''' <summary>
  182. ''' Gets the Genre tag field of file.
  183. ''' </summary>
  184. Public Shared Function Get_Genre(ByVal File As String) As String
  185.  
  186.    Try
  187.        Return TagLib.File.Create(File).Tag.Genres(0)
  188.  
  189.    Catch ex As Exception
  190.        Throw New Exception(ex.Message)
  191.        Return String.Empty
  192.  
  193.    Finally
  194.        If TagFile IsNot Nothing Then TagFile.Dispose()
  195.  
  196.    End Try
  197.  
  198. End Function
  199.  
  200. ''' <summary>
  201. ''' Gets the Year tag field of file.
  202. ''' </summary>
  203. Public Shared Function Get_Year(ByVal File As String) As String
  204.  
  205.    Try
  206.        Return TagLib.File.Create(File).Tag.Year
  207.  
  208.    Catch ex As Exception
  209.        Throw New Exception(ex.Message)
  210.        Return String.Empty
  211.  
  212.    Finally
  213.        If TagFile IsNot Nothing Then TagFile.Dispose()
  214.  
  215.    End Try
  216.  
  217. End Function
  218.  
  219. ''' <summary>
  220. ''' Gets the basic tag fields of file.
  221. ''' </summary>
  222. Public Shared Function Get_Basic_TagInfo(ByVal File As String) As String
  223.  
  224.    Try
  225.        TagFile = TagLib.File.Create(File)
  226.  
  227.        Return String.Format("Title: {1}{0}Artist: {2}{0}Album: {3}{0}Genre: {4}{0}Year: {5}", Environment.NewLine, _
  228.                             TagFile.Tag.Title, _
  229.                             TagFile.Tag.Performers(0), _
  230.                             TagFile.Tag.Album, _
  231.                             TagFile.Tag.Genres(0), _
  232.                             TagFile.Tag.Year)
  233.  
  234.    Catch ex As Exception
  235.        Throw New Exception(ex.Message)
  236.        Return String.Empty
  237.  
  238.    Finally
  239.        If TagFile IsNot Nothing Then TagFile.Dispose()
  240.  
  241.    End Try
  242.  
  243. End Function
  244.  
  245. ''' <summary>
  246. ''' Sets a Tag field.
  247. ''' </summary>
  248. Public Shared Sub Set_Tag_Fields(ByVal File As String, _
  249.                                   ByVal FieldSetter As Action(Of TagLib.File))
  250.  
  251.    Try
  252.        TagFile = TagLib.File.Create(File)
  253.    Catch ex As Exception
  254.        Throw New Exception(ex.Message)
  255.        Exit Sub
  256.    End Try
  257.  
  258.    Try
  259.  
  260.        If Not TagFile.PossiblyCorrupt _
  261.        AndAlso TagFile.Writeable Then
  262.  
  263.            FieldSetter(TagFile)
  264.            TagFile.Save()
  265.  
  266.        End If
  267.  
  268.    Catch ex As Exception
  269.        Throw New Exception(ex.Message)
  270.  
  271.    Finally
  272.        If TagFile IsNot Nothing Then TagFile.Dispose()
  273.  
  274.    End Try
  275.  
  276. End Sub
  277.  
  278. ''' <summary>
  279. ''' Sets multiple Tag fields.
  280. ''' </summary>
  281. Public Shared Sub Set_Tag_Fields(ByVal File As String, _
  282.                                   ByVal FieldSetter() As Action(Of TagLib.File))
  283.  
  284.    Try
  285.        TagFile = TagLib.File.Create(File)
  286.    Catch ex As Exception
  287.        Throw New Exception(ex.Message)
  288.        Exit Sub
  289.    End Try
  290.  
  291.    Try
  292.  
  293.        If Not TagFile.PossiblyCorrupt _
  294.        AndAlso TagFile.Writeable Then
  295.  
  296.            For Each Field In FieldSetter
  297.                Field(TagFile)
  298.            Next
  299.  
  300.            TagFile.Save()
  301.  
  302.        End If
  303.  
  304.    Catch ex As Exception
  305.        Throw New Exception(ex.Message)
  306.  
  307.    Finally
  308.        If TagFile IsNot Nothing Then TagFile.Dispose()
  309.  
  310.    End Try
  311.  
  312. End Sub
  313.  
  314. End Class
  315.  
  316. #End Region
8063  Foros Generales / Sugerencias y dudas sobre el Foro / Re: Problemas de acceso al foro en: 5 Octubre 2013, 19:02 pm
WTF con algunas personas

Además vaya un mentiroso.

@Inzect02
Que tu digas que el ataque duró 10-15 minutos no cambia la realidad, no va a cambiar lo que pone en el registro del Admin, ni tampoco te va a hacer mejor persona,
la mayoría que somos habituales al foro sabemos que tiraste la página durante 1-2 horas completas (sinó más), el tiempo exacto solo lo sabrán los que hayan controlado la duración de la caida completa, y El-Brujo.

En fín, que los que mandan hagan lo que quieran contigo, yo no me meto más para desmentir las palabras de un mentiroso.

Saludos!
8064  Foros Generales / Sugerencias y dudas sobre el Foro / Re: Problemas de acceso al foro en: 5 Octubre 2013, 18:26 pm
Ey yo lo hice para probar un rato el servidor, ya que estoy haciendo una herramienta que en unas semanas lo publicare.

Y lo dice tan pancho!

El fín no justifica los medios, has podido testear con cualquier otro foro.

¿Se supone que el administrador debe ser comprensivo con tus actos?, tu gracia ha afectado a miles de usuarios y segúramente haya afectado económicamente de alguna manera a la página, no tienes ningún perdón por mi parte, desde luego si yo fuera el administrador, si me metiese en la piel de El-Brujo esto no quedaría así, y si, haría lo que me plazca contigo y con los que son igual que tú.

Saludos
8065  Programación / Programación General / Re: ¿La sintaxis de la programacion siempre se usa en Ingles? en: 5 Octubre 2013, 14:55 pm
El mundo de la programación es como el mundo de los militares aeronavales y otros muchos, ya seas de raza china, español, o mongol, un requisito esencial es dominar el Inglés ya que este es el idioma establecido para comunicarte.

Los chinos dejan comentarios en chino dentro de los códigos, para mi no ha sido común ver códigos chinos/japos con comentarios en Inglés (aunque si que los hay), pero obviamente se basan en el Inglés para todo lo demás.

...Y tampoco es tán dificil, no es lo mismo aprender un lenguaje entero, hablar, leer, escribir, entender... que aprender el significado de 200-500 términos.

Saludos!
8066  Programación / Scripting / Re: Crear programa que abra un programa y una pagina web en: 5 Octubre 2013, 13:36 pm
@Darksythe

No, con puro Batch olvídate de hacer cosas complejas :P, a menos que utilices herramientas de terceros como por ejemplo NirCMD.

Con cualquier otro lenguaje (Ej: VBS) podrías hacerlo enviando pulsaciones del teclado al navegador pero es una lata y no sería del todo efectivo,
necesitarías averiguar las combinaciones para cambiar a modo Fullscreen de cada navegador... y averiguar que navegador se inició para enviar la tecla correspondiente a ese navegador,
tu Bat no iniciará un nuevo proceso del navegador predeterminado si este ya se encuentra corriendo, además ten en cuenta que puede haber 1 navegador corriendo o más de 1 en el equipo...
Son muchas variables a tomar en cuenta.

Por ejemplo a firefox puedes enviarle la pulsación de la tecla "F11" y pasa a modo fullscreen, pero si se trata de un laptop se supone que tienes que enviar la combinación "fín + f11"...

(Aunque diréctamente se podría deshabilitar el botón "cerrar" importando y utilizando unas funciones de la API "user32.dll", pero para esto recomiendo otros lenguajes...)

Lo que intentas hacer no me parece ético, pero de todas formas creo que no merece la pena intentarlo por el esfuerzo que requiere y la poca eficacia que tendría en Batch.

Saludos!
8067  Programación / Scripting / Re: Crear programa que abra un programa y una pagina web en: 5 Octubre 2013, 00:37 am
Código
  1.    @ECHO OFF
  2.    START /B "" "%ProgramFiles%\Plantas Contra Zombis\plantsvszombies.exe"
  3.    START /B "" "http://www.google.com/" & Rem Esto iniciará el navegador predeterminado.
  4.    Pause&Exit

Saludos
8068  Foros Generales / Dudas Generales / Re: qué formatos son? en: 4 Octubre 2013, 19:56 pm
Entendí que para que te saliera el correspondiente icono debias tener instalado el correspondiente programa que lo abre.

Es una posible opción pero no es del todo necesario,
si te instalas el programa que lee "X" archivos lo más común es que también le asigne un icono a esos archivos de "X" extensión,
pero no es 100% seguro que el programa vaya a modificar los iconos de los archivos... eso depende de las "caracteristicas" de dicha aplicación.

Lo que intento decirte por ponerte un ejemplo es que yo no uso el Word y le asigné un icono a los archivos doc y docx para diferenciarlos de otro tipo de archivos:



Se puede hacer sin instalar la aplicación que lea archivos "doc".

Saludos
8069  Foros Generales / Dudas Generales / Re: qué formatos son? en: 4 Octubre 2013, 17:17 pm
Si en la imagen sale ".pl" ¿eso significa que tengo instalado un intérprete de perl?

No, significa que es un archivo ".pl", ni más, ni menos...

Como te intenté explicar necesitas instalar Perl si quieres leer archivos ".pl", pero vamos, que el archivo lo puedes abrir con Notepad también.

Saludos
8070  Foros Generales / Dudas Generales / Re: qué formatos son? en: 4 Octubre 2013, 16:14 pm
Hola,

El término correcto a lo que llamas "simbolito" es "Icono", existen miles de extensiones conocidas (.txt, .pdf, etc...) y otras miles no conocidas,
windows asigna un icono específico a las extensiones más conocidas y usadas en el propio SO, el resto no tienen icono a menos que tu le asignes manuálmente el icono o instales un programa para leer dichos archivos para asociarlos a la aplicación y que la aplicación le asigne un icono (esto último depende de como hayan programado la aplicación...)

Por ejemplo el archivo "sgen.pl" de la imagen es un archivo de Perl, para leerlo necesitas instalar el intérprete de Perl, y el instalador le asignará un icono a ese tipo de archivos ".pl"...

El archivo "changelog" y "dicnum13" no tienen extensión pero eso no significa que sean archivos "extraños", son archivos de texto plano, los puedes abrir con notepad.


con frecuencia me encuentro con formatos que no conozco. Salen en blanco

El icono blanco es el icono predeterminado (default file) para archivos desconocidos, no es nada por lo que preocuparse, símplemente ese tipo de archivos no tienen un icono asignado, pero como ya dije tu puedes asignar de forma manual cualquier icono a cualquier tipo de extensión de archivo, desde el registro de Windows, hay muchos tutoriales en Google...


PD: En la imagen tienes las extensiones escondidas para los archivos comunes (txt y exe), sincéramente yo odiaria navegar por mi equipo con las extensiones escondidas, si quieres activarlas puedes hacerlo desde el menú "opciones de carpeta", eso también está en Google...


Saludos!
Páginas: 1 ... 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 [807] 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines