Advertisement
Guest User

fetchtv.sh

a guest
Nov 5th, 2010
560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 18.67 KB | None | 0 0
  1. #!/bin/bash
  2. # fetchtv.sh 4 nov 2010
  3. #  Adapted,from
  4. # fetchiview v1.0 by [email protected]
  5. # 10th February 2010.
  6. # Adapted, with thanks, from iView Downloader v6.2
  7. #   (from http://whirlpool.net.au/wiki/?tag=ABC_iView_Downloader)
  8. #
  9.  
  10. # Destination directory to where iView Flash Video files will be downloaded
  11. DESTDIR="."
  12.  
  13. # Set the pathnames to your binaries based on your operating system
  14. case `uname` in
  15.     Darwin) RTMP="./rtmpdump-2.1c-osx"  # for Mac-OSX
  16.         FFMPEG="./ffmpeg-osx"
  17.         ;;
  18.     Linux)  RTMP="./rtmpdump-2.1c-linux"    # for traditional Linux/Unix
  19.         FFMPEG="./ffmpeg-linux"
  20.         ;;
  21.     CYGWIN*)    RTMP="rtmpdump.exe" # for cygwin
  22.         FFMPEG="ffmpeg"
  23.         ;;
  24.     CYGWIN_NT-6.1)  RTMP="rtmpdump.exe" # for cygwin
  25.         FFMPEG="ffmpeg"
  26.         ;;
  27.     *)      echo "$0: cannot determine your architecture" `uname` ; exit 1 ;;
  28. esac
  29.  
  30. # How lengthy output will be displayed (typically using 'less' or 'more')
  31. VIEWER="less -e "
  32.  
  33. # which editor
  34. EDITOR=vi
  35.  
  36. # Seconds to wait between retrys (uses the sleep command)
  37. SLEEPTIME=5
  38.  
  39. # ---------------------------------------------------------------------
  40. # Please don't edit below here unless you know what you are doing
  41.  
  42. WORKDIR="work"
  43.  
  44. mkdir -p  $WORKDIR  || (echo Cannot create working directory ; exit 1)
  45. chmod 700 $WORKDIR
  46.  
  47. SHOWLIST_TXT="$WORKDIR/showlisttv.txt"
  48. WANTED_TXT="$WORKDIR/wantedtv.txt"
  49. EXTRAS_TXT="$WORKDIR/tvextra.txt"
  50. touch $SHOWLIST_TXT $WANTED_TXT $EXTRAS_TXT
  51.  
  52. # Logfiles (capturing verbose debugging)
  53. RTMP_LOG="$WORKDIR/dumptvv.log"
  54. FFMPEG_LOG="$WORKDIR/ffmpegtv.log"
  55. rm -f $RTMP_LOG $FFMPEG_LOG
  56. #
  57. DOWNLOAD_EXIT="./epilog"
  58.  
  59. SWFPARAMS="-W http://www.abc.net.au/iview/netConnectionWrapper.swf"
  60. TEMPFILE="/tmp/ivd$$"
  61. TEMPFILE2="/tmp/ivd2$$"
  62. TEMPFILE3="/tmp/ivd3$$"
  63. MISSLIST="work/miss.txt"
  64. OPTION=$1
  65.  
  66.  
  67. # ---------------------------------------------------------------------
  68.  
  69. function linecounts() {
  70.     SLC=`wc -l < $SHOWLIST_TXT      | sed 's/ //g'`
  71.     if [ $SLC == "1" ]; then
  72.     SDESC="1 show"
  73.     else
  74.     SDESC="$SLC shows"
  75.     fi
  76.  
  77.     WLC=`wc -l < $WANTED_TXT    | sed 's/ //g'`
  78.     if [ $WLC == "1" ]; then
  79.     WDESC="1 show"
  80.     else
  81.     WDESC="$WLC shows"
  82.     fi
  83. }
  84.  
  85. # ---------------------------------------------------------------------
  86.  
  87. function setWantedListName() {
  88.     read -p "New filename to store (or currently storing) download list? " NEW
  89.     if [ "x$NEW" != "x" ]; then
  90.     WANTED_TXT="$NEW"
  91.     touch $WANTED_TXT
  92.     lincecounts
  93.     echo $WDESC wanted in $WANTED_TXT
  94.     else
  95.     echo "Download list unchanged - still using $WANTED_TXT"
  96.     fi
  97. }
  98.  
  99. function setWantedtoExtra() {
  100.     NEW=$EXTRAS_TXT
  101.     if [ "x$NEW" != "x" ]; then
  102.     WANTED_TXT="$NEW"
  103.     touch $WANTED_TXT
  104.     lincecounts
  105.     echo $WDESC wanted in $WANTED_TXT
  106.     else
  107.     echo "Download list unchanged - still using $WANTED_TXT"
  108.     fi
  109. }
  110.  
  111. function addToWantedList() {
  112.     read -p "Provide show number(s) to add to download list: " NEW
  113.     if [ "x$NEW" != "x" ]; then
  114.     cp $WANTED_TXT $TEMPFILE
  115.     for N in `echo $NEW`
  116.     do
  117.         sed "$N!d" < $SHOWLIST_TXT >> $TEMPFILE
  118.     done
  119.     /usr/bin/sort -u < $TEMPFILE > $WANTED_TXT
  120.     rm -f $TEMPFILE
  121.     linecounts
  122.     echo $WDESC wanted in $WANTED_TXT
  123.     fi
  124. }
  125.  
  126. function displayWantedList() {
  127.     cut -f1,3,5,6 < $WANTED_TXT | cat -n | $VIEWER
  128.     echo
  129.     linecounts
  130.     echo $WDESC wanted in $WANTED_TXT
  131. }
  132.  
  133. # ---------------------------------------------------------------------
  134.  
  135. function searchShowList() {
  136.     read -p "Enter search string (not case sensitive): " SEARCHSTRING
  137.     if [ "x$SEARCHSTRING" != "x" ]; then
  138.     cut -f1,4 < $SHOWLIST_TXT | cat -n | grep -i "$SEARCHSTRING" > $TEMPFILE
  139.     LC=`wc -l < $TEMPFILE       | sed 's/ //g'`
  140.     if [ $LC == "0" ]; then
  141.         echo no matching shows found
  142.     else
  143.         echo $LC found: ; cat < $TEMPFILE
  144.         echo
  145.         addToWantedList
  146.     fi
  147.     rm -f $TEMPFILE
  148.     fi
  149. }
  150.  
  151. # ---------------------------------------------------------------------
  152.  
  153. function setShowListName() {
  154.     read -p "New filename to store (or currently storing) showlist? " NEW
  155.     if [ "x$NEW" != "x" ]; then
  156.     SHOWLIST_TXT="$NEW"
  157.     touch $SHOWLIST_TXT
  158.     linecounts
  159.     echo $SDESC listed in $SHOWLIST_TXT
  160.     else
  161.     echo "Showlist unchanged - still using $SHOWLIST_TXT"
  162.     fi
  163. }
  164. function setExitRoutine() {
  165.     read -p "Routine to run after downloading? " NEW
  166.     if [ "x$NEW" != "x" ]; then
  167.     DOWNLOAD_EXIT="$NEW"
  168.     fi
  169. }
  170.  
  171. function displayShowList() {
  172.     cut -f1,3 < $SHOWLIST_TXT | cat -n | $VIEWER
  173.     echo
  174.     linecounts
  175.     echo $SDESC listed in $SHOWLIST_TXT
  176. }
  177.  
  178. function downloadShowList() {
  179.     MISS=`tr "\n|\"\';:<>$" "||........" <$MISSLIST `ZZZZZZZ
  180.     echo MISS pattern $MISS
  181.     # ABC
  182.     SERIES_URL='http://173.230.146.115/iview/api/?series='
  183.     # SERIES_URL='http://www.abc.net.au/iview/api/series.htm?id='
  184.     CONFIG_URL='http://173.230.146.115/iview/xml/config.xml'
  185.     # INDEX_URL='http://tvmp.abc.net.au/iview/api/?index'
  186.     INDEX_URL='http://173.230.146.115/iview/api/?seriesIndex'
  187.     mv $SHOWLIST_TXT $SHOWLIST_TXT.0
  188.     BASEU=`wget -O- -T 20 http://www.abc.net.au/iview/xml/config.xml |grep '"api"' |\
  189.     sed -e 's/^.*value="//' -e 's/".*$//'`
  190.     #echo $BASEU
  191.     INDEX_URL=${BASEU}seriesIndex
  192.     SERIES_URL=${BASEU}series=
  193.     wget -nv -O- -T 20 $INDEX_URL  | \
  194.     sed -e 's/][}],[{]/\n/g' | sed -e 's/^[[{]*"a"\:"\([^"]*\)","b"\:"\([^"]*\)","e"\:"\([^"]*\)".*$/id=\1 name=\2 desc=\3/' -e '/shopdownload/d' |\
  195. #    sed -e 's/[[]"\([^"]*\)","\([^"]*\)","","","\([^"]*\)",[[]\([[][^]]*],*\)*]]/id=\1 name=\2 desc=\3\n/g' |sed -e 's/^[[,]//' -e '/^]$/d' |\
  196.     sed -e 's/^id=\([^ ]*\) .*$/\1/' > $TEMPFILE
  197.     #cat $TEMPFILE > /dev/tty
  198.  
  199.     #wget -nv -O- $INDEX_URL | sed -e 's/.//' -e 's/\(}]}\),/\1\/g' | sed 's/."id":"\(.*\)","title.*/\1/' > $TEMPFILE
  200.  
  201.     for series in `cat $TEMPFILE`
  202.     do
  203.     echo -n '#' > /dev/tty
  204.     echo -n '#' $series > /dev/tty
  205.     # ["number","series title","","image","key",[ -list- ]
  206.     # ["number","*episode*","subtitle","description","genre","*shown date*","keep date","","*size*","*duration*","instruction","web","rating","*url*","","","",""]
  207.     wget -nv -O- -T 20 "$SERIES_URL$series" |\
  208.         sed -e 's,\\/,/,g' -e 's/[}],[{]/}\n{/g' -e 's/"f"\:[[][{]/\n/g'|tee /dev/tty|sed -e 's/^[^}]*"b"\:"\([^"]*\)"[^}]*"f"\:"\([^"]*\)"[^}]*"i"\:"\([^"]*\)","j"\:"\([^"]*\)"[^}]*"n"\:"\([^"]*\)".*$/\n\1\t\2\tABC\t\5\t\3\t\4\n/g' > test.txt
  209. # sed -e 's,\\/,/,g' -e '/abcshop/d' -e 's/[[]"[^"]*","\([^"]*\)","[^"]*","[^"]*","[^"]*","\([^"]*\)","[^"]*","[^"]*","\([^"]*\)","\([^"]*\)","[^"]*","[^"]*","[^"]*","\([^"]*\)","[^"]*","[^"]*","[^"]*"]*,*/\n\1\t\2\tABC\t\5\t\3\t\4\n/g' > test.txt
  210. #echo formatted ABC line >/dev/tty
  211. #cat test.txt >/dev/tty
  212. cat test.txt
  213.     # wget -nv -O- "$SERIES_URL$series" | sed -e 's/[[]"\([^"]*\)","\([^"]*\)","","","\([^"]*\)",[[]\([[][^]]*]\)*]]/id=\1 name=\2 desc=\3\n/g' | tee test.txt
  214.     done | \
  215.     grep -E '(\.flv|\.mp4)  ' > $TEMPFILE2
  216.     pag=94
  217.     echo starting SBS
  218.     #grab the seed file
  219.     #split chunk into lines
  220.     #only use lines with playlist
  221.     # remove before the first quote, and after second (or last) quote
  222.     # and remove duplicates - output is a list of relative URLs
  223.     echo  "/video/playlist/index/standalone/$pag" |\
  224.     wget -i- -O- -o log2.file -B http://player.sbs.com.au |\
  225.     # use category tag as new line divider
  226.     sed "s/[<]category[>]/\n&/g" |\
  227.     # strip off everything till name=, and everything from src=,
  228.     # and use title tag as a seperator
  229.     sed -e 's/^.*name="//' -e 's/[<]\/title[>].*$//' -e 's/^.*" src="//' -e 's/"[>][<]title[>]/ /' -e 's/\([^ ]*\) \(.*\)$/\2\t-date-\t\SBS\t\1\tSIZE\t\DUR/' \
  230.     >> $TEMPFILE2
  231.     echo finished SBS
  232.  
  233. # script to retrieve all yahoo plus 7 programs
  234. # copyright tilt whirl 2010
  235. # This program released under GPL
  236. # parameter 1: filter expression to match name of a program
  237. # output is a script that can stream the episode
  238.  
  239. wget -O- "http://au.tv.yahoo.com/plus7/browse/"|grep " <a href="|sed -e 's/^.*href="//' -e 's/".*$//'|tr "
  240. " " " |\
  241. egrep -v "$MISS" |\
  242. wget -i- -O- -nv -T 20 | grep "<h3>.*$1"|sed -e 's/^.*href="/http:\/\/au.tv.yahoo.com/' -e 's/".*$//'|egrep -v "$MISS" |/usr/bin/sort|uniq >tempselect.url
  243. # tempselect.url is a list of url's in a file, one for each episode available
  244. # for each episode the code is repeated
  245. for  URL in `<tempselect.url` ; do
  246.     shname=`echo $URL|cut -f5,9 -d/|tr "/-" "  "`
  247.     echo -n $shname\   
  248.     # find out the id number of the episode, we just want one number
  249.     #IDID=`wget -O- -nv -T 20 "$URL" |grep "vid.:"|cut -f2 -d\'`
  250.     echo $shname\   07$URL\   unknown\    unknown>> $TEMPFILE2
  251.     # the xml file, which includes airing time, and a picture, not used here
  252.     #wget -O- "http://cosmos.bcst.yahoo.com/rest/v2/pops;id=$IDID;lmsoverride=1"
  253.     #XML="http://cosmos.bcst.yahoo.com/rest/v2/pops;id=$IDID;lmsoverride=1;element=stream;bw=1200"
  254.     done
  255.     /usr/bin/sort -u <$TEMPFILE2 >$SHOWLIST_TXT
  256.     rm -f $TEMPFILE
  257.  
  258.     echo '' > /dev/tty
  259.     linecounts
  260.     echo $SDESC now listed in $SHOWLIST_TXT
  261.    
  262.     comm -2 -3 $SHOWLIST_TXT $SHOWLIST_TXT.0 |cut -f1,2|$VIEWER
  263. }
  264.  
  265. # ---------------------------------------------------------------------
  266.  
  267. function fetchServerToken() {
  268.     HANDSHAKER="http://www2b.abc.net.au/iViewHandshaker/Services/iViewHandshaker.asmx/isp"
  269.     HANDSHAKER="http://tviview.abc.net.au/iview/auth/?v2"
  270.  
  271.     echo getting server token
  272.     wget -nv -O- $HANDSHAKER > $TEMPFILE
  273.     SERVER=`grep  '<host>'  < $TEMPFILE | sed 's=.*<host>\(.*\)</host>.*=\1='`
  274.     FREE=`grep  '<free>'  < $TEMPFILE | sed 's=.*<free>\(.*\)</free>.*=\1='`
  275.     ISP=`grep  '<isp>'  < $TEMPFILE | sed 's=.*<isp>\(.*\)</isp>.*=\1='`
  276.     TOKEN=`grep '<token>' < $TEMPFILE | \
  277.     sed -e 's=.*<token>\(.*\)</token>.*=\1=' -e 's/&amp;/\&/'`
  278.     cat $TEMPFILE >> thetoken
  279.     rm -f $TEMPFILE
  280.     echo get token $TOKEN
  281. }
  282.  
  283. function fromAkamai() {
  284.     $RTMP $SWFPARAMS $RESUME \
  285.     -r "rtmp://cp53909.edgefcs.net////flash/playback/_definst_/$SHOWPATH" \
  286.     -t "rtmp://cp53909.edgefcs.net/ondemand?auth=$TOKEN" \
  287.     -W "http://www.abc.net.au/iview/images/iview.jpg" \
  288.     -o "$OUTFILE" 2>&1
  289.     rtmpstatus="$?"
  290. }
  291.  
  292. function fromHostworks() {
  293.     $RTMP $SWFPARAMS $RESUME \
  294.     -r "rtmp://203.18.195.10/ondemand?auth=$TOKEN" \
  295.     -y "$SHOWPATH" \
  296.     -W "http://www.abc.net.au/iview/images/iview.jpg" \
  297.     -o "$OUTFILE" 2>&1
  298.     rtmpstatus="$?"
  299. }
  300.  
  301. function fromSBS() {
  302.     #OUTFILE=${SHOWNAME/,[@ //]/_}.flv
  303.     OUTFILE=`echo "$SHOWNAME.flv"|tr "@" " "|tr -d "\\/:$,*?\"<>|" `
  304.     echo OUTFILE $OUTFILE
  305.     SBSXML=`echo "$LOCATION" |wget -O- -i- -o log3.file -B http://player.sbs.com.au`
  306.     RY=`echo $SBSXML|sed  -e '/base=.rtmp/s/^.*"\(rtmp:\/\/[^"]*\)".*video src="\([^?]*\)\(?[^"]*\)".*1000000.*$/.\/ -r "\1\2.flv"  -y "s\/\2\3" /;s/&amp;/\&/g' \
  307. -e '/base=.rtmp/s/^.*"\(rtmp:\/\/[^"]*\)".*video src="\([^"]*\).flv".*1000000.*$/ -r "\1" -y "\2" /;s/&amp;/\&/g'  `
  308. #
  309.     R=`echo $SBSXML|sed  -e '/base=.rtmp/s/^.*"\(rtmp:\/\/[^"]*\)".*video src="\([^?]*\)\(?[^"]*\)".*1000000.*$/.\/\1\2.flv/;s/&amp;/\&/g' \
  310. -e '/base=.rtmp/s/^.*"\(rtmp:\/\/[^"]*\)".*video src="\([^"]*\).flv".*1000000.*$/\1/;s/&amp;/\&/g'  `
  311. #
  312.     Y=`echo $SBSXML|sed  -e '/base=.rtmp/s/^.*"\(rtmp:\/\/[^"]*\)".*video src="\([^?]*\)\(?[^"]*\)".*1000000.*$/.\/"s\/\2\3/;s/&amp;/\&/g' \
  313. -e '/base=.rtmp/s/^.*"\(rtmp:\/\/[^"]*\)".*video src="\([^"]*\).flv".*1000000.*$/\2/;s/&amp;/\&/g'  `
  314. #
  315. #-e '/base=.http/s/^.*"\(http:\/\/[^"]*\)".*video src="\([^"]*\)".*1000000.*$/wget -O "\2" "\1\2" /'
  316.     echo debug RY $RY R $R y $Y
  317.     $RTMP -r $R -y $Y -s "http://player.sbs.com.au/web/flash/standalone_video_player_application.swf" -m 300 --resume -o "$OUTFILE" 2>&1
  318.     rtmpstatus="$?"
  319.     echo $RTMP $RY -s "http://player.sbs.com.au/web/flash/standalone_video_player_application.swf" -m 300 --resume -o "$OUTFILE" >debugcommand
  320.     #rtmpstatus="$?"
  321.     sleep 10
  322.     }
  323.  
  324. function fromPLUS7(){
  325.  
  326. # script to retrieve one yahoo plus 7 program
  327. # copyright tilt whirl 2010
  328. # parameter 1: program id
  329.  
  330. # find out the id number of the episode, we just want one number
  331. IDID=`wget -O- -nv -T 20 "$LOCATION" |grep "vid.:"|cut -f2 -d\'`
  332. #rawIDID=${LOCATION:-.}
  333. #IDID=`echo "$rawIDID"|sed "s,^.*/,,"`
  334. echo "# id" $IDID
  335. XML="http://cosmos.bcst.yahoo.com/rest/v2/pops;id=$IDID;lmsoverride=1;element=stream;bw=1200"
  336. echo "# URL of XML is" "$XML"
  337. # grab the xml descripter file for the stream
  338. # and pick the informative line out, map it to a rtmpdump command
  339. wget -O- "$XML" > tempstream.xml
  340. echo 99999999999
  341. cat tempstream.xml > /dev/tty
  342. echo 99999999999
  343. PATHS=`grep "media:content url" <tempstream.xml| \
  344. sed -e '/media:content/s/^.*media:content url=./"/' -e 's/" path="/" -y "/' -e 's/type=".*$//'`
  345. #echo extracting the URL
  346. #URL=`grep "media:content url" tempstream.xml| sed -e '/media:content/s/^.*media:content url=.//' -e 's/" path=".*$//' `
  347. #echo URL $URL
  348. #PATHS=`grep "media:content url" tempstream.xml| sed -e '/media:content/s/^.*media:content url=..*" path="//' -e 's/".*type=".*$//' `
  349. #echo PATH $PATHS
  350. # retrieve episode name, clean damaging characters,
  351. # extract title between square brackets, and turn it into -o value
  352. # and dont forget the file extension
  353.  
  354. OUTFILE=`grep "<title><![[]CDATA[[]" tempstream.xml|\
  355. tr -d "\\/:$,*?\"<>|" |\
  356. sed -e 's/^.*[[]\(.*\)]].*$/"\1.flv" /'`
  357. #rtmpdump -r $URL -y "$PATHS" -W "http://d.yimg.com/m/up/ypp/au/player.swf" --resume -m 300 -o $OUTFILE
  358. echo rtmpdump -r $PATHS -W "http://d.yimg.com/m/up/ypp/au/player.swf" --resume -m 300 -o "$OUTFILE"|bash
  359.     rtmpstatus="$?"
  360. echo plus7 $OUFILE
  361. OUTFILE=${OUTFILE//\"/}
  362. echo plus7 $OUFILE
  363. }
  364.  
  365. function downloadShowAlwaysRetry() {
  366. # input STATION LOCATION SHOWNAME
  367.   if [ "x$STATION" == "xABC" ]; then
  368. #  
  369.     SHOWEXT=`echo  $LOCATION | sed 's,.*\.\(.*\),\1,'`
  370.     SHOWNAME=`echo $LOCATION | sed -e "s,\(.*\)\.$SHOWEXT,\1," -e 's,.*/,,'`
  371.     CHANNEL=`echo $LOCATION | sed -e "s,$SHOWNAME\.$SHOWEXT,," -e 's,/$,,' -e 's,^/,,'`
  372.  
  373.     if [ "x$CHANNEL" == "x" ]; then
  374.     OUTFILE="$SHOWNAME.flv"
  375.     else
  376.     OUTFILE=`echo $CHANNEL/$SHOWNAME.flv | sed "s,/,-,g"`
  377.     SHOWNAME="$CHANNEL/$SHOWNAME"
  378.     fi
  379.     OUTFILE="$DESTDIR/$OUTFILE"
  380.     echo CHANNEL "$CHANNEL" SHOWNAME "$SHOWNAME" SHOWEXT $SHOWEXT OUTFILE "$OUTFILE"
  381.   fi
  382.  
  383.     TRIES=0
  384.     T0=`date +%s`
  385.     while [ $TRIES -le 5 ] ; do
  386.       if [ "x$STATION" == "xABC" ]; then
  387.     fetchServerToken
  388.  
  389.     if [ $SHOWEXT == "mp4" ]; then
  390.         case $SERVER in
  391.         Akamai) SHOWPATH="$SHOWNAME.mp4"    ;;
  392.         *)  SHOWPATH="mp4:$SHOWNAME"    ;;
  393.         esac
  394.     else
  395.         SHOWPATH="$SHOWNAME"
  396.     fi
  397.         echo fromAkemai $SHOWPATH
  398.  
  399.     echo Downloading $OUTFILE from ABC-iView servers on $SERVER
  400.  
  401.     case $SERVER in
  402.         Akamai) fromAkamai ;;
  403.         *)      fromHostworks ;;
  404.     esac
  405.       elif [ "x$STATION" == "xSBS" ]; then
  406.         fromSBS;
  407.       elif [ "x$STATION" == "x7" ]; then
  408.         fromPLUS7;
  409.       else echo unknown station "$STATION"; break
  410.       fi
  411.     T1=`date +%s`
  412.  
  413.     if [ "$rtmpstatus" == "0" ]; then
  414.         break;
  415.     fi
  416.  
  417.  
  418. # Unsuccessful, sleep, and retry #with swapped extension
  419.     echo "exit status $rtmpstatus, retrying after $SLEEPTIME seconds" retry $TRIES ; echo
  420.     sleep $SLEEPTIME
  421.     TRIES=$(( $TRIES + 1 ))
  422.     done
  423.     ls -l "$OUTFILE"
  424.     echo "Download took `expr $T1 - $T0` seconds"
  425.     echo
  426.     if test -f stop ; then exit ; fi
  427.     if test -f abort ; then exit ; fi
  428. }
  429.  
  430. function downloadWantedList() {
  431.     RESUME="--resume"
  432.     sed -e "s/ /@/g" $WANTED_TXT |while read SHOWNAME SN STATION LOCATION RIT ; do
  433.     echo SHOWNAME=$SHOWNAME STATION=$STATION LOCATION=$LOCATION
  434.     downloadShowAlwaysRetry
  435.         if test -f abort ; then exit ; fi
  436.     done
  437.     sed -e "s/ /@/g" $EXTRAS_TXT |while read SHOWNAME SN STATION LOCATION RIT ; do
  438.     echo SHOWNAME=$SHOWNAME STATION=$STATION LOCATION=$LOCATION
  439.     downloadShowAlwaysRetry
  440.         if test -f abort ; then exit ; fi
  441.     done
  442. }
  443.  
  444. # ---------------------------------------------------------------------
  445.  
  446. function convertFiles() {
  447.     for FLV in *.flv
  448.     do
  449.     if file $FLV | grep -q Flash.Video
  450.     then
  451.         MP4=`echo $FLV | sed 's/\.flv/.mp4/'`
  452.         echo ; echo "converting $FLV  ->  $MP4"
  453.         $FFMPEG -y -i $FLV \
  454.         -ar 22500 \
  455.         $MP4 >& $FFMPEG_LOG
  456.  
  457.         ls -l $FLV $MP4
  458.     fi
  459.     done
  460. }
  461.  
  462. # ---------------------------------------------------------------------
  463.  
  464. function newinlist() {
  465.     comm -2 -3 $SHOWLIST_TXT $SHOWLIST_TXT.0 |cut -f1,2|$VIEWER
  466. }
  467.  
  468. # ---------------------------------------------------------------------
  469. function editWantedList() {
  470.     $EDITOR $WANTED_TXT
  471. }
  472.  
  473. # ---------------------------------------------------------------------
  474. function ManualDownload() {
  475.     STARTTIME=
  476.     STOPTIME=
  477.     RESUME=
  478.     read -p "enter filename: " wanted
  479.     read -p "enter start time in seconds: " STARTTIME
  480.     read -p "enter stop time in seconds: " STOPTIME
  481.     if [ "STARTTIME" != "" ] ; then RESUME="-A $STARTTIME" ; fi
  482.     if [ "STOPTIME" != "" ] ; then RESUME="$RESUME -B $STOPTIME" ; fi
  483.     downloadShowAlwaysRetry $wanted
  484.    
  485. }
  486.  
  487. # ---------------------------------------------------------------------
  488.  
  489. function mainmenu() {
  490.     echo "l)  Download a new SHOWLIST from iView (to $SHOWLIST_TXT)"
  491.     echo ""
  492.     if [ $SLC != "0" ]; then
  493.     echo "v)  View the current SHOWLIST ($SDESC)"
  494.     echo "n)  See the new listings in ($SDESC)"
  495.     echo "s)  Search the SHOWLIST"
  496.     echo "a)  Add show numbers to your WANTED list"
  497.     echo ""
  498.     fi
  499.     if [ $WLC != "0" ]; then
  500.     echo "w)  View your current WANTED list ($WDESC)"
  501.     echo "e)  Edit your current WANTED list ($WDESC)"
  502.     echo "E)  Make WANTED list the extras"
  503.     echo "c)  Clear your current WANTED list ($WDESC)"
  504.     echo "d)  Download your WANTED shows from iView ($WDESC)"
  505.     echo ""
  506.     fi
  507.     echo "t)  Convert downloaded Flash Video files for TiVo"
  508.     echo ""
  509.     echo "f)  Set the filename holding the SHOWLIST (currently $SHOWLIST_TXT)"
  510.     echo "m)  Set the manual download settings"
  511.     echo "F)  Set the filename holding your WANTED list (currently $WANTED_TXT)"
  512.     echo "z)  Set the filename of the post download routine (currently $DOWNLOAD_EXIT)"
  513.     echo ""
  514.     echo "x)  Exit"
  515.     echo ""
  516.  
  517.     read -p "Select an option: " OPTION
  518. }
  519.  
  520. function press() {
  521.     echo
  522.     read -p "Press ENTER to continue ..."
  523. }
  524. # ---------------------------------------------------------------------
  525.  
  526. while true
  527. do
  528.     linecounts
  529.     clear
  530.     if [ "$OPTION" = "" ]; then mainmenu; fi
  531.  
  532.     case $OPTION in
  533.         l)  downloadShowList ; press ;;
  534.         v)  displayShowList ; press ;;
  535.         n)  newinlist ; press ;;
  536.  
  537.         s)  searchShowList ; press ;;
  538.         a)  addToWantedList ; press ;;
  539.         c)  cp /dev/null $WANTED_TXT    ;;
  540.  
  541.         d)  downloadWantedList ; press ;;
  542.         e)  editWantedList ;;
  543.         E)  setWantedtoExtra ;;
  544.         w)  displayWantedList ; press ;;
  545.  
  546.         f)  setShowListName ;;
  547.         F)  setWantedListName ;;
  548.  
  549.         m)  ManualDownload ; press ;;
  550.         t)  convertFiles ; press ;;
  551.         z)  setExitRoutine ; press ;;
  552.  
  553.         x)  exit ;;
  554.  
  555.         *)  OPTION= ;continue ;;
  556.     esac
  557.     OPTION=
  558. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement