Advertisement
hackloper775

Infomp3Perl

Jun 16th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 5.32 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #===============================================================================
  3. #
  4. #         archivo:  infomp3.pl
  5. #
  6. #        USAGE:  ./infomp3.pl  MP3
  7. #
  8. #  DESCRIPTION:  Programa para colocar y mostrar informacion de su musica mp3
  9. #
  10. #      OPTIONS:  ---
  11. # REQUIREMENTS:  Gtk3,MP3::Info
  12. #         BUGS:   gobject-introspection >= 1.33.10
  13. #        NOTES:  Error de gobject en mi sistema donde se compilo,compilar en su propio sistema para evitar bugs.
  14. #        CODER:  demianx864 (http://www.itimetux.com)
  15. #    PROGRAMER:  http://search.cpan.org/dist/MP3-Info/Info.pm,http://search.cpan.org/~tsch/Gtk3-0.009/lib/Gtk3.pm
  16. #      COMPANY:  
  17. #      VERSION:  1.0
  18. #      CREATED:  15/06/13 12:02:01
  19. #     REVISION:  ---
  20. #===============================================================================
  21. # For developing #
  22. #use strict;
  23. #use warnings;
  24.  
  25. use utf8;
  26. use MP3::Info;
  27. use feature ':5.14';
  28. use Glib qw/TRUE FALSE/;
  29. use Gtk3 -init;
  30.  
  31. my $title = "Mp3InfoPerl";
  32. my $ventana = Gtk3::Window->new('toplevel');
  33.    $ventana->set_default_size(170, 260);
  34.    $ventana->set_title($title);  
  35.    $ventana->set_border_width(2);
  36.    $ventana->set_resizable(FALSE);
  37.    $ventana->signal_connect(delete_event => \&salir);
  38. my $ajustes = Gtk3::Settings->get_default;
  39.    $ajustes->set( 'gtk-application-prefer-dark-theme', TRUE );
  40.  
  41. my $archivo = "@ARGV";
  42. my $tag = get_mp3tag("$archivo") || die exit;
  43. my $info = get_mp3info("$archivo") || die exit;
  44. my $titulo = Gtk3::Entry->new();
  45. my $artista = Gtk3::Entry->new();
  46. my $album = Gtk3::Entry->new();
  47. my $anio = Gtk3::Entry->new();
  48. my $comentario = Gtk3::Entry->new();
  49. my $genero = Gtk3::Entry->new();
  50.  
  51. my %labels = ( Titulo => Gtk3::Label->new("Titulo : "),
  52.                         Artista => Gtk3::Label->new("Artista : "),
  53.                         Album => Gtk3::Label->new("Album : "),
  54.                         Anio => Gtk3::Label->new("AƱo : "),
  55.                         Comentario => Gtk3::Label->new("Comentario : "),
  56.                         Genero => Gtk3::Label->new("Genero : ")
  57. );
  58. my $separador = Gtk3::Separator->new('vertical');
  59. my $aceptar = Gtk3::Button->new_with_label("Aceptar");
  60. my $binfo = Gtk3::Button->new_with_label("Informacion");
  61. my $cancelar = Gtk3::Button->new_with_label("Cancelar");
  62.    $aceptar->signal_connect ( "clicked" => \&settags);
  63.    $binfo->signal_connect ( "clicked" => \&informacion,0);
  64.    $cancelar->signal_connect ( "clicked" => \&salir);
  65.  
  66. my $vbox = Gtk3::Box->new("vertical", 0);
  67.    $vbox->pack_start($titulo, TRUE,TRUE , 0);
  68.    $vbox->pack_start($artista, TRUE,TRUE , 0);
  69.    $vbox->pack_start($album, TRUE,TRUE , 0);
  70.    $vbox->pack_start($anio, TRUE,TRUE , 0);
  71.    $vbox->pack_start($comentario, TRUE,TRUE , 0);
  72.    $vbox->pack_start($genero, TRUE,TRUE , 0);
  73.  
  74. my $vboxlabels = Gtk3::Box->new("vertical", 0);
  75.    $vboxlabels->pack_start($labels{"Titulo"}, TRUE,TRUE , 0);
  76.    $vboxlabels->pack_start($labels{"Artista"}, TRUE,TRUE , 0);
  77.    $vboxlabels->pack_start($labels{"Album"}, TRUE,TRUE , 0);
  78.    $vboxlabels->pack_start($labels{"Anio"}, TRUE,TRUE , 0);
  79.    $vboxlabels->pack_start($labels{"Comentario"}, TRUE,TRUE , 0);
  80.    $vboxlabels->pack_start($labels{"Genero"}, TRUE,TRUE , 0);
  81.  
  82. my $hbox = Gtk3::Box->new("horizontal", 0);
  83.    $hbox->pack_start($vboxlabels, TRUE,TRUE , 0);
  84.    $hbox->pack_start($separador, TRUE,TRUE , 0);
  85.    $hbox->pack_start($vbox, TRUE,TRUE , 0);
  86.  
  87. my $hboxbtons = Gtk3::Box->new("horizontal", 0);
  88.    $hboxbtons->pack_start($aceptar, FALSE,FALSE , 0);
  89.    $hboxbtons->pack_start($binfo, FALSE,FALSE , 0);
  90.    $hboxbtons->pack_start($cancelar, FALSE,FALSE , 0);
  91.  
  92. my $vboxall = Gtk3::Box->new("vertical", 0);
  93.    $vboxall->pack_start($hbox, TRUE,TRUE , 0);
  94.    $vboxall->pack_start($hboxbtons, FALSE,FALSE , 0);
  95.  
  96. $ventana->add($vboxall);
  97.  
  98. tags();
  99.  
  100. $ventana->show_all();
  101.  
  102. Gtk3->main();  
  103.  
  104. sub salir { Gtk3->main_quit; }
  105.  
  106. sub tags
  107. {
  108.     $titulo->set_text($tag->{TITLE});
  109.     $artista->set_text($tag->{ARTIST});
  110.     $album->set_text($tag->{ALBUM});
  111.     $anio->set_text($tag->{YEAR});
  112.     $comentario->set_text($tag->{COMMENT});
  113.     $genero->set_text($tag->{GENRE});
  114. }
  115.  
  116. sub informacion
  117. {
  118.     my $stereo = "No";
  119.     my $copyrigth = " ";
  120.     if ($info->{STEREO})
  121.     {
  122.         $stereo = "Si";
  123.     }
  124.     if ($info->{COPYRIGHT})
  125.     {
  126.         $copyrigth = "Si";
  127.     }
  128. my $texto =<<EOF;
  129.  
  130. Nonmbre(Archivo) : $archivo
  131.  
  132. Version : $info->{VERSION}
  133.  
  134. MPEG Layer : $info->{LAYER}
  135.  
  136. Stereo : $stereo
  137.  
  138. Frequency : $info->{FREQUENCY}
  139.  
  140. Size (bytes) : $info->{SIZE}
  141.  
  142. Time : $info->{TIME}
  143.  
  144. COPYRIGHT : $copyrigth
  145.  
  146. EOF
  147.     my $dialog = Gtk3::MessageDialog->new(
  148.         $ventana,'destroy-with-parent', 'info', 'close', $texto);
  149.         $dialog->signal_connect( response => sub { $dialog->destroy } );
  150.         $dialog->show();
  151. }
  152.  
  153. sub settags
  154. {
  155.     $tag->{TITLE} = $titulo->get_text;
  156.     $tag->{ARTIST} = $artista->get_text;
  157.     $tag->{ALBUM} = $album->get_text;
  158.     $tag->{YEAR} = $anio->get_text;
  159.     $tag->{COMMENT} = $comentario->get_text;
  160.     $tag->{GENRE} = $genero->get_text;
  161.     set_mp3tag($archivo,$tag);
  162.     salir();
  163. }
  164.  
  165. =head LICENSE
  166.  
  167. This library is free software; you can redistribute it and/or modify it under
  168. the terms of the GNU Library General Public License as published by the Free
  169. Software Foundation; either version 2.1 of the License, or (at your option) any
  170. later version.
  171.  
  172. =cut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement