line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Shoutcast::Admin::Song; |
2
|
|
|
|
|
|
|
# $Id: Song.pm 315 2008-03-19 00:07:39Z davidp $ |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
23
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
64
|
|
5
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
54
|
|
6
|
2
|
|
|
2
|
|
9
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
125
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
8
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
659
|
|
9
|
|
|
|
|
|
|
$VERSION = '0.02'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Net::Shoutcast::Admin::Song - object to represent a song |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
An object representing a song (either the current song, or an entry in the |
20
|
|
|
|
|
|
|
song history). Barely justifies being an object rather than a hashref |
21
|
|
|
|
|
|
|
at the moment, but at some point I may be able to add other useful methods, |
22
|
|
|
|
|
|
|
perhaps $song->lyrics to attempt to fetch lyrics. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use Net::Shoutcast::Admin; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $shoutcast = Net::Shoutcast::Admin->new( |
30
|
|
|
|
|
|
|
host => 'server hostname', |
31
|
|
|
|
|
|
|
port => 8000, |
32
|
|
|
|
|
|
|
admin_password => 'mypassword', |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
if ($shoutcast->source_connected) { |
36
|
|
|
|
|
|
|
my $song = $shoutcast->current_song; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
print "Current song is: " . $song->title; |
39
|
|
|
|
|
|
|
} else { |
40
|
|
|
|
|
|
|
print "No source is currently connected."; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Object representing a song, returned by Net::Shoutcast::Admin |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 INTERFACE |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=over 4 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item new |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
There's no reason to create instances of Net::Shoutcast::Admin::Song directly; |
56
|
|
|
|
|
|
|
Net::Shoutcast::Admin creates and returns instances for you. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Having said that: |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$song = Net::Shoutcast::Admin::Song->new( %params ); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Creates a new Net::Shoutcast::Admin object. Takes a hash of options |
63
|
|
|
|
|
|
|
as follows: |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=over 4 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item I |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
The title of the song |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item I |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
The timestamp this song started playing. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub new { |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
0
|
1
|
|
my ($class, %params) = @_; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$self->{last_update} = 0; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my %acceptable_params = map { $_ => 1 } |
|
0
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
qw(title played_at); |
89
|
0
|
|
|
|
|
|
my %required_params = map { $_ => 1 } |
|
0
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
qw(title); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# make sure we haven't been given any bogus parameters: |
94
|
0
|
0
|
|
|
|
|
if (my @bad_params = grep { ! $acceptable_params{$_} } keys %params) { |
|
0
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
carp "Net::Shoutcast::Admin::Song does not recognise param(s) " |
96
|
|
|
|
|
|
|
. join ',', @bad_params; |
97
|
0
|
|
|
|
|
|
return; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$self->{$_} = $params{$_} for keys %acceptable_params; |
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
if (my @missing_params = grep { ! $self->{$_} } keys %required_params) { |
|
0
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
carp "Net::Shoutcast::Admin->new() must be supplied with params: " |
104
|
|
|
|
|
|
|
. join ',', @missing_params; |
105
|
0
|
|
|
|
|
|
return; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
return $self; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item title |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Returns the artist |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub title { |
120
|
0
|
|
|
0
|
1
|
|
return shift->{title}; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub played_at { |
124
|
0
|
|
|
0
|
1
|
|
return shift->{played_at}; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
130
|
|
|
|
|
|
|
__END__ |