Hi, I know this is a common issue and answers can be found online, but I couldnt. I am trying to make a chrome extension thats lets people know the stream has started. I know only html/css and bit of php but thats not a problem i guess.
I got this:
Do you know a bit about JS?
I’ll try to write down the general outline, so you can maybe figure it out yourself.
I’m not sure how this ties into chrome extensions, so I can’t help you with that, but hope this is helpfull.
The API only updates once every 30 seconds or so.
So you’d start with checking for updates every 30 seconds.
Now, in this loop you probably want to load the channel data, like you did.
You load the data in a variable as a JSON. ( i assume you know this much, if this is too hard, maybe you can use Jquery for this?)
Okay great. We got the data!
Now all you have to do aswell, is check the JSON object called “stream”.
If this isn’t null, the channel is online!
so you can simply compare it to null
(I think it’s the string “null”)
So now you figured out if the channel is on.
You probably want a variable that keeps check of the last read, so you don’t spam messages about the streamer being online or being offline. so if the new result is different from this global variable, you can show a message.
Hi, thanks for the explanation. I tried to find some examples online, but I couldn’t, most of them cover the json stuff, but my problem is, that I dont really know what to do with the code that loads channel data, or what should be in the js file that loads channel data.
Instead of reinventing the wheel, you could just use a pre-existing solution like TwitchNow.
I’ve just got my bot checking the channels it joins every few minutes using the Twitch API json. When it checks, it also checks if and when the channel goes online. When/if it detects the channel online, it then grabs the stream’s current FPS, delay, and a few other statistics.
If you still need something like this, let me know and I can get you the code