| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Music::KNRadio::NowPlaying; |
|
2
|
1
|
|
|
1
|
|
66539
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
29
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
27
|
|
|
4
|
1
|
|
|
1
|
|
529
|
use open qw(:utf8 :std); |
|
|
1
|
|
|
|
|
1178
|
|
|
|
1
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
BEGIN { |
|
7
|
1
|
|
|
1
|
|
141
|
use Exporter; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
43
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
95
|
|
|
9
|
1
|
|
|
1
|
|
18
|
@ISA = qw(Exporter); |
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
|
|
4
|
$VERSION = '0.012'; |
|
12
|
1
|
|
|
|
|
23
|
@EXPORT_OK = qw(knnp); |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
449
|
use LWP::Simple; |
|
|
1
|
|
|
|
|
67240
|
|
|
|
1
|
|
|
|
|
9
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $url = 'http://www.knradio.se/latlist/exfile.php'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub knnp { |
|
22
|
0
|
|
|
0
|
1
|
|
my @content = split(/\n/, get($url)); |
|
23
|
0
|
|
|
|
|
|
my %now_playing = ( |
|
24
|
|
|
|
|
|
|
artist => 'undef', |
|
25
|
|
|
|
|
|
|
title => 'undef', |
|
26
|
|
|
|
|
|
|
state => 'undef', |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
for my $line(reverse(@content)) { |
|
30
|
0
|
0
|
|
|
|
|
if($line =~ m/Spelas just nu:(.+)/) { |
|
31
|
0
|
0
|
|
|
|
|
unless($1) { |
|
32
|
0
|
|
|
|
|
|
$now_playing{state} = 'paused'; |
|
33
|
0
|
|
|
|
|
|
last; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
0
|
|
|
|
|
|
($now_playing{artist}, $now_playing{title}) = $1 =~ m/(.+) - (.+)/; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
last unless defined $now_playing{artist}; |
|
38
|
0
|
|
|
|
|
|
$now_playing{artist} =~ s/[^[:ascii:]]//g; |
|
39
|
0
|
|
|
|
|
|
$now_playing{title} =~ s/[^[:ascii:]]//g; |
|
40
|
0
|
|
|
|
|
|
$now_playing{title} =~ s/\r//g; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$now_playing{state} = 'playing'; |
|
43
|
0
|
|
|
|
|
|
last; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
else { |
|
46
|
0
|
|
|
|
|
|
$now_playing{state} = 'paused'; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
0
|
|
|
|
|
|
return \%now_playing; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |