public async void GetFollowedStreams() { listfollow.Items.Clear(); if (Properties.Settings.Default.username != "") { TwitchLib.Models.API.v5.Users.Users userid = await TwitchAPI.Users.v5.GetUserByName(Properties.Settings.Default.username); if (userid.Total != 0) { TwitchLib.Models.API.v5.Users.UserFollows follows = await TwitchAPI.Users.v5.GetUserFollows(userid.Matches[0].Id.ToString(), 100, null, "desc", "last_broadcast"); if (follows.Follows != null) { foreach (TwitchLib.Models.API.v5.Users.UserFollow follow in follows.Follows) { string viewerstatus; string gamestatus; string streamstatus; TwitchLib.Models.API.v5.Streams.StreamByUser stream = await TwitchAPI.Streams.v5.GetStreamByUser(follow.Channel.Id.ToString()); if (stream.Stream == null) { viewerstatus = "0"; gamestatus = ""; streamstatus = "OFFLINE"; } else { viewerstatus = stream.Stream.Viewers.ToString(); gamestatus = stream.Stream.Game; streamstatus = stream.Stream.Channel.Status; } this.listfollow.Items.Add(new StreamList { Name = follow.Channel.DisplayName, Game = gamestatus, Status = streamstatus, Id = follow.Channel.Id.ToString(), Url = follow.Channel.Url, Viewers = viewerstatus }); } } } } else { MessageBox.Show("Please enter username"); } }
private async void UnfollowStream() { if (Properties.Settings.Default.username == "" || Properties.Settings.Default.token == "") { MessageBox.Show("Veuillez enregistrer un username et un token"); } else { if (listfollow.SelectedItems.Count > 0) { StreamList channel = (StreamList)listfollow.Items[listfollow.SelectedIndex]; TwitchLib.Models.API.v5.Users.Users userid = await TwitchAPI.Users.v5.GetUserByName(Properties.Settings.Default.username); if (userid.Total != 0) { await TwitchAPI.Users.v5.UnfollowChannel(userid.Matches[0].Id.ToString(), channel.Id, Properties.Settings.Default.token); GetFollowedStreams(); } } } }