Skip to content

Instantly share code, notes, and snippets.

@matchy256
Last active August 13, 2026 03:50
Show Gist options
  • Select an option

  • Save matchy256/9515cecbea40918add594203dc61406c to your computer and use it in GitHub Desktop.

Select an option

Save matchy256/9515cecbea40918add594203dc61406c to your computer and use it in GitHub Desktop.
簡易らじるらじる(NHK)録音スクリプト (2022/03 以降版)
#!/bin/bash
pid=$$
date=`date '+%Y-%m-%d-%H_%M'`
outdir="."
if [ $# -le 1 ]; then
echo "usage : $0 channel_name duration(minuites) [outputdir] [prefix]"
exit 1
fi
if [ $# -ge 2 ]; then
channel=$1
DURATION=`expr $2 \* 60 + 15`
fi
if [ $# -ge 3 ]; then
outdir=$3
fi
PREFIX=${channel}
if [ $# -ge 4 ]; then
PREFIX=$4
fi
#
# set channel
#
case $channel in
"NHK1")
aspx="https://radio-stream.nhk.jp/hls/live/2023229/nhkradiruakr1/master48k.m3u8"
;;
"NHK2")
aspx="https://radio-stream.nhk.jp/hls/live/2023501/nhkradiruakr2/master48k.m3u8"
;;
"FM")
aspx="https://radio-stream.nhk.jp/hls/live/2023507/nhkradiruakfm/master48k.m3u8"
;;
"NHK1_SAPPORO")
aspx="https://radio-stream.nhk.jp/hls/live/2023545/nhkradiruikr1/master48k.m3u8"
;;
"FM_SAPPORO")
aspx="https://radio-stream.nhk.jp/hls/live/2023546/nhkradiruikfm/master48k.m3u8"
;;
"NHK1_SENDAI")
aspx="https://radio-stream.nhk.jp/hls/live/2023543/nhkradiruhkr1/master48k.m3u8"
;;
"FM_SENDAI")
aspx="https://radio-stream.nhk.jp/hls/live/2023544/nhkradiruhkfm/master48k.m3u8"
;;
"NHK1_NAGOYA")
aspx="https://radio-stream.nhk.jp/hls/live/2023510/nhkradiruckr1/master48k.m3u8"
;;
"FM_NAGOYA")
aspx="https://radio-stream.nhk.jp/hls/live/2023511/nhkradiruckfm/master48k.m3u8"
;;
"NHK1_OSAKA")
aspx="https://radio-stream.nhk.jp/hls/live/2023508/nhkradirubkr1/master48k.m3u8"
;;
"FM_OSAKA")
aspx="https://radio-stream.nhk.jp/hls/live/2023509/nhkradirubkfm/master48k.m3u8"
;;
"NHK1_HIROSHIMA")
aspx="https://radio-stream.nhk.jp/hls/live/2023512/nhkradirufkr1/master48k.m3u8"
;;
"FM_IROSHIMA")
aspx="https://radio-stream.nhk.jp/hls/live/2023513/nhkradirufkfm/master48k.m3u8"
;;
"NHK1_MATSUYAMA")
aspx="https://radio-stream.nhk.jp/hls/live/2023547/nhkradiruzkr1/master48k.m3u8"
;;
"FM_MATSUYAMA")
aspx="https://radio-stream.nhk.jp/hls/live/2023548/nhkradiruzkfm/master48k.m3u8"
;;
"NHK1_FUKUOKA")
aspx="https://radio-stream.nhk.jp/hls/live/2023541/nhkradirulkr1/master48k.m3u8"
;;
"FM_FUKUOKA")
aspx="https://radio-stream.nhk.jp/hls/live/2023542/nhkradirulkfm/master48k.m3u8"
;;
*)
echo "failed channel"
exit 1
;;
esac
# MP3に変換する場合
ffmpeg -loglevel quiet -y -t ${DURATION} -i ${aspx} -acodec libmp3lame -ab 128k "${outdir}/${PREFIX}_${date}.mp3"
#avconv -loglevel quiet -y -t ${DURATION} -i ${aspx} -acodec mp3 -ab 128k "${outdir}/${PREFIX}_${date}.mp3"
# AACでとりだす場合
#ffmpeg -loglevel quiet -y -t ${DURATION} -i ${aspx} -vn -acodec copy -bsf:a aac_adtstoasc "${outdir}/${PREFIX}_${date}.m4a"
@Yasu75

Yasu75 commented Sep 26, 2025

Copy link
Copy Markdown

Raspberry Pi で使わせて頂いています。ありがとうございます。
何故か、今日から、HLS(HTTP Live Streaming)の URL が変更になったのだと思います。変更となった URL が分からず Web 探していると、
https://gist.github.com/zixing8284/4ec2f633be7a4d89ae2ede0638e648c7 が見つかりました。※参考までに下に書かれている NHK xml osaka 分でテストして接続の確認は取れました。

@matchy256

Copy link
Copy Markdown
Author

ありがとうございます。たぶんこれ https://www.nhk.or.jp/radio/config/config_web.xml から取得するようにしないとダメっぽいですね…

@Yasu75

Yasu75 commented Aug 13, 2026

Copy link
Copy Markdown

有効活用させて頂いています。
知らない間に、HLS(HTTP Live Streaming)の URL が変更になっていました。多分 260809 からの変更なのですかね。URL 変更して録音できるのを確認出来ました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment