Skip to content

Instantly share code, notes, and snippets.

@matchy256
Last active April 30, 2023 09:10
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save matchy256/9515cecbea40918add594203dc61406c to your computer and use it in GitHub Desktop.
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"
@hisshihit
Copy link

ありがとうございます。
参考にさせていただき、日々利用しております。

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