Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ## This is the third, probably final, iteration for the JB Live Stream recorder.
- ## It is going to us the UTC time stamp so you don't have to use more than one loop, for now, to record a single show.
- ## You will need to make sure that you have a Videos folder in your home folder, or edit the script to write the files to where you want.
- ## If you don't want a particular show recorded just comment out that section.
- ## This script has no license and is should be used with care as a single recording can produce a file over 1GB.
- ## If the day of the show changes change the "$d -eq X" of the while statement in the script. Sunday=0 Monday=1,,,,Saturday =6.
- ## Updated 28 May 2014, Changed the variable d in the main while loop to reflect the Pacific timezone, matching the tcalc function.
- lastrt=0930 ## *trt is the start time of a show. Default is 30 mins prior.
- lastop=1145 ## *top is the stop time of a show.
- codtrt=1130 ## Coder Radio start time
- codtop=1330 ## Coder Radio stop time
- liutrt=1330 ## Linux Unplugged start time
- liutop=1530 ## Linux Unplugged stop time
- scitrt=1900 ## SciByte start time
- scitop=2100 ## SciByte stop time
- bsdtrt=1030 ## BSDNow start time
- bsdtop=1300 ## BSDNow stop time
- unftrt=1730 ## UnFilter start time
- unftop=2000 ## UnFilter stop time
- tsntrt=1230 ## TechSNAP start time
- tsntop=1500 ## TechSNAP stop time
- nrstrt=1145 ## FauxShow start time
- nrstop=1315 ## FauxShow stop time
- ## This is the main function, the 'meat' of this script.
- bacon(){
- echo "Now recording $1$2"
- zm=`expr 60 \* \( \( \( $3 / 100 \) \- \( $4 / 100 \) \) \- 1 \)`
- zn=`expr 60 \+ \( \( $3 % 100 \) \- \( $4 \% 100 \) \)`
- mh=`expr \( $zm \+ $zn \) \/ 60`
- mm=`expr \( $zm \+ $zn \) \% 60`
- `mencoder -really-quiet http://videocdn-us.geocdn.scaleengine.net/jblive-iphone/live/jblive.stream/playlist.m3u8 -oac mp3lame -ovc lavc -lavcopts vcodec=msmpeg4 -ofps 30 -endpos 0$mh:$mm:00 -o ~/Videos/$1\-$5.mp4`
- killall mencoder
- sleep 5
- }
- tcalc(){
- s=`TZ=America/Los_Angeles date +%H%M` ## Grab time variable with no place padding.
- t=`expr $s / 1` ## Expr to drop the 0 off time variable for times less than 1000.
- }
- while true
- do
- tcalc ## Time calculation
- mh=0 ## Mencoder hour calc set.
- mm=0 ## Mencoder minute calc set.
- d=`TZ=America/Los_Angeles date +%w` ## Date veriable 0=Sunday 3=Wednesday.
- ot=`date +%c` ## Time and date stamp for the script's nothing to record output.
- while [ $t -ge $lastrt ] && [ $t -lt $lastop ] && [ $d -eq 0 ]; do
- clear
- bacon LAS '.' $lastop $t `date +%d%b%Y-%H%M%S`
- tcalc
- clear
- done
- while [ $t -ge $nrstrt ] && [ $t -lt $nrstop ] && [ $d -eq 0 ]; do
- clear
- bacon Faux 'Sho.......ITS NOT A REAL SHOW!!!!!' $nrstop $t `date +%d%b%Y-%H%M%S`
- tcalc
- clear
- done
- while [ $t -ge $codtrt ] && [ $t -lt $codtop ] && [ $d -eq 1 ]; do
- clear
- bacon Coder 'Radio.' $codtop $t `date +%d%b%Y-%H%M%S`
- tcalc
- clear
- done
- while [ $t -ge $liutrt ] && [ $t -lt $liutop ] && [ $d -eq 2 ]; do
- clear
- bacon Linux 'Unplugged.' $liutop $t `date +%d%b%Y-%H%M%S`
- tcalc
- clear
- done
- while [ $t -ge $scitrt ] && [ $t -lt $scitop ] && [ $d -eq 2 ]; do
- clear
- bacon SciByte '.' $scitop $t `date +%d%b%Y-%H%M%S`
- tcalc
- clear
- done
- while [ $t -ge $bsdtrt ] && [ $t -lt $bsdtop ] && [ $d -eq 3 ]; do
- clear
- bacon BSD 'Now.' $bsdtop $t `date +%d%b%Y-%H%M%S`
- tcalc
- clear
- done
- while [ $t -ge $unftrt ] && [ $t -lt $unftop ] && [ $d -eq 3 ]; do
- clear
- bacon UnFilter '.' $unftop $t `date +%d%b%Y-%H%M%S`
- tcalc
- clear
- done
- while [ $t -ge $tsntrt ] && [ $t -lt $tsntop ] && [ $d -eq 4 ]; do
- clear
- bacon TechSNAP '.' $tsntop $t `date +%d%b%Y-%H%M%S`
- tcalc
- clear
- done
- killall mencoder
- clear
- echo "Nothing to record. $ot"
- sleep 10
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement