Class representing a channel object from Twitch API.
Beispiel #1
0
 /// <summary>Constructor for follow</summary>
 public Follow(string apiResponse, bool successful = true)
 {
     IsFollowing = successful;
     if(successful)
     {
         JObject json = JObject.Parse(apiResponse);
         CreatedAt = Convert.ToDateTime(json.SelectToken("created_at").ToString());
         TimeSinceCreated = DateTime.UtcNow - CreatedAt;
         if ((bool)json.SelectToken("notifications"))
             Notifications = true;
         Channel = new Channel(json.SelectToken("channel"));
     }
 }
Beispiel #2
0
        /// <summary>Stream object constructor.</summary>
        public Stream(JToken twitchStreamData)
        {
            bool isPlaylist;
            long id;
            int viewers, videoHeight, delay;
            double averageFps;

            if (bool.TryParse(twitchStreamData.SelectToken("is_playlist").ToString(), out isPlaylist) && isPlaylist) IsPlaylist = true;
            if (long.TryParse(twitchStreamData.SelectToken("_id").ToString(), out id)) Id = id;
            if (int.TryParse(twitchStreamData.SelectToken("viewers").ToString(), out viewers)) Viewers = viewers;
            if (int.TryParse(twitchStreamData.SelectToken("video_height").ToString(), out videoHeight)) VideoHeight = videoHeight;
            if (int.TryParse(twitchStreamData.SelectToken("delay").ToString(), out delay)) Delay = delay;
            if (double.TryParse(twitchStreamData.SelectToken("average_fps").ToString(), out averageFps)) AverageFps = averageFps;

            Game = twitchStreamData.SelectToken("game").ToString();
            CreatedAt = Common.DateTimeStringToObject(twitchStreamData.SelectToken("created_at").ToString());
            TimeSinceCreated = DateTime.UtcNow - CreatedAt;
            Channel = new Channel((JObject) twitchStreamData.SelectToken("channel"));
            Preview = new PreviewObj(twitchStreamData.SelectToken("preview"));
        }