Open RFBomb opened 4 years ago
I think the best way to perform the check would be make a call to the twitch api. I have no experience with API calls though.
Here are some links I found:
https://discuss.dev.twitch.tv/t/check-if-streamer-is-online/22672/2
https://discuss.dev.twitch.tv/t/check-whether-channel-is-online-or-not-via-js-solution-found/2019
This PR is not longer required, as this got merged: https://github.com/D3vl0per/Twitch-watcher/pull/84
As I posted in #84 , that change did not satisfy the problem at all.
I have tested and published my mod using the HELIX API here: https://github.com/RFBomb/Twitch-watcher https://hub.docker.com/repository/docker/rfbomb/warframe_watcher
My update to the code is based on the base sourcecode here from a few months back. It involves bit of a major rework in order to incorporate the HELIX API to grab preferred stream status. I have built an entire module that works well if you wish to implement it here.
I wanted to re-work this to watch Twitch.tv/warframe, and after poking through the code, I feel like it could work great. The only hiccup would be actually getting the specific channel that I want to watch, instead of the random channels.
The changes include several new routines:
ViewPriority -> This is now the main loop (instead of ViewRandomPage being the main loop). It allows checking for several high-priority streams to view before viewing any random channels.
ViewURL -> I moved all of the pertinent code from the ViewRandomPage routine into this new routine. This is what will allow specific channels to be watched, while keeping the total code smaller (and mostly the same)
CheckStreamerOnline -> This routine is mocked up, but I'll be honest that I am unsure of how to perform this check at the moment. This routine would return a boolean TRUE if the requested stream is online. The ViewPriority routine would then call the ViewURL to go to that stream.
SleepWatching -> This routine checks if there are any high priority streams running. If there is a higher priority stream running, it will stop sleeping and allow the ViewPriority loop to decide which page to go to next. If no high priority stream is running it will run out the sleep timer in 1 minute increments, checking for higher priorities each loop.
Since this new code will support up to three 'high priority' channels, and I know some people have data caps or other resources they want to be aware of , I also added in the ability to completely ignore the random streams. If enabled, it will ONLY check the specified channels. I have also added some safeguards to avoid refreshing the page if on a high priority stream, and if the 'ignore' function is turned on, but no high priority streams are available, it will refresh the browser and sit idle, and check every 2 minutes. This should save some resources for the end user's system, as well as save the data cost (if they care about it)
These are the commands to be added into the docker environment list:
- IgnoreRandomChannels=TRUE #Disables viewing random channels and sits idle if no High-Priority channels are live