Thread MP3-tag überschreiben: Hilfe, überschreiben klappt nicht (14 answers)
Opened by Gast at 2005-08-17 17:50

J-jayz-Z
 2005-08-19 05:05
#57260 #57260
User since
2005-04-13
625 Artikel
BenutzerIn
[Homepage] [default_avatar]
Ich hab mir ein kleines Tk Tool geschrieben zu dem Thema, vielleicht interessiert es ja jemand:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/perl
use strict;
use warnings;

use Tk;
use Tk::FileSelect;
use MP3::ID3v1Tag;

my $file;
my $select;
my %info;
my @info = qw/title artist album year genre genre_num comment/;
my %mp3;


#Frames deklarieren
my %config;
$config{main} = MainWindow->new();
$config{up} = $config{main}->Frame()->pack(-side => 'top');
$config{bottom} = $config{main}->Frame()->pack(-side => 'bottom');
$config{bottom_left} = $config{bottom}->Frame()->pack(-side => 'left');
$config{bottom_right} = $config{bottom}->Frame()->pack(-side => 'right');
$config{middle} = $config{main}->Frame()->pack(-side => 'bottom');
$config{middle_left} = $config{middle}->Frame()->pack(-side => 'left');
$config{middle_right} = $config{middle}->Frame()->pack(-side => 'right');
$config{top} = $config{main}->Frame()->pack(-side => 'top');
$config{top_left} = $config{top}->Frame()->pack(-side => 'left');
$config{top_right} = $config{top}->Frame()->pack(-side => 'right');

#Titel erzeugen
$config{main}->configure(-title => "MP3 Tag Editor");


#Überschrift erzeugen
$config{header} = $config{up}->Label(-text => 'MP3 Tag Editor', -font => '{Arial} 15 {underline}')->pack();

#Buttons erzeugen
$config{button_save} = $config{bottom_left}->Button(-text => 'Save', -command => \&save)->pack(-side => 'left');

$config{button_exit} = $config{bottom_right}->Button(-text => 'Quit', -command => sub { $config{main}->destroy(); })->pack(-side => 'right');

$config{button_clear} = $config{bottom_right}->Button(-text => 'Clear', -command => \&clear)->pack();

#MP3 Selektion
$config{top_left}->Entry(-textvariable => \$file)->pack(-side => 'top');
$config{top_right}->Button(-text => 'MP3', -command => \&mp3_select)->pack(-side => 'top');

#Hauptinhalt erzeugen
foreach (@info) {
$config{middle_left}->Label(-text => "$_")->pack();
$mp3{$_} = $config{middle_right}->Entry(-textvariable => \$info{$_})->pack();
}

MainLoop();


sub mp3_select {
$select = $config{main}->FileSelect(-directory => './');
$file= "";
$file = $select->Show;
unless($file =~ /.*\.mp3/i) {
$file = "";
$config{error} = $config{main}->Toplevel();
$config{error}->Label(-text => 'Kann nur MP3 Dateien öffnen !')->pack();
$config{error}->Button(-text => 'Schließen', -command => sub { $config{error}->destroy(); })->pack(-side => 'bottom');
} else {
&mp3_info();
}
}

sub mp3_info {
my $mp3_file = new MP3::ID3v1Tag($file);
foreach my $info (@info) {
my $tmp = "get_$info";
$info{$info} = $mp3_file->$tmp();
}
}

sub clear {
foreach (@info) {
$mp3{$_}->delete('0.0','end');
}
}

sub save {
my $mp3_file = new MP3::ID3v1Tag($file);
foreach (@info) {
my $tmp = "set_$_";
my $new = $mp3{$_}->get();
$mp3_file->$tmp($new);
my $save_status = $mp3_file->save();
unless($save_status) {
$config{popup} = $config{main}->Toplevel();
$config{popup}->Label(-text => "Fehler beim sichern von $_")->pack();
$config{popup}->Button(-text => 'Schließen', -command => sub { $config{popup}->destroy(); })->pack(-side => 'bottom');
}
}
}
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="5065726c2d436f6d6d756e697479"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'

http://perl-tutor.de

View full thread MP3-tag überschreiben: Hilfe, überschreiben klappt nicht