line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Music::KNRadio::NowPlaying; |
2
|
1
|
|
|
1
|
|
72376
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
614
|
use open qw(:utf8 :std); |
|
1
|
|
|
|
|
1242
|
|
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
BEGIN { |
7
|
1
|
|
|
1
|
|
132
|
use Exporter; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
8
|
1
|
|
|
1
|
|
7
|
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
107
|
|
9
|
1
|
|
|
1
|
|
21
|
@ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
|
|
5
|
$VERSION = '0.010'; |
12
|
1
|
|
|
|
|
23
|
@EXPORT_OK = qw(knnp); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
511
|
use LWP::Simple; |
|
1
|
|
|
|
|
71380
|
|
|
1
|
|
|
|
|
10
|
|
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__ |