April 21, 2010 Archives

2010-04-21 00:40:45

Linux, mplayer and the ZDF Mediathek

While the idea behind the ZDF Mediathek is not so bad at all, the actual implementation is a pain in the ass - especially the flash version of the website, which causes my Firefox to crash again and again...
So I tried the HTML version of the site, which has two major advantages:
1.) Firefox doesn't crash anymore and
2.) one can watch the videos with any external program like vlc or mplayer.

However, there's still a huge drawback: The videos are streamed via the Real-Time Streaming Protocol or the Microsoft Media Server Protocol, so basic operations like fast-forwarding, rewinding or pausing should be avoided. Additionally, as no (significant) buffering is performed, your internet connection will be in use for the whole runtime of a video, limiting other online activities.
Looking for an easy solution for this, I checked mplayer's manpage and found the -dumpstream option. The rest was some elementary bash scripting:

mplayer -dumpfile "$(date +%y_%m_%d_%H_%M.dump)" -dumpstream "$(curl -s "$(curl -s "$LINK" | egrep "<li>DSL\s*2000\s*<a href=.*asx" | sed -r 's#.*href="([^"]+)".*#\1#')" | egrep -o 'mms://[^"]+')"
This will save any(?) video from the Mediathek to a local file called *current_date*.dump. If you didn't figure it out by yourself, $LINK must be set to / replaced by the actual URL pointing to your video (you'll need the URL to the HTML version, or do some additional preprocessing first).

Before you ask: Of course I wrote an easy-to-use, ready-to-run script for this - it even does some limited error checking. It can be found here.


Update: Seems like this only works for just a few videos, so don't be too disappointed if it fails...


Posted by haui | Permanent Link | Categories: linux, scripts, perl