| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::NicoVideo::URL; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
22336
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
78
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
65
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
185
|
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.27'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
9
|
use base qw(Exporter); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
229
|
|
|
9
|
2
|
|
|
2
|
|
10
|
use vars qw(@EXPORT); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
104
|
|
|
10
|
|
|
|
|
|
|
@EXPORT = qw(shorten unshorten); |
|
11
|
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
10
|
use Carp qw(croak); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
3707
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub shorten { |
|
15
|
50
|
50
|
|
50
|
0
|
41064
|
my $url = shift or croak 'No URL passed to shorten'; |
|
16
|
50
|
100
|
|
|
|
964
|
if( 0 ){ |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
return; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# douga |
|
21
|
0
|
|
|
|
|
0
|
elsif( $url =~ m{^(https?)://www\.nicovideo\.jp/watch/([-_0-9A-Za-z]+)} ){ |
|
22
|
4
|
|
|
|
|
35
|
return "$1://nico.ms/$2"; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# seiga |
|
26
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://seiga\.nicovideo\.jp/seiga/([-_0-9A-Za-z]+)} ){ |
|
27
|
2
|
|
|
|
|
15
|
return "$1://nico.ms/$2"; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://seiga\.nicovideo\.jp/watch/([-_0-9A-Za-z]+)} ){ |
|
30
|
6
|
|
|
|
|
48
|
return "$1://nico.ms/$2"; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# live |
|
34
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://live\.nicovideo\.jp/watch/([-_0-9A-Za-z]+)} ){ |
|
35
|
4
|
|
|
|
|
10
|
my $sc = $1; |
|
36
|
4
|
|
|
|
|
9
|
my $id = $2; |
|
37
|
4
|
100
|
|
|
|
40
|
if( $id =~ /^lv/ ){ |
|
|
|
50
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
13
|
return "$sc://nico.ms/$id"; |
|
39
|
|
|
|
|
|
|
}elsif( $id =~ /^co/ ){ |
|
40
|
2
|
|
|
|
|
11
|
return "$sc://nico.ms/l/$id"; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# community |
|
45
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://com\.nicovideo\.jp/community/([-_0-9A-Za-z]+)} ){ |
|
46
|
2
|
|
|
|
|
20
|
return "$1://nico.ms/$2"; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# channel |
|
50
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://ch\.nicovideo\.jp/channel/([-_0-9A-Za-z]+)} ){ |
|
51
|
2
|
|
|
|
|
19
|
return "$1://nico.ms/$2"; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://ch\.nicovideo\.jp/article/([-_0-9A-Za-z]+)} ){ |
|
54
|
2
|
|
|
|
|
20
|
return "$1://nico.ms/$2"; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# chokuhan |
|
58
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://chokuhan\.nicovideo\.jp/products/detail/(\d+)} ){ |
|
59
|
2
|
|
|
|
|
13
|
return "$1://nico.ms/nd$2"; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# ichiba |
|
63
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://ichiba\.nicovideo\.jp/item/([-_0-9A-Za-z]+)} ){ |
|
64
|
12
|
|
|
|
|
93
|
return "$1://nico.ms/$2"; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# app |
|
68
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://app\.nicovideo\.jp/app/([-_0-9A-Za-z]+)} ){ |
|
69
|
2
|
|
|
|
|
19
|
return "$1://nico.ms/$2"; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# jikkyou |
|
73
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://jk\.nicovideo\.jp/watch/([-_0-9A-Za-z]+)} ){ |
|
74
|
2
|
|
|
|
|
14
|
return "$1://nico.ms/$2"; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# commons |
|
78
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://www\.niconicommons\.jp/material/([-_0-9A-Za-z]+)} ){ |
|
79
|
2
|
|
|
|
|
18
|
return "$1://nico.ms/$2"; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# news |
|
83
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://news\.nicovideo\.jp/watch/([-_0-9A-Za-z]+)} ){ |
|
84
|
2
|
|
|
|
|
19
|
return "$1://nico.ms/$2"; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# dictionary |
|
88
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://dic\.nicovideo\.jp/id/([-_0-9A-Za-z]+)} ){ |
|
89
|
2
|
|
|
|
|
21
|
return "$1://nico.ms/dic/$2"; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# user |
|
93
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://www\.nicovideo\.jp/user/([-_0-9A-Za-z]+)} ){ |
|
94
|
2
|
|
|
|
|
15
|
return "$1://nico.ms/user/$2"; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# mylist |
|
98
|
|
|
|
|
|
|
elsif( $url =~ m{^(https?)://www\.nicovideo\.jp/mylist/([-_0-9A-Za-z]+)} ){ |
|
99
|
2
|
|
|
|
|
15
|
return "$1://nico.ms/mylist/$2"; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
0
|
return; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub unshorten { |
|
106
|
50
|
50
|
|
50
|
0
|
387
|
my $url = shift or croak 'No URL passed to unshorten'; |
|
107
|
|
|
|
|
|
|
|
|
108
|
50
|
|
|
|
|
73
|
my $schem = undef; |
|
109
|
50
|
|
|
|
|
63
|
my $dir = undef; |
|
110
|
50
|
|
|
|
|
64
|
my $id = undef; |
|
111
|
50
|
|
|
|
|
67
|
my $class = undef; |
|
112
|
50
|
100
|
|
|
|
1526
|
if( $url =~ m{^(https?)://nico\.(?:ms|sc)/(\w+)/([-_0-9A-Za-z]+)} ){ |
|
|
|
50
|
|
|
|
|
|
|
113
|
8
|
|
|
|
|
23
|
$schem = $1; |
|
114
|
8
|
|
|
|
|
17
|
$dir = $2; |
|
115
|
8
|
|
|
|
|
17
|
$id = $3; |
|
116
|
|
|
|
|
|
|
}elsif( $url =~ m{^(https?)://nico\.(?:ms|sc)/((\w{2})[-_0-9A-Za-z]+)} ){ |
|
117
|
42
|
|
|
|
|
107
|
$schem = $1; |
|
118
|
42
|
|
|
|
|
82
|
$id = $2; |
|
119
|
42
|
|
|
|
|
82
|
$class = $3; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
50
|
100
|
66
|
|
|
478
|
if( defined $dir and defined $schem and defined $id ){ |
|
|
|
50
|
66
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
|
124
|
8
|
100
|
|
|
|
40
|
if( 0 ){ |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
return; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# live |
|
129
|
0
|
|
|
|
|
0
|
elsif( $dir eq 'l' ){ |
|
130
|
2
|
|
|
|
|
14
|
return "$schem://live.nicovideo.jp/watch/$id"; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# dictionary |
|
134
|
|
|
|
|
|
|
elsif( $dir eq 'dic' ){ |
|
135
|
2
|
|
|
|
|
15
|
return "$schem://dic.nicovideo.jp/id/$id"; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# user |
|
139
|
|
|
|
|
|
|
elsif( $dir eq 'user' ){ |
|
140
|
2
|
|
|
|
|
13
|
return "$schem://www.nicovideo.jp/user/$id"; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# mylist |
|
144
|
|
|
|
|
|
|
elsif( $dir eq 'mylist' ){ |
|
145
|
2
|
|
|
|
|
14
|
return "$schem://www.nicovideo.jp/mylist/$id"; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
else{ |
|
149
|
0
|
|
|
|
|
0
|
return; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
}elsif( defined $class and defined $schem and defined $id ){ |
|
153
|
|
|
|
|
|
|
|
|
154
|
42
|
100
|
100
|
|
|
859
|
if( 0 ){ |
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
return; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# douga |
|
159
|
0
|
100
|
100
|
|
|
0
|
elsif( $class eq 'sm' or $class eq 'nm' or $class eq 'so' ){ |
|
160
|
4
|
|
|
|
|
26
|
return "$schem://www.nicovideo.jp/watch/$id"; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# seiga |
|
164
|
|
|
|
|
|
|
elsif( $class eq 'im' ){ |
|
165
|
2
|
|
|
|
|
24
|
return "$schem://seiga.nicovideo.jp/seiga/$id?ref=nicoms"; |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
elsif( $class eq 'sg' or $class eq 'mg' ){ |
|
168
|
4
|
|
|
|
|
32
|
return "$schem://seiga.nicovideo.jp/watch/$id?ref=nicoms"; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
elsif( $class eq 'bk' ){ |
|
171
|
2
|
|
|
|
|
14
|
return "$schem://seiga.nicovideo.jp/watch/$id"; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# live |
|
175
|
|
|
|
|
|
|
elsif( $class eq 'lv' ){ |
|
176
|
2
|
|
|
|
|
18
|
return "$schem://live.nicovideo.jp/watch/$id"; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# community |
|
180
|
|
|
|
|
|
|
elsif( $class eq 'co' ){ |
|
181
|
2
|
|
|
|
|
15
|
return "$schem://com.nicovideo.jp/community/$id"; |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# channel |
|
185
|
|
|
|
|
|
|
elsif( $class eq 'ch' ){ |
|
186
|
2
|
|
|
|
|
20
|
return "$schem://ch.nicovideo.jp/channel/$id"; |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
elsif( $class eq 'ar' ){ |
|
189
|
2
|
|
|
|
|
14
|
return "$schem://ch.nicovideo.jp/article/$id"; |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# chokuhan |
|
193
|
|
|
|
|
|
|
elsif( $class eq 'nd' and $id =~ /^nd\d+$/ ){ |
|
194
|
2
|
|
|
|
|
30
|
$id =~ s/^$class//; |
|
195
|
2
|
|
|
|
|
14
|
return "$schem://chokuhan.nicovideo.jp/products/detail/$id"; |
|
196
|
|
|
|
|
|
|
} |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# ichiba |
|
199
|
|
|
|
|
|
|
elsif( $class eq 'az' or $class eq 'ys' or $class eq 'gg' or $class eq 'ga' |
|
200
|
|
|
|
|
|
|
or $class eq 'nd' or $class eq 'dw' or $class eq 'it' or $class eq 'ip' ){ |
|
201
|
12
|
|
|
|
|
81
|
return "$schem://ichiba.nicovideo.jp/item/$id"; |
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# app |
|
205
|
|
|
|
|
|
|
elsif( $class eq 'ap' ){ |
|
206
|
2
|
|
|
|
|
14
|
return "$schem://app.nicovideo.jp/app/$id"; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
# jikkyou |
|
210
|
|
|
|
|
|
|
elsif( $class eq 'jk' ){ |
|
211
|
2
|
|
|
|
|
15
|
return "$schem://jk.nicovideo.jp/watch/$id"; |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# commons |
|
215
|
|
|
|
|
|
|
elsif( $class eq 'nc' ){ |
|
216
|
2
|
|
|
|
|
95
|
return "$schem://www.niconicommons.jp/material/$id"; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
# news |
|
220
|
|
|
|
|
|
|
elsif( $class eq 'nw' ){ |
|
221
|
2
|
|
|
|
|
18
|
return "$schem://news.nicovideo.jp/watch/$id"; |
|
222
|
|
|
|
|
|
|
} |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
else{ |
|
225
|
0
|
|
|
|
|
|
return; |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
|
|
229
|
0
|
|
|
|
|
|
return; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
1; |
|
234
|
|
|
|
|
|
|
__END__ |