Skip to content

Instantly share code, notes, and snippets.

@ushitora-anqou
Last active June 28, 2018 14:48
Show Gist options
  • Save ushitora-anqou/edde19c77bf372c0fd021c77083a34eb to your computer and use it in GitHub Desktop.
Save ushitora-anqou/edde19c77bf372c0fd021c77083a34eb to your computer and use it in GitHub Desktop.
radiru.sh - a shellscript to record らじる★らじる(Radiru*Radiru)
#!/bin/sh
# THANKS TO https://gist.github.com/riocampos/93739197ab7c765d16004cd4164dca73
##### LICENSE - CC0 ######
#radiru.sh - a shellscript to record らじる★らじる(Radiru*Radiru)
#Written in 2018 by Ushitora Anqou
#To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
#You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
##########################
# For use you need to install FFmpeg.
print_usage_and_exit() {
printf "Usage: radiru.sh -c {r1,r2,fm} -d duration -o output_path_without_extension\n"
exit 2
}
ffmpeg=ffmpeg
ffmpeg_normal_args='-y -i $url -t $duration -loglevel error'
ffmpeg_args="$ffmpeg_normal_args"' -c copy $output_path'
# uncomment this to output mp3 result file.
#ffmpeg_args="$ffmpeg_normal_args"' -write_xing 0 $output_path'
while getopts c:d:o: opt
do
case $opt in
c)
case $OPTARG in
r1)
url='https://nhkradiobkr1-i.akamaihd.net/hls/live/512291/1-r1/1-r1-01.m3u8'
;;
r2)
url='https://nhkradioakr2-i.akamaihd.net/hls/live/511929/1-r2/1-r2-01.m3u8'
;;
fm)
url='https://nhkradiobkfm-i.akamaihd.net/hls/live/512070/1-fm/1-fm-01.m3u8'
;;
?)
print_usage_and_exit
;;
esac
;;
d)
duration=$OPTARG
;;
o)
output_path=$OPTARG
;;
?)
print_usage_and_exit
;;
esac
done
if [ -z ${url+x} ] || [ -z ${duration+x} ] || [ -z ${output_path+x} ]; then
print_usage_and_exit
fi
eval "$ffmpeg $ffmpeg_args"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment