コード整形(余分な空白を除去).
authorsatomichan <...@...>
Wed, 18 Mar 2026 06:54:59 +0000 (15:54 +0900)
committersatomichan <...@...>
Wed, 18 Mar 2026 11:26:17 +0000 (20:26 +0900)
get-nhk-title.pl
radiru2-dl.pl
rec-nhk-radio.pl

index 656c583164e458afbedb76b986187d26cf7428f5..18aab9c311a660dd59e92d535e15bb7782676e97 100755 (executable)
@@ -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|<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";
     }
@@ -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;
index 9bee35cae08164d836c9dd3d8083d93f38572858..642e9dc8e0d682a9ea639449890517049fc1607c 100755 (executable)
@@ -182,7 +182,7 @@ sub sec2duration {
 
 sub gen_filename {
     my($orig_name, $num) = @_;
-    
+
     return $orig_name if $num == 0;
 
     my $base = $orig_name;
index f4f24a88addc8c8792225bf0d5d7c8bd2381bed7..63a336bff315a444862e738c4ddc58b59c85b408 100755 (executable)
@@ -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;
 }