Skip to content

Instantly share code, notes, and snippets.

@mystasly48
Last active November 19, 2019 15:32
Show Gist options
  • Save mystasly48/07b4b4167cfbb91c97bec846dd2c5c3d to your computer and use it in GitHub Desktop.
Save mystasly48/07b4b4167cfbb91c97bec846dd2c5c3d to your computer and use it in GitHub Desktop.
A script that records "Seven Eleven Presents - Sakura Toshitai Onishi". DO NOT UPLOAD any videos which recorded by this script. ONLY FOR PERSONAL USE.
#!/bin/bash
# toshitai starts at 23:30, and ends at 23:59, so duration is 1740 secs
now_date=`date +%Y%m%d`
start_time=`date --date "$now_date 23 hours 30 minutes" +%s`
#start_time=`date --date "$now_date 16 hours 35 minutes" +%s` # debug
now_time=`date +%s`
duration=1743
echo "Now : " `date +"%Y/%m/%d %H:%M:%S"`
echo "Starts: " `date --date "$now_date 23 hours 30 minutes" +"%Y/%m/%d %H:%M:%S"`
# wait until 2 secs before the start
((waiting = start_time - now_time - 2))
if [ $waiting -gt 0 ] ; then
printf 'Wait recording for '$waiting' secs\n'
sleep $waiting
fi
# The base episode is 189 on 2019/11/12
base_date=20191112
base_episode=189
base_date_s=`date --date "$base_date" +%s`
now_date_s=`date --date "$date" +%s`
((diff = (now_date_s - base_date_s) / 60 / 60 / 24 / 7))
((episode = base_episode + diff))
file="$episode"_"$now_date"
while [[ -e "$file".flv || -e "$file".mp4 ]]
do
echo "Already exists "$file" file! We connect some random characters."
file+="_"
file+=`date +%N`
done
printf 'Recording for '$duration' secs to '$file'.flv and '$file'.mp4\n\n'
rtmpdump -r rtmp://fms-base1.mitene.ad.jp/agqr/aandg1b --stop $duration --live -o $file.flv
ffmpeg -i $file.flv -acodec copy -vcodec copy $file.mp4
printf '\nSaved to '$file'.flv and '$file'.mp4\n'
@mystasly48
Copy link
Author

TODO

  • Check if the recording has succeeded.
  • Adjust duration if the recording started late.
@mystasly48
Copy link
Author

I revised the duration because the end time is 23:59 not 24:00. (ads for 1 min)

@mystasly48
Copy link
Author

TODO

  • Check the rtmp url is correct (not changed, and correctly started recording)
  • Update waiting time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment