line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Playlist; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
47
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
370
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub items { |
9
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
10
|
|
|
|
|
|
|
|
11
|
0
|
0
|
|
|
|
0
|
return wantarray ? @{$self->{items}} : $self->{items}; |
|
0
|
|
|
|
|
0
|
|
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
0
|
1
|
0
|
sub parse { die("must be implemented by subclass\n") } |
15
|
0
|
|
|
0
|
1
|
0
|
sub dump { die("must be implemented by subclass\n") } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub load { |
18
|
2
|
|
|
2
|
1
|
796
|
my ($self, $file) = @_; |
19
|
|
|
|
|
|
|
|
20
|
2
|
50
|
|
|
|
50
|
open(my $FH, "<", $file) or return $!; |
21
|
2
|
|
|
|
|
23
|
local $/ = undef; |
22
|
2
|
|
|
|
|
26
|
my $content = <$FH>; |
23
|
2
|
|
|
|
|
9
|
close($FH); |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
|
|
6
|
return $self->parse($content); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub save { |
29
|
0
|
|
|
0
|
1
|
|
my ($self, $file, @items) = @_; |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
open(my $FH, ">", $file) or die $!; |
32
|
0
|
|
|
|
|
|
print $FH $self->dump(@items); |
33
|
0
|
|
|
|
|
|
close($FH); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
return 1; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=pod |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Text::Playlist -- base class for work with various playlist formats |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 DESCRIPTION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This module acts only as base class for specific parsers. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 Methods |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 C |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my @items = $pls->load('playlist.pls'); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Simple helper for loading playlist from file. See also C. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 C |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my @items = $pls->parse($text); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Takes playlist text and returns array of hashrefs with playlist items. In scalar content returns arrayref. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 C |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$pls->save('playlist.pls', @items); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Simple helper for saving playlist to file. See also C. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 C |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $text = $pls->dump(@items); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Takes array of hashrefs with playlist items and returns constructed playlist. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SEE ALSO |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
L, L, L |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 AUTHORS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
* Alex 'AdUser' Z |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |