Skip to content

Instantly share code, notes, and snippets.

@gganley
Created July 28, 2016 14:44
Show Gist options
  • Select an option

  • Save gganley/8d889b490881cb82cd1170d72e070603 to your computer and use it in GitHub Desktop.

Select an option

Save gganley/8d889b490881cb82cd1170d72e070603 to your computer and use it in GitHub Desktop.
(defn lookup-past-broadcasts [chan]
(->> (client/get (format "https://api.twitch.tv/kraken/channels/%s/videos?limit=10000" chan)
{:content-type :vnd.twitchtv.v3+json
:query-params {"broadcasts" "true"}})
:body
parse-string
walk/keywordize-keys
:videos
(map (fn [x]
(-> x
(select-keys [:recorded_at :_id])
(update :recorded_at tc/from-string)
(update :_id #(apply str (rest %)))
(set/rename-keys {:_id :id :recorded_at :recorded-at}))))))
; (lookup-past-broadcasts "iijeriichoii")
(defn broadcast-id-to-m3u [broadcast-id]
(->> (client/get (format "http://api.twitch.tv/api/vods/%s/access_token" broadcast-id))
:body
parse-string
walk/keywordize-keys
(#(client/get (format "http://usher.twitch.tv/vod/%s" broadcast-id)
{:query-params {"nauthsig" (:sig %)
"nauth" (:token %)}}))
:body))
;(spit "index-dvr.m3u8" (broadcast-id-to-m3u "80174227"))
; ffmpeg -i index-dvr.m3u8 -c copy -bsf:a aac_adtstoasc output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment