From: satomichan <...@...> Date: Wed, 18 Mar 2026 06:54:59 +0000 (+0900) Subject: コード整形(余分な空白を除去). X-Git-Url: https://satomichan.jp/gitweb/?a=commitdiff_plain;h=1b0087eb1565f324d536088840a90f48e29bed29;p=rec-radiko.git コード整形(余分な空白を除去). --- diff --git a/get-nhk-title.pl b/get-nhk-title.pl index 656c583..18aab9c 100755 --- a/get-nhk-title.pl +++ b/get-nhk-title.pl @@ -51,7 +51,7 @@ NHKオンライン テキスト版 (https://k.nhk.jp/) で提供されている 複数指定することも出来ます. 例) --li 3,4 Short出力モード のときに --shinyabin を指定すると, - 番組が ラジオ深夜便 だった場合に, 番組タイトルを 「ラジオ深夜便」+ + 番組が ラジオ深夜便 だった場合に, 番組タイトルを 「ラジオ深夜便」+ 2,3行目を組み合わせた文字列にします (1行目のみだと特集内容がわか らないため). @@ -124,7 +124,7 @@ if ($program) { if ($option{short}) { #Short 表示モード print "$program->{minutes} " unless $option{nominutes}; - + my $title = ''; #ラジオ深夜便対策 @@ -132,13 +132,13 @@ if ($program) { $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"; @@ -154,25 +154,25 @@ exit; 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|
${kanji_time}から.+?分(放送時間(\d{1,3})分間)
| 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/
/\n/g; - + my @list = $entry=~ m|
  • (.+?)
  • |sg; return {minutes => $minutes, list => \@list}; - + }else{ die "Not success GET : $url"; } @@ -186,19 +186,19 @@ sub kanji_time { 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); } @@ -207,11 +207,11 @@ sub kanji_time { #エリアコード・チャンネルコード 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', @@ -222,7 +222,7 @@ sub station2area_channel { matsuyama => '800', fukuoka => '501', ); - + die "'$station' : Unknown area." unless $area_code{$base}; @@ -230,10 +230,10 @@ sub station2area_channel { r1 => '05', fm => '07', ); - + die "'$station' : Unknown area." unless $channel_code{$channel}; - - + + return [$area_code{$base}, $channel_code{$channel}]; } @@ -242,7 +242,7 @@ sub station2area_channel { #ファイル名不適記号類を全角文字化 sub escape { my($str) = @_; - + #空白 -> _ にする $str =~ s/\s+/_/g; $str =~ s/ +/_/g; diff --git a/radiru2-dl.pl b/radiru2-dl.pl index 9bee35c..642e9dc 100755 --- a/radiru2-dl.pl +++ b/radiru2-dl.pl @@ -182,7 +182,7 @@ sub sec2duration { sub gen_filename { my($orig_name, $num) = @_; - + return $orig_name if $num == 0; my $base = $orig_name; diff --git a/rec-nhk-radio.pl b/rec-nhk-radio.pl index f4f24a8..63a336b 100755 --- a/rec-nhk-radio.pl +++ b/rec-nhk-radio.pl @@ -6,16 +6,16 @@ # 使い方は引数なしで実行すると表示されます. # # 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. @@ -114,9 +114,9 @@ unless (@ARGV) { <録音長(分)> <タイトル> を省略したときには, get-nhk-title.pl を使用して取得します. <録音開始日> を省略したときには, 現在時刻以降の直近の <録音開始時刻> から録音を開始します. - + EOM_USAGE - + print STDERR $usage; exit; }