Schnee (schnee) wrote,
Schnee
schnee

Downloading the Icelandic evening news

Just on the off chance that someone else is interested, here's a shell script to download the Icelandic evening news. There's no magic involved, just a bit of automation to figure out the right resource name for a given date; the actual downloading's done using rtmpdump.

#!/bin/bash

DATE=$1
EPOCHSECONDS=`date -d "${DATE} UTC" +%s`
EPOCHDAYS=$((EPOCHSECONDS / 86400))
STREAMID=$((4723254 + EPOCHDAYS))
TAG=${STREAMID: -2:2}
STREAMID2=0

until rtmpdump -V -o ${DATE}.mp4 -n sipvodfs.fplive.net -a sipvod -y mp4:opid/${STREAMID}R${STREAMID2}.mp4
do
        if [ "$?" -eq 2 ]
        then
                break
        fi
        STREAMID2=$((STREAMID2 + 1))
        sleep 1
done

mv -f ${DATE}.mp4 ${DATE}_${TAG}R${STREAMID2}.mp4

Invoke it as e.g. ./dlfrettir.sh 2015-08-25, and you'll eventually end up with a 348 MiB file called 2015-08-25_26R10.mp4.

A few notes:

  • Resources are named e.g. 4739918R0.mp4 on the server; the number before the R is sequentially assigned for each new day, the number after is apparently random. (It's often 0, but not always. Numbers exceeding 20 are rare, and I've never seen it go beyond 30.)
  • Broadcasts remain available online for 90 days or so before they're memory-holed.
  • rtmpdump exits with status 0 upon a successful download, 1 if the resource wasn't found, and 2 if the user interrupts the download.
  • The script, as it is, outputs a lot of debug info; remove the -V flag in the rtmpdump call if you'd rather not have that.

Have I mentioned I really dislike shell scripting? So inelegant. (But it gets the job done.)

Tags: icelandic, news, tv, useful stuff
Subscribe

Posts from This Journal “useful stuff” Tag

  • Using ffmpeg to convert MP4s to GIFs

    "GIF" has become a bit of a misnomer in recent years, with various services referring to any animated image as a GIF even when it's not in GIF…

  • HTTP Live Streaming downloads

    If you're finding yourself wanting to save a video that's available on the web, but only served in the form of a bunch of TS files over HTTP…

  • Firefox tracking protection vs. GMail

    If you find yourself unable to access GMail in a recent Firefox version, with a message indicating an infinite redirect loop and advising that this…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 2 comments