複数指定することも出来ます. 例) --li 3,4
Short出力モード のときに --shinyabin を指定すると,
- 番組が ラジオ深夜便 だった場合に, 番組タイトルを 「ラジオ深夜便」+
+ 番組が ラジオ深夜便 だった場合に, 番組タイトルを 「ラジオ深夜便」+
2,3行目を組み合わせた文字列にします (1行目のみだと特集内容がわか
らないため).
if ($option{short}) {
#Short 表示モード
print "$program->{minutes} " unless $option{nominutes};
-
+
my $title = '';
#ラジオ深夜便対策
$title = 'ラジオ深夜便';
$option{li} = '2,3';
}
-
+
#タイトル取得・エスケープ
$title .= $program->{list}[$_ -1] for split(/,/, $option{li});
$title = escape($title) if $option{escape};
-
+
print "$title";
-
+
}else{
#Long 表示モード
print $option{nominutes} ? "" : "$program->{minutes}分間\n";
sub get_timetable {
my ($area, $ch, $tt_ymd, $d, $h, $m) = @_;
# └番組表の年月日, └暦日
-
+
my $kanji_time = kanji_time($d, $h, $m);
my $url = "https://k.nhk.jp/timetable/read/c.html?a=$area&c=$ch&d=$tt_ymd&f=top";
my $resp = HTTP::Tiny->new->get($url);
-
+
if ($resp->{success}) {
my $body = Encode::decode('UTF-8', $resp->{content});
-
- my ($minutes, $entry) =
+
+ my ($minutes, $entry) =
$body =~ m|<div><span>${kanji_time}から.+?分(放送時間(\d{1,3})分間)</span><ul>(.+?)</ul></div>|
or die "Cannot get program info starting at the specified date-time. TIME: ${kanji_time} URL: $url";
$entry = HTML::Entities::decode_entities($entry); #HTML文字実体参照(&xxxx;) デコード
$entry =~ s/<br>/\n/g;
-
+
my @list = $entry=~ m|<li>(.+?)</li>|sg;
return {minutes => $minutes, list => \@list};
-
+
}else{
die "Not success GET : $url";
}
my $day = '';
my $ampm;
-
+
if ($h < 5) {
$day = sprintf('%i日', $d);
$ampm = '午前';
-
+
}elsif ($h <= 11) {
$ampm = '午前';
-
+
}else{
$ampm = '午後';
$h -= 12;
}
-
+
return sprintf("%s%s%i時%02i分", $day, $ampm, $h, $m);
}
#エリアコード・チャンネルコード
sub station2area_channel {
my ($station) = @_;
-
+
return ['001','06'] if $station eq 'r2';
-
+
my ($base, $channel) = $station =~ /^(.\w+)-(r1|fm)$/ or die "'$station' : Unknown station.";
-
+
my %area_code = (
sapporo => '700',
sendai => '600',
matsuyama => '800',
fukuoka => '501',
);
-
+
die "'$station' : Unknown area." unless $area_code{$base};
r1 => '05',
fm => '07',
);
-
+
die "'$station' : Unknown area." unless $channel_code{$channel};
-
-
+
+
return [$area_code{$base}, $channel_code{$channel}];
}
#ファイル名不適記号類を全角文字化
sub escape {
my($str) = @_;
-
+
#空白 -> _ にする
$str =~ s/\s+/_/g;
$str =~ s/ +/_/g;
# 使い方は引数なしで実行すると表示されます.
#
# Copyright 2024-2025 FUKUDA Satomi (https://satomichan.jp/)
-#
+#
# Licensed under the Apache License, Version 2.0 (the “License”);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an “AS IS” BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#
+#
# See the License for the specific language governing permissions and
# limitations under the License.
<録音長(分)> <タイトル> を省略したときには, get-nhk-title.pl を使用して取得します.
<録音開始日> を省略したときには, 現在時刻以降の直近の <録音開始時刻> から録音を開始します.
-
+
EOM_USAGE
-
+
print STDERR $usage;
exit;
}