Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

daily show download script
Sunday, September 20th, 2009 at 11:49:13am MDT 

  1. #!/bin/bash
  2. #
  3. # This script depends on curl, rtmpdump and avidemux.
  4. # For playback I recommend mplayer.
  5. # Sometimes the sound is not in sync : /
  6. # Suggestions welcome.
  7. #
  8.  
  9. RTMPDUMP="rtmpdump_x86" # the name of the binary
  10.  
  11. set -eu
  12.  
  13. if [ $# = 1 ] && [ ${#1} = 6 ] ; then
  14.   ID="$1"
  15. elif [ $# = 1 ] && echo "$1" | grep -E -q "http://media.mtvnservices.com/mgid:cms:[^:]+:comedycentral.com:[0-9]+" ; then
  16.   ID=`echo "$1" | cut -d : -f 6`
  17. elif [ $# = 1 ] && echo "$1" | grep -E -q "http://.+" ; then
  18.   if ! ID=`curl -s "$1" | grep -E -m 1 -o "http://media.mtvnservices.com/mgid:cms:[^:]+:comedycentral.com:[0-9]+" | cut -d : -f 6` ; then
  19.     echo "error: could not extract video id"
  20.     exit 1
  21.   fi
  22. else
  23.   echo "usage:"
  24.   echo "  $0 \${ID}"
  25.   echo "  $0 http://www.thedailyshow.com/full-episodes/\${ID}/title-of-the-episode"
  26.   echo "  $0 http://www.thedailyshow.com/watch/some-kind-of-date/title-of-video"
  27.   echo "  $0 http://www.comedycentral.com/colbertreport/full-episodes/index.jhtml?episodeId=\${ID}"
  28.   echo "  $0 http://media.mtvnservices.com/mgid:cms:item:comedycentral.com:\${ID}"
  29.   echo "  $0 http://media.mtvnservices.com/mgid:cms:video:comedycentral.com:\${ID}"
  30.   echo "  $0 http://media.mtvnservices.com/mgid:cms:fullepisode:comedycentral.com:\${ID}"
  31.   exit 1
  32. fi
  33.  
  34. RTMPDUMP_OPTS="--swfsize 563963 --swfUrl http://media.mtvnservices.com/player/release/?v=3.14.0"
  35. RTMPDUMP_OPTS="$RTMPDUMP_OPTS --swfhash 1155163cece179766c97fedce8933ccfccb9a553e47c1fabbb5faeacc4e8ad70"
  36.  
  37. GEN_URL="http://media.mtvnservices.com/player/config.jhtml?uri=mgid:cms:item:comedycentral.com:${ID}&group=entertainment&type=error"
  38. PARTS=`curl -s "$GEN_URL" | grep media:content | grep -v bumper | cut -d \" -f 2`
  39.  
  40. DIR="/tmp/dailyshow_${ID}"
  41. [ ! -d "$DIR" ] && mkdir $DIR
  42.  
  43. AVIDEMUX_ARGS="--audio-codec copy --video-codec copy"
  44. TMP="--load"
  45.  
  46. # download parts in parallel
  47. for X in $PARTS ; do
  48.   VIDEO_URL=`curl -s "$X" | grep edgefcs.net | tail -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1`
  49.   FILENAME="${DIR}/"`basename "$VIDEO_URL"`
  50.   $RTMPDUMP $RTMPDUMP_OPTS -r "$VIDEO_URL" -o "$FILENAME" &
  51.   AVIDEMUX_ARGS="$AVIDEMUX_ARGS $TMP $FILENAME"
  52.   TMP="--append"
  53. done
  54. wait
  55.  
  56. # this introduces a small audio delay
  57. #avidemux2_cli $AVIDEMUX_ARGS --output-format avi --save dailyshow_${ID}.avi
  58.  
  59. # but this seems to work a little better
  60. avidemux2_cli $AVIDEMUX_ARGS --output-format ogm --fps 29.97 --save dailyshow_${ID}.ogm
  61. echo "call: mplayer dailyshow_${ID}.ogm"
  62.  
  63. # this doenst work
  64. #mencoder -quiet -of lavf -oac copy -ovc copy -o "dailyshow_${ID}.flv" ${DIR}/*.flv
  65.  
  66. # this also doesnt work
  67. #ffmpeg -i a.flv -i b.flv -i c.flv -vcodec copy -acodec copy out.flv
  68.  
  69. # remove temporary files (let's not)
  70. #rm -r "$DIR"
  71. echo "or: mplayer ${DIR}/"'*.flv'

Paste Details

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right worth-right