#!/bin/sh # Twitch.tv playlist grab script. # License: WTFPL # Author: Hiltjo Posthuma # Usage: mpv --playlist $(sh twitch.sh channel) # NOTE: channel name is very case-sensitive ;_; [ "$1" = "" ] && printf "Usage: %s \n" "$0" >&2 && exit 1 tokendata=$(curl -s -L "https://api.twitch.tv/api/channels/$1/access_token") test x"${tokendata}" = x"" && exit 1 printf 'http://usher.justin.tv/api/channel/hls/%s.m3u8?token=%s&sig=%s' \ "$1" \ "$(printf '%s' "${tokendata}" | sed -E -e 's@.*"token":"(.*)","sig".*@\1@g' -e 's@\\"@"@g')" \ "$(printf '%s' "${tokendata}" | sed -E 's@.*"sig":"([^"]*)".*@\1@g')"