ラジオ深夜便の番組表形式変更に対処. ファイル名が長くなりすぎないよう, タイトル最大長を160bytesに制限. master
authorsatomichan <git-kitte.20250824@...>
Tue, 3 Feb 2026 15:00:54 +0000 (00:00 +0900)
committersatomichan <git-kitte.20250824@...>
Tue, 3 Feb 2026 15:00:54 +0000 (00:00 +0900)
get-nhk-title.pl
rec-nhk-radio.pl

index 578cf2f7d841dda746c693975e8cda763fd85cad..656c583164e458afbedb76b986187d26cf7428f5 100755 (executable)
@@ -51,8 +51,9 @@ NHKオンライン テキスト版 (https://k.nhk.jp/) で提供されている
   複数指定することも出来ます.  例)  --li 3,4
 
   Short出力モード のときに --shinyabin を指定すると,
-  番組が ラジオ深夜便 だった場合に 番組タイトルを 3,4行目などを組み
-  合わせたものを出力します (1行目のみだと特集内容がわからないため).
+  番組が ラジオ深夜便 だった場合に, 番組タイトルを 「ラジオ深夜便」+ 
+  2,3行目を組み合わせた文字列にします (1行目のみだと特集内容がわか
+  らないため).
 
 
   --nominutes または -m を指定されていると, 放送長さ を出力しません.
@@ -129,7 +130,7 @@ if ($program) {
         #ラジオ深夜便対策
         if ($option{shinyabin} && $program->{list}[0] =~ /^ラジオ深夜便/) {
             $title = 'ラジオ深夜便';
-            $option{li} = '3,4';
+            $option{li} = '2,3';
         }
         
         #タイトル取得・エスケープ
index 53fd5ebf55818777471cedc7344be7cd3067b227..f4f24a88addc8c8792225bf0d5d7c8bd2381bed7 100755 (executable)
@@ -32,7 +32,8 @@ use Getopt::Long qw(:config posix_default no_ignore_case gnu_compat);
 use Time::Piece;
 use Encode;
 
-my $FILE_PERMISSION = 644;
+my $FILE_PERMISSION  = 644;
+my $MAX_TITLE_LENGTH = 160;
 
 
 
@@ -151,7 +152,8 @@ $title =~ s/\s+/_/g;
 die "無効な引数です." unless ($y && $m && $d && $time_h <= 24 && $time_h >= 0 &&
                               $time_m <= 59  && $time_m >= 0  && $min > 0     && length $title);
 
-my $file_name_base = sprintf('%04d-%02d-%02d_%02d%02d_nhk-%s_%s_%dmin', $y, $m, $d, $time_h, $time_m, $station, $title, $min);
+my $file_name_base = sprintf('%04d-%02d-%02d_%02d%02d_nhk-%s_%s_%dmin', $y, $m, $d, $time_h, $time_m, $station,
+                                                                        substr($title, 0, $MAX_TITLE_LENGTH) , $min);
 my $mp3 = "${file_name_base}.mp3";
 my $txt = "${file_name_base}.txt";