Re: Twitch.tv plugin (some help needed)
- From: Mattias Bengtsson <mattias jc bengtsson gmail com>
- To: Bastien Nocera <hadess hadess net>
- Cc: grilo-list gnome org
- Subject: Re: Twitch.tv plugin (some help needed)
- Date: Tue, 06 Jan 2015 05:16:26 +0100
On mån, 2015-01-05 at 10:42 +0100, Bastien Nocera wrote:
Hey Mattias!
On Mon, 2015-01-05 at 06:25 +0100, Mattias Bengtsson wrote:
[...]
– The twitch API uses the following flow to get the video stream URI's:
1) GET https://api.twitch.tv/api/channels/:channel/access_token
2) Unpack the JSON payload and extract the sig and token fields
3) The stream is now:
http://199.9.251.155/api/channel/hls/:channel.m3u8?token=:token&sig=:sig
Is it possible to let my lua-script return a function for
retrieving the sig and token values?
Did you mean to ask how you could cache them, so you only need to query
it once? FWIW, all the HTTP fetches in the Lua sources are async, so
you'd need to queue the "actual" call.
You'd use global variables for that. grl-pluzz.lua in the
grilo-lua-sources repo on github has an example of a cache.
Nah, I basically had no idea at all how grilo works, I think I do might
now though.
I'm fairly sure I'm not supposed
to find these values before I request the stream (running n HTTP-
requests whenever I load a list of streams seems bad, plus I know
from experience that the token can get outdated).
– I would like to be able to browse Twitch like this:
/Top Channels/{stream}
/Games/{game}/{stream}
That is with "sub-folders" at least three deep.
Is this possible in a Lua-plugin? I see that the Rai.tv does it, but
that's also implemented in C.
There's nothing in grilo that cares about depth levels in folders. The
plugin is the one constructing the "ID" for a folder (a box in grilo
parlance). When browsing inside that box, you're given the media ID.
Just make sure you know how to deconstruct the unique ID you've given
for that box item.
Is that clear?
Maybe. Let's see if I understand.
So for the "top-level" box of my plugin I'd get some media_id sent to
grl_source_browse that I'd match on and I'd return two media-objects:
- id="top_channels"
- id="games".
Then when I click on top_channels I'd get a call to grl_source_browse()
with media_id set to "top_channels", I'd pattern match on that and then
return a list of media-objects with id="game/{name_of_game}".
Rinse and repeat 'til I have covered all of twitch.
This is basically me guessing wildy instead of reading code. :)
So have I understood it correctly?
If so then the first question above would be solved by returning a media
object with id="stream/{twitch_user}" and when that one is passed to
grl_source_browse() I'd do the lookup of the sig and token then.
I'm quite sure that the reason Twitch does this is to prevent people
from hot-linking and I believe it is frowned upon and also not really
possible to cache these tokens, they need to be retrieved pretty much
immediately before accessing the stream.
– How do I ship an icon with my plugin?
Putting a .gresource file of the same name as the script in the same
directory.
And then: "source-icon" = "resource:///org/gnome/grilo/twitch.svg"
in the source itself.
Ah thx!
Regards,
Mattias
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]