- Migrated to twitch helix api for stream notifications

- Added 2 new fields to creds.yml -> TwitchClientId and TwitchClientSecret
- Users now have to provide them in order to use twitch stream notifications as Twitch is shutting down old api on 18th of February 2022
- Possibly fixed some issues with streams randomly getting cleared
- Added an incomplete trovo stream notification provider
This commit is contained in:
Kwoth
2022-02-15 17:03:31 +01:00
parent 7ed1b13e85
commit e6e802b563
15 changed files with 340 additions and 330 deletions

View File

@@ -26,7 +26,7 @@ public class NotifChecker
_key = $"{uniqueCacheKey}_followed_streams_data";
_streamProviders = new()
{
{ FollowedStream.FType.Twitch, new TwitchProvider(httpClientFactory) },
{ FollowedStream.FType.Twitch, new TwitchHelixProvider(httpClientFactory, credsProvider) },
{ FollowedStream.FType.Picarto, new PicartoProvider(httpClientFactory) },
{ FollowedStream.FType.Trovo, new TrovoProvider(httpClientFactory, credsProvider) }
};
@@ -95,14 +95,20 @@ public class NotifChecker
{
// update cached data
var key = newData.CreateKey();
CacheAddData(key, newData, true);
// compare old data with new data
var oldData = oldStreamDataDict[key.Type][key.Name];
// this is the first pass
if (oldData is null)
if (!oldStreamDataDict.TryGetValue(key.Type, out var typeDict)
|| !typeDict.TryGetValue(key.Name, out var oldData)
|| oldData is null)
{
continue;
}
// fill with last known game in case it's empty
if (string.IsNullOrWhiteSpace(newData.Game))
newData.Game = oldData.Game;
CacheAddData(key, newData, true);
// if the stream is offline, we need to check if it was
// marked as offline once previously