Skip to content

Instantly share code, notes, and snippets.

@Deflated-Criossant
Created December 10, 2015 12:14
Show Gist options
  • Save Deflated-Criossant/c47ba7d5f5dc6638a1c5 to your computer and use it in GitHub Desktop.
Save Deflated-Criossant/c47ba7d5f5dc6638a1c5 to your computer and use it in GitHub Desktop.

Revisions

  1. @stefanschmidt stefanschmidt revised this gist Feb 2, 2014. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions daily-show-downloader.sh
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ if [ $# = 1 ] && [ ${#1} = 6 ] ; then
    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
    if ! ID=`curl -s "$1" | sed -En 's/.*"video_([0-9]+)".*/\1/p'`; then
    echo "error: could not extract video id"
    exit 1
    fi
    @@ -36,16 +36,16 @@ echo "ID = $ID"

    RTMPDUMP_OPTS="--swfUrl "http://media.mtvnservices.com/player/prime/mediaplayerprime.1.7.0.swf" --swfsize 1983727 --swfhash 0884b06decee5e866a24792f198b4b88f7232e9da92f1e5520ca330822f0d4f9 --resume"

    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`
    GEN_URL="http://shadow.comedycentral.com/feeds/video_player/mrss/?uri=mgid%3Acms%3Aepisode%3Acolbertnation.com%3A{$ID}"
    PARTS=`curl -s "$GEN_URL" | grep media:content | grep -v bumper | sed -En 's/.*url="([^"]+)".*/\1/p'`

    echo -n "PARTS = " ; echo $PARTS

    FILENAMES=""

    # download parts in parallel
    for X in $PARTS ; do
    VIDEO_URL=`curl -s "$X" | grep edgefcs.net | head -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1 | sed -e s/rtmpe/rtmp/`
    VIDEO_URL=`curl -s "$X" | sed -En 's/.*rtmpe([^<]+)<.*/rtmp\1/p' | tail -1`
    echo "VIDEO_URL = $VIDEO_URL"
    FILENAME=`basename "$VIDEO_URL"`
    $RTMPDUMP $RTMPDUMP_OPTS -o "$FILENAME" -r "$VIDEO_URL" &
  2. @stefanschmidt stefanschmidt renamed this gist Mar 6, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @stefanschmidt stefanschmidt renamed this gist Apr 20, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @stefanschmidt stefanschmidt renamed this gist Apr 17, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. @stefanschmidt stefanschmidt revised this gist Apr 16, 2011. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    # Suggestions are welcome.
    #

    RTMPDUMP="rtmpdump_x86" # the name of the binary
    RTMPDUMP="rtmpdump" # the name of the binary

    set -eu

    @@ -34,7 +34,7 @@ fi

    echo "ID = $ID"

    RTMPDUMP_OPTS="--swfUrl "http://media.mtvnservices.com/player/release/?v=4.1.2" --swfsize 536258 --swfhash f98296daddbd723bb2f740a6c276535638038b128857c8e4e750664e9e592468 --resume"
    RTMPDUMP_OPTS="--swfUrl "http://media.mtvnservices.com/player/prime/mediaplayerprime.1.7.0.swf" --swfsize 1983727 --swfhash 0884b06decee5e866a24792f198b4b88f7232e9da92f1e5520ca330822f0d4f9 --resume"

    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`
    @@ -45,7 +45,7 @@ FILENAMES=""

    # 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 | sed -e s/rtmpe/rtmp/`
    VIDEO_URL=`curl -s "$X" | grep edgefcs.net | head -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1 | sed -e s/rtmpe/rtmp/`
    echo "VIDEO_URL = $VIDEO_URL"
    FILENAME=`basename "$VIDEO_URL"`
    $RTMPDUMP $RTMPDUMP_OPTS -o "$FILENAME" -r "$VIDEO_URL" &
  6. @invalid-email-address Anonymous created this gist Jan 13, 2010.
    74 changes: 74 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,74 @@
    #!/bin/bash
    #
    # This script depends on curl and rtmpdump.
    # For playback I recommend mplayer.
    # Suggestions are 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
    BA=`basename "$0"`
    echo "usage:"
    echo " $BA \${ID}"
    echo " $BA http://www.thedailyshow.com/full-episodes/\${ID}/title-of-the-episode"
    echo " $BA http://www.thedailyshow.com/watch/some-kind-of-date/title-of-video"
    # echo " $BA http://www.comedycentral.com/colbertreport/full-episodes/index.jhtml?episodeId=\${ID}"
    echo " $BA http://www.colbertnation.com/full-episodes/date-and-title-of-the-episode"
    echo " $BA http://media.mtvnservices.com/mgid:cms:item:comedycentral.com:\${ID}"
    echo " $BA http://media.mtvnservices.com/mgid:cms:video:comedycentral.com:\${ID}"
    echo " $BA http://media.mtvnservices.com/mgid:cms:fullepisode:comedycentral.com:\${ID}"
    exit 1
    fi

    echo "ID = $ID"

    RTMPDUMP_OPTS="--swfUrl "http://media.mtvnservices.com/player/release/?v=4.1.2" --swfsize 536258 --swfhash f98296daddbd723bb2f740a6c276535638038b128857c8e4e750664e9e592468 --resume"

    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`

    echo -n "PARTS = " ; echo $PARTS

    FILENAMES=""

    # 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 | sed -e s/rtmpe/rtmp/`
    echo "VIDEO_URL = $VIDEO_URL"
    FILENAME=`basename "$VIDEO_URL"`
    $RTMPDUMP $RTMPDUMP_OPTS -o "$FILENAME" -r "$VIDEO_URL" &
    FILENAMES="$FILENAMES $FILENAME"
    done
    wait

    # here is an example of how you can combine the parts into a proper video:
    # NOTE: downloaded files are not actually in mp4 format!
    #
    #mv ds_15001_01_640x360_1300.mp4 ds_15001_01_640x360_1300.flv
    #mv ds_15001_02_640x360_1300.mp4 ds_15001_02_640x360_1300.flv
    #mv ds_15001_03_640x360_1300.mp4 ds_15001_03_640x360_1300.flv
    #mv ds_15001_04_640x360_1300.mp4 ds_15001_04_640x360_1300.flv
    #
    #ffmpeg -acodec copy -vcodec copy -i ds_15001_01_640x360_1300.flv ds_15001_01_640x360_1300.mp4
    #ffmpeg -acodec copy -vcodec copy -i ds_15001_02_640x360_1300.flv ds_15001_02_640x360_1300.mp4
    #ffmpeg -acodec copy -vcodec copy -i ds_15001_03_640x360_1300.flv ds_15001_03_640x360_1300.mp4
    #ffmpeg -acodec copy -vcodec copy -i ds_15001_04_640x360_1300.flv ds_15001_04_640x360_1300.mp4
    #
    #MP4Box -add ds_15001_01_640x360_1300.mp4 -cat ds_15001_02_640x360_1300.mp4 -cat ds_15001_03_640x360_1300.mp4 -cat ds_15001_04_640x360_1300.mp4 -new ds_15001.mp4
    #

    echo
    echo "play it with:"
    echo "mplayer -fixed-vo -fs${FILENAMES}"