public TwitchStreamPreviewResultsBuilder Add(
            string streamThumbnailUrl,
            int numberOfViewers,
            string channelName,
            string channelLogo,
            string streamUrl,
            string streamName)
        {
            var twitchStream = new TwitchStreamDto
            {
                preview = new TwitchStreamPreviewDto
                {
                    medium = streamThumbnailUrl
                },
                viewers = numberOfViewers,
                channel = new TwitchChannelDto
                {
                    status       = streamName,
                    display_name = channelName,
                    logo         = channelLogo,
                    url          = streamUrl,
                },
            };

            twitchStreams.Add(twitchStream);

            return(this);
        }
Пример #2
0
        public async Task <bool> CheckIfStreamIsLive(string path)
        {
            using (HttpResponseMessage response = await client.GetAsync(path).ConfigureAwait(false))
            {
                if (response.IsSuccessStatusCode)
                {
                    string jsonResponse = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                    TwitchStreamDto twitchUser = JsonConvert.DeserializeObject <TwitchStreamDto>(jsonResponse);

                    if (twitchUser.Stream != null)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }