line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::NHKProgram::API::Service; |
2
|
2
|
|
|
2
|
|
15434
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
41
|
|
4
|
2
|
|
|
2
|
|
1177
|
use utf8; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
9
|
|
5
|
2
|
|
|
2
|
|
48
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
153
|
|
6
|
2
|
|
|
2
|
|
10
|
use Encode qw/encode_utf8 decode_utf8/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
85
|
|
7
|
2
|
|
|
2
|
|
824
|
use parent qw/Exporter/; |
|
2
|
|
|
|
|
285
|
|
|
2
|
|
|
|
|
23
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw/fetch_service_id/; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
|
|
618
|
use constant SERVICES => { |
11
|
|
|
|
|
|
|
g1 => 'NHK総合1', |
12
|
|
|
|
|
|
|
g2 => 'NHK総合2', |
13
|
|
|
|
|
|
|
e1 => 'NHKEテレ1', |
14
|
|
|
|
|
|
|
e2 => 'NHKEテレ2', |
15
|
|
|
|
|
|
|
e3 => 'NHKEテレ3', |
16
|
|
|
|
|
|
|
e4 => 'NHKワンセグ2', |
17
|
|
|
|
|
|
|
s1 => 'NHKBS1', |
18
|
|
|
|
|
|
|
s2 => 'NHKBS1(102ch)', |
19
|
|
|
|
|
|
|
s3 => 'NHKBSプレミアム', |
20
|
|
|
|
|
|
|
s4 => 'NHKBSプレミアム(104ch)', |
21
|
|
|
|
|
|
|
r1 => 'NHKラジオ第1', |
22
|
|
|
|
|
|
|
r2 => 'NHKラジオ第2', |
23
|
|
|
|
|
|
|
r3 => 'NHKFM', |
24
|
|
|
|
|
|
|
n1 => 'NHKネットラジオ第1', |
25
|
|
|
|
|
|
|
n2 => 'NHKネットラジオ第2', |
26
|
|
|
|
|
|
|
n3 => 'NHKネットラジオFM', |
27
|
|
|
|
|
|
|
tv => 'テレビ全て', |
28
|
|
|
|
|
|
|
radio => 'ラジオ全て', |
29
|
|
|
|
|
|
|
netradio => 'ネットラジオ全て', |
30
|
2
|
|
|
2
|
|
345
|
}; |
|
2
|
|
|
|
|
3
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub fetch_service_id { |
33
|
6
|
|
|
6
|
0
|
1943
|
my $arg = shift; |
34
|
|
|
|
|
|
|
|
35
|
6
|
100
|
|
|
|
42
|
if ($arg =~ /\A([a-zA-Z0-9]+)\Z/) { |
36
|
3
|
100
|
|
|
|
191
|
croak "No such service code: $1" unless SERVICES->{$1}; |
37
|
2
|
|
|
|
|
10
|
return $1; |
38
|
|
|
|
|
|
|
} |
39
|
3
|
|
|
|
|
7
|
return _retrieve_id_by_name($arg); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _retrieve_id_by_name { |
43
|
3
|
|
|
3
|
|
6
|
my $name = shift; |
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
3
|
eval { $name = decode_utf8($name) }; |
|
3
|
|
|
|
|
10
|
|
46
|
3
|
|
|
|
|
53
|
for my $key (keys %{+SERVICES}) { |
|
3
|
|
|
|
|
17
|
|
47
|
33
|
100
|
|
|
|
77
|
return $key if SERVICES->{$key} eq $name; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
11
|
croak encode_utf8("No such service: $name"); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|