+sub add_tags
+{
+ my($self, @tags)=@_;
+ my $existing=$self->tags();
+ my @existing=split(/\s*,\s*/, $existing) if($existing);
+ my @merged=$self->uniq(@tags, @existing);
+ my $genre=join(', ', @merged);
+ return($self->set("genre", $genre));
+}
+
+
+sub write
+{
+ my $self=shift;
+ $self->{mp3}->update_tags();
+}
+
+sub delete_artist { shift->delete("artist"); }
+sub delete_album { shift->delete("album"); }
+sub delete_track { shift->delete("song"); }
+sub delete_tracknum { shift->delete("track"); }
+sub delete_year { shift->delete("year"); }
+sub delete_v1genre { shift->delete("v1genre"); }
+sub delete_comment { shift->delete("comment"); }
+sub delete_genre { shift->delete("genre"); }
+
+sub delete_tags
+{
+ my($self, @tags)=@_;
+ my $current=$self->tags();
+ my @current=split(/\s*,\s*/, $current);
+ my %hash=();
+ @hash{@current}=();
+ for my $tag (@tags)
+ {
+ delete($hash{$tag}) if(exists($hash{$tag}));
+ }
+ my @tagsout=sort keys(%hash);
+ my $genre=join(', ', @tagsout);
+ if(length($genre))
+ {
+ return($self->set("genre", $genre));
+ }
+ else
+ {
+ return($self->delete_genre());
+ }
+}
+
+sub delete_all
+{
+ my($self)=@_;
+ if(exists($self->{mp3}->{ID3v1}))
+ {
+ $self->{mp3}->{ID3v1}->remove_tag;
+ }
+ if(exists($self->{mp3}->{ID3v2}))
+ {
+ $self->{mp3}->{ID3v2}->remove_tag;
+ }
+}
+
+sub delete
+{
+ my($self, $thing)=@_;
+
+ if(exists($self->{mp3}->{ID3v1}) && $thing ne "genre")
+ {
+ my $action=$thing;
+ $action="genre" if($action eq "v1genre");
+ if($action eq "track")
+ {
+ $self->{mp3}->{ID3v1}->track("00");
+ }
+ else
+ {
+ $self->{mp3}->{ID3v1}->$action(" ");
+ }
+ }
+
+ if(exists($self->{mp3}->{ID3v2}))
+ {
+ print "2: remove: $thing\n";
+ if($thing eq "artist")
+ {
+ $self->{mp3}->{ID3v2}->remove_frame("TPE1");
+ $self->{mp3}->{ID3v2}->remove_frame("TPE2");
+ }
+ elsif($thing eq "album")
+ {
+ $self->{mp3}->{ID3v2}->remove_frame("TALB");
+ }
+ elsif($thing eq "song")
+ {
+ $self->{mp3}->{ID3v2}->remove_frame("TIT2");
+ }
+ elsif($thing eq "track")
+ {
+ $self->{mp3}->{ID3v2}->remove_frame("TRCK");
+ }
+ elsif($thing eq "year")
+ {
+ $self->{mp3}->{ID3v2}->remove_frame("TYER");
+ $self->{mp3}->{ID3v2}->remove_frame("TDRC");
+ }
+ elsif($thing eq "comment")
+ {
+ $self->{mp3}->{ID3v2}->remove_frame("COMM");
+ }
+ elsif($thing eq "genre")
+ {
+ $self->{mp3}->{ID3v2}->remove_frame("TCON");
+ }
+ }
+}