DownloadTVStream

2018/11/13

Categories: technology tv Tags: media

Downloading from German TV Streams

I wanted to download German TV Streaming media, on a schedule (i.e. to grab a particular show on a weekly basis). That’s not particularly difficult, but it took a while

Source URLS:

Lots of good information here: https://wiki.ubuntuusers.de/Internet-TV/Stationen/ the URL I wanted was for “Das Erste”: https://daserstehdde-lh.akamaihd.net/i/daserstehd_de@629196/master.m3u8

Software

I pretty quickly decided that VLC could do what I needed (via command line interface, cvlc). My first attempt was a bash script like so:

#!/bin/bash
cd /temp/Video/
timeout 2h cvlc https://daserstehdde-lh.akamaihd.net/i/daserstehd_de@629196/master.m3u8 --sout file/ts:SavedFile_$(date +%F).ts

Problems!

This nearly worked but with 2 problems:

Working Solution

I spent a lot of time trying to use different URLs, or to set a preferred resolution, without success. Final fix was to add an extra tool: Streamlink

This wasn’t in Debian at the time, but can be installed with pip. However, I was keen not to add repositories and to at least sort-of sandbox it, so installation steps I followed were:

pip install virtualenv
mkdir ~/src/StreamLink
cd ~/src/StreamLink
virtualenv StreamLink
source StreamLink/bin/activate
pip install streamlink

Then I reworked my bash script like so (note here I’m downloading at 540p):

#!/bin/bash
source ~/src/StreamLink/StreamLink/bin/activate
cd ~/temp/Video/

timeout 2h streamlink --player="cvlc --sout file/ts:SavedFile_$(date +%F_%T)_540p.ts" \
https://daserstehdde-lh.akamaihd.net/i/daserstehd_de@629196/master.m3u8 540p
>> Home