You can now follow picarto streams (.picarto/.pa)

This commit is contained in:
Master Kwoth
2017-11-17 18:27:24 +01:00
parent 940600bda6
commit 7a85677d74
6 changed files with 56 additions and 10 deletions

View File

@ -126,6 +126,17 @@ namespace NadekoBot.Modules.Searches.Services
bmData.Url = beamUrl;
_cachedStatuses.AddOrUpdate(beamUrl, bmData, (key, old) => bmData);
return bmData;
case FollowedStream.FollowedStreamType.Picarto:
var picartoUrl = $"https://api.picarto.tv/v1/channel/name/{stream.Username.ToLowerInvariant()}";
if (checkCache && _cachedStatuses.TryGetValue(picartoUrl, out result))
return result;
var paResponse = await _http.GetAsync(picartoUrl).ConfigureAwait(false);
if(!paResponse.IsSuccessStatusCode)
throw new StreamNotFoundException($"{stream.Username} [{stream.Type}]");
var paData = JsonConvert.DeserializeObject<PicartoResponse>(await paResponse.Content.ReadAsStringAsync());
_cachedStatuses.AddOrUpdate(picartoUrl, paData, (key, old) => paData);
return paData;
default:
break;
}
@ -155,7 +166,7 @@ namespace NadekoBot.Modules.Searches.Services
true);
embed.AddField(GetText(fs, "followers"),
status.FollowerCount.ToString(),
status.Followers.ToString(),
true);
if (!string.IsNullOrWhiteSpace(status.Icon))
@ -178,6 +189,8 @@ namespace NadekoBot.Modules.Searches.Services
return $"https://www.twitch.tv/{fs.Username}/";
if (fs.Type == FollowedStream.FollowedStreamType.Mixer)
return $"https://www.mixer.com/{fs.Username}/";
if (fs.Type == FollowedStream.FollowedStreamType.Picarto)
return $"https://www.picarto.tv/{fs.Username}";
return "??";
}
}