// Gets m3u for channel on Twitch use "std" use "http" use "json" use "functional" channel = "" if (length(ARGS) > 0) channel = ARGS[0] if (length(channel) == 0) { use "canvas" channel = prompt("Enter twitch channel") } if (length(channel) == 0) channel = "lynxcatgirl" def USHER_API(channel, token, sig) = sprintf("http://usher.twitch.tv/api/channel/hls/%s.m3u8?player=twitchweb&token=%s&sig=%s&allow_audio_only=true&allow_source=true&type=any&p=%d", channel, token, sig, rand(1000000)) TOKEN_API = "http://api.twitch.tv/api/channels/" + channel + "/access_token" thread(::http, TOKEN_API, def(r) { data = jsondecode(r) m3uurl = USHER_API(channel, data.token, data.sig) println m3uurl //use "robot" //toClipboard(m3uurl) use "files" f = fopen(channel + ".m3u8", "wb") writeBytes(f, download(m3uurl)) flush(f) fclose(f) })