[vlc-devel] Tagging VLC 3.0.13

Pierre Ynard linkfanel at yahoo.fr
Sat Apr 10 12:39:25 UTC 2021


> > > For Twitch I took a quick look, it seems that a new signature
> > > token is generated by a POST request to the endpoint
> > > https://gql.twitch.tv/gqlthrough/gql with among the request
> > > JSON body, an operationNam: "PlaybackAccessToken_Template".

> For twitch we do pass the Client-ID that way. The issue is the
> token/sig retrieval which is using a removed API, and which must
> be switched to the gqpthrough/gql endpoint.

I don't know what this gqlthrough or gqpthrough thing is, and I
can't find any trace of it. The API endpoint is apparently just
https://gql.twitch.tv/gql

Passing the client ID in the query string is what was done with the
previous API, and I presume it worked, but it apparently doesn't work
with GQL. I tested:

wget -S -q -O - 'https://gql.twitch.tv/gql' --post-data='{}'

HTTP/1.1 400 Bad Request


wget -S -q -O - 'https://gql.twitch.tv/gql' --header 'Client-Id: kimne78kx3ncx6brgo4mv6wki5h1ko' --post-data='{}'

HTTP/1.1 200 OK


wget -S -q -O - 'https://gql.twitch.tv/gql?client_id=kimne78kx3ncx6brgo4mv6wki5h1ko' --post-data='{}'

HTTP/1.1 400 Bad Request


Same thing when replaying the query we need, or a stripped down version
for brevity here:

wget -S -q -O - 'https://gql.twitch.tv/gql?client_id=kimne78kx3ncx6brgo4mv6wki5h1ko' --post-data='{"query":"{ videoPlaybackAccessToken(id: \"978682029\", params: {platform: \"web\", playerType: \"site\"}) { value signature }}"}'

HTTP/1.1 400 Bad Request


wget -S -q -O - 'https://gql.twitch.tv/gql' --header 'Client-Id: kimne78kx3ncx6brgo4mv6wki5h1ko' --post-data='{"query":"{ videoPlaybackAccessToken(id: \"978682029\", params: {platform: \"web\", playerType: \"site\"}) { value signature }}"}

HTTP/1.1 200 OK
...
{"data":{"videoPlaybackAccessToken":{"value":"{\"authorization\":{\"forbidden\":false,\"reason\":\"\"},\"chansub\":{\"restricted_bitrates\":[]},\"device_id\":null,\"expires\":1618057202,\"https_required\":true,\"privileged\":false,\"user_id\":null,\"version\":2,\"vod_id\":978682029}","signature":"16497e7d762cdf483379fee52a734832a78bd848"}},"extensions":{"durationMilliseconds":62,"requestID":"01F2VPXTM0K64J63P3JBAJX8H4"}}


But if someone can find and show how to make it work using query string
parameters or something else instead, I'll take it. Then, all I have to
do is plug the results of that request into this URL template:

https://usher.ttvnw.net/vod/<id>.m3u8?sig=<signature>&token=<value>

And the URL gets me playback in VLC.

> It seems that the adaptive plugin cannot handle the Twitch manifest
> timeline though, so the playback fails a few seconds in.

It works fine for me, using VLC 3.0.12. Playback hangs for a bit a
couple seconds in, while the adaptive module switches from the initial
resolution to the normal one, but that's as usual like with most
streams, then it plays fine after that.

I know we mentioned modifications to pass custom HTTP headers, but
actually we need a POST request here - unless we find some way to use
this API with GET, despite it returning a 405 Method Not Allowed when
trying. I don't think it's possible to issue HTTP POST requests using
the stream layer of VLC. We'd need an HTTP POST API - which could then
also possibly provide access to HTTP headers regardless of the HTTP
access. However I'm not aware that we have such an API yet, and it would
also need to be exposed through lua, and all of that in 3.0.

Another approach would be to write ad hoc HTTP code within the lua
script. This didn't work out too well in the past, and it's not
currently possible either as the network bindings aren't exposed to
playlist scripts (and I'm not saying they should be). However it would
probably work to recode twitch.lua as an interface or extension script,
using ad hoc HTTP POST request code. That's not something I'm going to
pursue though.

-- 
Pierre Ynard
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."


More information about the vlc-devel mailing list