Compilenix's Blog - Recording live-streams with livestreamer

RSS Feed | Find Stuff

Recording live-streams with livestreamer

This enable you to record a twitch.tv (and many other) stream with VLC or write it into a file and get notified (via mail) when the stream is finished

broadcaster="widgitybear"
while true; do
    date=$(date +%0Y-%0m-%0d.%0k%0M%z)
    file="twitch.tv_${broadcaster}_$date"
    livestreamer twitch.tv/$broadcaster best -l info -o $file.flv --retry-open 3 --hds-segment-threads 4 --hls-segment-threads 4 --no-version-check > /dev/null
    if [[ $? -eq 0 ]]; then
        sendmail yourmail@example.org << EOF
Subject: $broadcaster's stream has finished
$file.flv
EOF
    fi
    echo "$date Waiting 60s... for $broadcaster"
    sleep 60
done

Ref's: livestreamer.io

Update: Repository