|
|
|
@ -70,4 +70,31 @@ sub load {
|
|
|
|
|
return $self->items; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub dump { |
|
|
|
|
my ($self) = @_; |
|
|
|
|
my $count = 0; |
|
|
|
|
my @lines = ('[playlist]'); |
|
|
|
|
|
|
|
|
|
foreach my $item ($self->items) { |
|
|
|
|
$count += 1; |
|
|
|
|
foreach my $key (qw(file title length)) { |
|
|
|
|
push @lines, sprintf("%s%d=%s", ucfirst($key), $count, $item->{$key}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
splice(@lines, 1, 0, sprintf("numberofentries=%d", $count)); |
|
|
|
|
push @lines, "Version=2", ""; |
|
|
|
|
return join("\n", @lines); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub save { |
|
|
|
|
my ($self, $file) = @_; |
|
|
|
|
|
|
|
|
|
open(my $FH, ">", $file) or die $!; |
|
|
|
|
print $FH $self->dump(); |
|
|
|
|
close($FH); |
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
1; |
|
|
|
|