Advertisement
KreepyUncle

JB Live Show Recorder, now with 6x more BACON!!!

Aug 12th, 2012
1,168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.88 KB | None | 0 0
  1. #!/bin/bash
  2. ## This is the third, probably final, iteration for the JB Live Stream recorder.
  3. ## 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.
  4. ## 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.
  5. ## If you don't want a particular show recorded just comment out that section.
  6. ## This script has no license and is should be used with care as a single recording can produce a file over 1GB.
  7.  
  8. ## 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.
  9.  
  10. ## Updated 28 May 2014, Changed the variable d in the main while loop to reflect the Pacific timezone, matching the tcalc function.
  11.  
  12. lastrt=0930  ## *trt is the start time of a show. Default is 30 mins prior.
  13. lastop=1145  ## *top is the stop time of a show.
  14. codtrt=1130   ## Coder Radio start time
  15. codtop=1330  ## Coder Radio stop time
  16. liutrt=1330  ## Linux Unplugged start time
  17. liutop=1530  ## Linux Unplugged stop time
  18. scitrt=1900  ## SciByte start time
  19. scitop=2100  ## SciByte stop time
  20. bsdtrt=1030  ## BSDNow start time
  21. bsdtop=1300  ## BSDNow stop time
  22. unftrt=1730  ## UnFilter start time
  23. unftop=2000  ## UnFilter stop time
  24. tsntrt=1230  ## TechSNAP start time
  25. tsntop=1500  ## TechSNAP stop time
  26. nrstrt=1145   ## FauxShow start time
  27. nrstop=1315  ## FauxShow stop time
  28.  
  29. ## This is the main function, the 'meat' of this script.
  30. bacon(){
  31.         echo "Now recording $1$2"
  32.     zm=`expr 60 \* \( \( \( $3 / 100 \) \- \( $4 / 100 \) \) \- 1 \)`
  33.     zn=`expr 60 \+ \( \( $3 % 100 \) \- \( $4 \% 100 \) \)`
  34.     mh=`expr \( $zm \+ $zn \) \/ 60`
  35.     mm=`expr \( $zm \+ $zn \) \% 60`
  36.     `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`
  37.     killall mencoder
  38.     sleep 5
  39. }
  40.  
  41. tcalc(){
  42. s=`TZ=America/Los_Angeles date +%H%M`       ## Grab time variable with no place padding.
  43. t=`expr $s / 1`         ## Expr to drop the 0 off time variable for times less than 1000.
  44. }
  45.  
  46. while true
  47.  
  48. do
  49.  
  50. tcalc   ## Time calculation
  51. mh=0    ## Mencoder hour calc set.
  52. mm=0    ## Mencoder minute calc set.
  53. d=`TZ=America/Los_Angeles date +%w`         ## Date veriable 0=Sunday 3=Wednesday.
  54. ot=`date +%c`           ## Time and date stamp for the script's nothing to record output.
  55.  
  56.         while [ $t -ge $lastrt ] && [ $t -lt $lastop ] && [ $d -eq 0 ]; do
  57.                 clear
  58.         bacon LAS '.' $lastop $t `date +%d%b%Y-%H%M%S`
  59.         tcalc
  60.         clear
  61.         done
  62.  
  63.     while [ $t -ge $nrstrt ] && [ $t -lt $nrstop ] && [ $d -eq 0 ]; do
  64.         clear
  65.         bacon Faux 'Sho.......ITS NOT A REAL SHOW!!!!!' $nrstop $t `date +%d%b%Y-%H%M%S`
  66.         tcalc
  67.         clear
  68.     done
  69.  
  70.     while [ $t -ge $codtrt ] && [ $t -lt $codtop ] && [ $d -eq 1 ]; do
  71.         clear
  72.         bacon Coder 'Radio.' $codtop $t `date +%d%b%Y-%H%M%S`
  73.         tcalc
  74.         clear
  75.     done
  76.  
  77.         while [ $t -ge $liutrt ] && [ $t -lt $liutop ] && [ $d -eq 2 ]; do
  78.         clear
  79.         bacon Linux 'Unplugged.' $liutop $t `date +%d%b%Y-%H%M%S`
  80.         tcalc
  81.         clear
  82.     done
  83.  
  84.         while [ $t -ge $scitrt ] && [ $t -lt $scitop ] && [ $d -eq 2 ]; do
  85.         clear
  86.         bacon SciByte '.' $scitop $t `date +%d%b%Y-%H%M%S`
  87.         tcalc
  88.         clear
  89.     done
  90.  
  91.     while [ $t -ge $bsdtrt ] && [ $t -lt $bsdtop ] && [ $d -eq 3 ]; do
  92.         clear
  93.         bacon BSD 'Now.' $bsdtop $t `date +%d%b%Y-%H%M%S`
  94.         tcalc
  95.         clear
  96.     done
  97.  
  98.     while [ $t -ge $unftrt ] && [ $t -lt $unftop ] && [ $d -eq 3 ]; do
  99.         clear
  100.         bacon UnFilter '.' $unftop $t `date +%d%b%Y-%H%M%S`
  101.         tcalc
  102.         clear
  103.     done
  104.  
  105.     while [ $t -ge $tsntrt ] && [ $t -lt $tsntop ] && [ $d -eq 4 ]; do
  106.         clear
  107.         bacon TechSNAP '.' $tsntop $t `date +%d%b%Y-%H%M%S`
  108.         tcalc
  109.         clear
  110.     done
  111.  
  112.         killall mencoder
  113.         clear
  114.         echo "Nothing to record. $ot"
  115.         sleep 10
  116.  
  117. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement