- daily show download script
- Sunday, September 20th, 2009 at 11:49:13am MDT
- #!/bin/bash
- #
- # This script depends on curl, rtmpdump and avidemux.
- # For playback I recommend mplayer.
- # Sometimes the sound is not in sync : /
- # Suggestions welcome.
- #
- RTMPDUMP="rtmpdump_x86" # the name of the binary
- set -eu
- if [ $# = 1 ] && [ ${#1} = 6 ] ; then
- ID="$1"
- elif [ $# = 1 ] && echo "$1" | grep -E -q "http://media.mtvnservices.com/mgid:cms:[^:]+:comedycentral.com:[0-9]+" ; then
- ID=`echo "$1" | cut -d : -f 6`
- elif [ $# = 1 ] && echo "$1" | grep -E -q "http://.+" ; then
- 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
- echo "error: could not extract video id"
- exit 1
- fi
- else
- echo "usage:"
- echo " $0 \${ID}"
- echo " $0 http://www.thedailyshow.com/full-episodes/\${ID}/title-of-the-episode"
- echo " $0 http://www.thedailyshow.com/watch/some-kind-of-date/title-of-video"
- echo " $0 http://www.comedycentral.com/colbertreport/full-episodes/index.jhtml?episodeId=\${ID}"
- echo " $0 http://media.mtvnservices.com/mgid:cms:item:comedycentral.com:\${ID}"
- echo " $0 http://media.mtvnservices.com/mgid:cms:video:comedycentral.com:\${ID}"
- echo " $0 http://media.mtvnservices.com/mgid:cms:fullepisode:comedycentral.com:\${ID}"
- exit 1
- fi
- RTMPDUMP_OPTS="--swfsize 563963 --swfUrl http://media.mtvnservices.com/player/release/?v=3.14.0"
- RTMPDUMP_OPTS="$RTMPDUMP_OPTS --swfhash 1155163cece179766c97fedce8933ccfccb9a553e47c1fabbb5faeacc4e8ad70"
- GEN_URL="http://media.mtvnservices.com/player/config.jhtml?uri=mgid:cms:item:comedycentral.com:${ID}&group=entertainment&type=error"
- PARTS=`curl -s "$GEN_URL" | grep media:content | grep -v bumper | cut -d \" -f 2`
- DIR="/tmp/dailyshow_${ID}"
- [ ! -d "$DIR" ] && mkdir $DIR
- AVIDEMUX_ARGS="--audio-codec copy --video-codec copy"
- TMP="--load"
- # download parts in parallel
- for X in $PARTS ; do
- VIDEO_URL=`curl -s "$X" | grep edgefcs.net | tail -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1`
- FILENAME="${DIR}/"`basename "$VIDEO_URL"`
- $RTMPDUMP $RTMPDUMP_OPTS -r "$VIDEO_URL" -o "$FILENAME" &
- AVIDEMUX_ARGS="$AVIDEMUX_ARGS $TMP $FILENAME"
- TMP="--append"
- done
- wait
- # this introduces a small audio delay
- #avidemux2_cli $AVIDEMUX_ARGS --output-format avi --save dailyshow_${ID}.avi
- # but this seems to work a little better
- avidemux2_cli $AVIDEMUX_ARGS --output-format ogm --fps 29.97 --save dailyshow_${ID}.ogm
- echo "call: mplayer dailyshow_${ID}.ogm"
- # this doenst work
- #mencoder -quiet -of lavf -oac copy -ovc copy -o "dailyshow_${ID}.flv" ${DIR}/*.flv
- # this also doesnt work
- #ffmpeg -i a.flv -i b.flv -i c.flv -vcodec copy -acodec copy out.flv
- # remove temporary files (let's not)
- #rm -r "$DIR"
- echo "or: mplayer ${DIR}/"'*.flv'
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.
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.