3

I'm building an application in Unity that can play Twitch VODs via the AVPro video player. Using Twitch's V5 API I can retrieve up to 100 of the most recent VODs of a given channel (source).

I have successfully performed that; however, the JSON objects contain URLs with links to the VOD - the same one you'd see if you went to a channel and clicked on an archived broadcast - but not a link to the video file itself. I need a video file to link to AVPro for it to play the VOD, and I have searched all over the internet and through Twitch's API and cannot find a way to get a URL to a video file corresponding to a VOD. I do not want to download the VOD with a 3rd party service, as that will take up too much of the user's memory. To note, I am getting this data in C# using Unity's WWW class.

Is there something I'm missing, or is this simply not possible? All help is greatly appreciated!

  • 1
    I don't believe Twitch offers direct downloads of their VODs, however there are other programs like Livestreamer and Streamlink that have implemented the ability to pipe live streams and VODs through a player of choice (e.g. VLC) using just the URL of the stream/VOD. I believe both of those are open source, so you may be able to look at their code for help or use the programs directly to pipe the bytes to your app. – JBC May 25 '17 at 18:25

1 Answers1

2

By going through the source code to Twitch Leecher, I found the following two API calls:

1. https://api.twitch.tv/api/vods/{0}/access_token
2. https://usher.ttvnw.net/vod/{0}?nauthsig={1}&nauth={2}&allow_source=true&player=twitchweb&allow_spectre=true&allow_audio_only=true

The first API takes in the video ID of the VOD for {0} and returns a token and signature. For the second API, use the video ID for {0} again, the signature for {1}, and the entire token for {2}.

After that is done, I had a string with various source URLs for the VOD corresponding to different qualities. Then it was just a simple matter of parsing the result and taking the links I wanted!