예제 #1
0
 public EmoticonImage(int?emoticonSet, int height, int width, string url)
 {
     this.emoticonSet = emoticonSet;
     this.height      = height;
     this.width       = width;
     this.url         = new WebUrl(url);
 }
예제 #2
0
파일: User.cs 프로젝트: Sinfire/Twixel
        /// <summary>
        /// Gets a list of channels this user is following
        /// </summary>
        /// <param name="limit">How many channels to get at one time. Default is 25. Maximum is 100</param>
        /// <returns>A list of channels</returns>
        public async Task <List <Channel> > RetrieveFollowing(int limit)
        {
            Uri uri;

            if (limit <= 100)
            {
                uri = new Uri("https://api.twitch.tv/kraken/users/" + name + "/follows/channels?limit=" + limit.ToString());
            }
            else
            {
                twixel.CreateError("You cannot get more than 100 channels at a time");
                return(null);
            }
            string responseString = await Twixel.GetWebData(uri);

            if (Twixel.GoodStatusCode(responseString))
            {
                nextFollowing = new WebUrl((string)JObject.Parse(responseString)["_links"]["next"]);
                List <Channel> followedChannels = new List <Channel>();
                foreach (JObject o in (JArray)JObject.Parse(responseString)["follows"])
                {
                    followedChannels.Add(twixel.LoadChannel((JObject)o["channel"]));
                }
                return(followedChannels);
            }
            else
            {
                twixel.CreateError(responseString);
                return(null);
            }
        }
예제 #3
0
파일: User.cs 프로젝트: Sinfire/Twixel
 internal User(Twixel twixel,
               string name,
               string logo,
               long id,
               string displayName,
               bool?staff,
               string createdAt,
               string updatedAt,
               string bio)
 {
     blockedUsers    = new List <User>();
     subscribedUsers = new List <Subscription>();
     channelEditors  = new List <User>();
     authorized      = false;
     this.name       = name;
     if (logo != null)
     {
         this.logo = new WebUrl(logo);
     }
     this.id          = id;
     this.displayName = displayName;
     if (staff != null)
     {
         this.staff = staff;
     }
     this.createdAt = DateTime.Parse(createdAt);
     this.updatedAt = DateTime.Parse(updatedAt);
     if (bio != null)
     {
         this.bio = bio;
     }
 }
예제 #4
0
파일: Team.cs 프로젝트: Sinfire/Twixel
 public Team(string info,
             string background,
             string banner,
             string name,
             long id,
             string displayName,
             string logo)
 {
     this.info = info;
     if (background != null)
     {
         this.background = new WebUrl(background);
     }
     if (banner != null)
     {
         this.banner = new WebUrl(banner);
     }
     this.name        = name;
     this.id          = id;
     this.displayName = displayName;
     if (logo != null)
     {
         this.logo = new WebUrl(logo);
     }
 }
예제 #5
0
파일: Video.cs 프로젝트: Sinfire/Twixel
 public Video(string recordedAt,
              string title,
              string url,
              string id,
              string channel,
              string embed,
              int views,
              string description,
              int length,
              string game,
              string preview)
 {
     this.recordedAt = DateTime.Parse(recordedAt);
     this.title      = title;
     this.url        = new WebUrl(url);
     this.id         = id;
     this.channel    = new WebUrl(channel);
     this.embed      = embed;
     this.views      = views;
     if (description != null)
     {
         this.description = description;
     }
     this.length = length;
     if (game != null)
     {
         this.game = game;
     }
     this.preview = new WebUrl(preview);
 }
예제 #6
0
 public Stream(string channelUrl, string broadcaster, long?id, string preview, string game, JObject channelO, string name, int?viewers, Twixel twixel)
 {
     if (channelUrl != null)
     {
         this.channelUrl = new WebUrl(channelUrl);
     }
     this.broadcaster = broadcaster;
     if (id == null)
     {
         this.id = -1;
     }
     else
     {
         this.id = id;
     }
     this.preview = new WebUrl(preview);
     this.game    = game;
     channel      = twixel.LoadChannel(channelO);
     this.name    = name;
     if (viewers == null)
     {
         this.viewers = -1;
     }
     else
     {
         this.viewers = viewers;
     }
 }
예제 #7
0
파일: User.cs 프로젝트: Sinfire/Twixel
        /// <summary>
        /// Get a list of users subscribed to this user. Requires user authorization. Requires Twitch partnership.
        /// </summary>
        /// <param name="limit">How many subscriptions to get at one time. Default is 25. Maximum is 100</param>
        /// <param name="direction">Creation date sorting direction</param>
        /// <returns>A list of subscriptions</returns>
        public async Task <List <Subscription> > RetriveSubscribers(int limit, TwitchConstants.Direction direction)
        {
            if (authorized && authorizedScopes.Contains(TwitchConstants.Scope.ChannelSubscriptions))
            {
                Uri    uri;
                string url = "https://api.twitch.tv/kraken/channels/" + name + "/subscriptions";
                if (limit <= 100)
                {
                    url += "?limit=" + limit.ToString();
                }
                else
                {
                    twixel.CreateError("You cannot fetch more than 100 subs at a time");
                    return(null);
                }

                if (direction != TwitchConstants.Direction.None)
                {
                    url += "&direction=" + TwitchConstants.DirectionToString(direction);
                }

                uri = new Uri(url);
                string responseString = await Twixel.GetWebData(uri, accessToken);

                if (responseString != "422")
                {
                    totalSubscribers = (int)JObject.Parse(responseString)["_total"];
                    nextSubs         = new WebUrl((string)JObject.Parse(responseString)["_links"]["next"]);
                    foreach (JObject o in (JArray)JObject.Parse(responseString)["subscriptions"])
                    {
                        if (!ContainsSubscriber((string)o["user"]["name"]))
                        {
                            subscribedUsers.Add(LoadSubscriber(o));
                        }
                    }
                    return(subscribedUsers);
                }
                else
                {
                    twixel.CreateError("You aren't partnered so you cannot have subs");
                    return(null);
                }
            }
            else
            {
                if (!authorized)
                {
                    twixel.CreateError(name + " is not authorized");
                }
                else if (!authorizedScopes.Contains(TwitchConstants.Scope.ChannelSubscriptions))
                {
                    twixel.CreateError(name + " has not given channel_subscriptions permissions");
                }
                return(null);
            }
        }
예제 #8
0
 public Ingest(string name,
               bool defaultIngest,
               long id,
               string urlTemplate,
               double avalibility)
 {
     this.name          = name;
     this.defaultIngest = defaultIngest;
     this.id            = id;
     this.urlTemplate   = new WebUrl(urlTemplate);
     this.avalibility   = avalibility;
 }
예제 #9
0
 // Also a little note Twitch NEVER uses this...
 void LoadImages(JObject o)
 {
     if (o != null)
     {
         imagesThumb  = new WebUrl((string)o["thumb"]);
         imagesTiny   = new WebUrl((string)o["tiny"]);
         imagesSmall  = new WebUrl((string)o["small"]);
         imagesSuper  = new WebUrl((string)o["super"]);
         imagesMedium = new WebUrl((string)o["medium"]);
         imagesIcon   = new WebUrl((string)o["icon"]);
         imagesScreen = new WebUrl((string)o["screen"]);
     }
 }
예제 #10
0
파일: Game.cs 프로젝트: Sinfire/Twixel
 public Game(string name, JObject boxO, JObject logoO, long?id, long?giantBombId, int?viewers, int?channels)
 {
     this.name        = name;
     boxLarge         = new WebUrl((string)boxO["large"]);
     boxMedium        = new WebUrl((string)boxO["medium"]);
     boxSmall         = new WebUrl((string)boxO["small"]);
     boxTemplate      = new WebUrl((string)boxO["template"]);
     logoLarge        = new WebUrl((string)logoO["large"]);
     logoMedium       = new WebUrl((string)logoO["medium"]);
     logoSmall        = new WebUrl((string)logoO["small"]);
     logoTemplate     = new WebUrl((string)logoO["template"]);
     this.id          = id;
     this.giantBombId = giantBombId;
     this.viewers     = viewers;
     this.channels    = channels;
 }
예제 #11
0
파일: User.cs 프로젝트: Sinfire/Twixel
 internal User(Twixel twixel,
               string accessToken,
               List <TwitchConstants.Scope> authorizedScopes,
               string name,
               string logo,
               long id,
               string displayName,
               string email,
               bool?staff,
               bool?partnered,
               string createdAt,
               string updatedAt,
               string bio)
 {
     this.twixel           = twixel;
     blockedUsers          = new List <User>();
     subscribedUsers       = new List <Subscription>();
     channelEditors        = new List <User>();
     authorized            = true;
     this.accessToken      = accessToken;
     this.authorizedScopes = authorizedScopes;
     this.name             = name;
     if (logo != null)
     {
         this.logo = new WebUrl(logo);
     }
     this.id          = id;
     this.displayName = displayName;
     if (email != null)
     {
         this.email = email;
     }
     if (staff != null)
     {
         this.staff = staff;
     }
     if (partnered != null)
     {
         this.partnered = partnered;
     }
     this.createdAt = DateTime.Parse(createdAt);
     this.updatedAt = DateTime.Parse(updatedAt);
     if (bio != null)
     {
         this.bio = bio;
     }
 }
예제 #12
0
파일: User.cs 프로젝트: Sinfire/Twixel
        /// <summary>
        /// Gets a list of users subscribed to this user. Requires user authorization. Requires Twitch partnership.
        /// </summary>
        /// <param name="getNext">If this method was called before then this will get the next page of subscriptions</param>
        /// <returns>A list of subscriptions</returns>
        public async Task <List <Subscription> > RetriveSubscribers(bool getNext)
        {
            if (authorized && authorizedScopes.Contains(TwitchConstants.Scope.ChannelSubscriptions))
            {
                Uri uri;
                uri = new Uri("https://api.twitch.tv/kraken/channels/" + name + "/subscriptions");
                string responseString = await Twixel.GetWebData(uri, accessToken);

                if (responseString != "422")
                {
                    totalSubscribers = (int)JObject.Parse(responseString)["_total"];
                    nextSubs         = new WebUrl((string)JObject.Parse(responseString)["_links"]["next"]);
                    foreach (JObject o in (JArray)JObject.Parse(responseString)["subscriptions"])
                    {
                        if (!ContainsSubscriber((string)o["user"]["name"]))
                        {
                            subscribedUsers.Add(LoadSubscriber(o));
                        }
                    }
                    return(subscribedUsers);
                }
                else
                {
                    twixel.CreateError("You aren't partnered so you cannot have subs");
                    return(null);
                }
            }
            else
            {
                if (!authorized)
                {
                    twixel.CreateError(name + " is not authorized");
                }
                else if (!authorizedScopes.Contains(TwitchConstants.Scope.ChannelSubscriptions))
                {
                    twixel.CreateError(name + " has not given channel_subscriptions permissions");
                }
                return(null);
            }
        }
예제 #13
0
파일: User.cs 프로젝트: Sinfire/Twixel
        /// <summary>
        /// Gets a list of channels this user is following
        /// </summary>
        /// <param name="getNext">If this method was called before then this will get the next page of channels</param>
        /// <returns>A list of channels</returns>
        public async Task <List <Channel> > RetrieveFollowing(bool getNext)
        {
            Uri uri;

            if (!getNext)
            {
                uri = new Uri("https://api.twitch.tv/kraken/users/" + name + "/follows/channels");
            }
            else
            {
                if (nextFollowing != null)
                {
                    uri = nextFollowing.url;
                }
                else
                {
                    uri = new Uri("https://api.twitch.tv/kraken/users/" + name + "/follows/channels");
                }
            }
            string responseString = await Twixel.GetWebData(uri);

            if (Twixel.GoodStatusCode(responseString))
            {
                nextFollowing = new WebUrl((string)JObject.Parse(responseString)["_links"]["next"]);
                List <Channel> followedChannels = new List <Channel>();
                foreach (JObject o in (JArray)JObject.Parse(responseString)["follows"])
                {
                    followedChannels.Add(twixel.LoadChannel((JObject)o["channel"]));
                }
                return(followedChannels);
            }
            else
            {
                twixel.CreateError(responseString);
                return(null);
            }
        }
예제 #14
0
 public Channel(string mature,
                string background,
                string updatedAt,
                long id,
                JArray teamsA,
                string status,
                string logo,
                string url,
                string displayName,
                string game,
                string banner,
                string name,
                string videoBanner,
                string chat,
                string subscriptions,
                string features,
                string commercial,
                string streamKey,
                string editors,
                string videos,
                string self,
                string follows,
                string createdAt,
                string profileBanner,
                string primaryTeamName,
                string primaryTeamDisplayName,
                long?views,
                long?followers,
                Twixel twixel)
 {
     teams = new List <Team>();
     if (teamsA != null)
     {
         foreach (JObject team in teamsA)
         {
             teams.Add(twixel.LoadTeam(team));
         }
     }
     this.mature = mature;
     if (background != null)
     {
         this.background = new WebUrl(background);
     }
     this.updatedAt = updatedAt;
     this.id        = id;
     this.status    = status;
     if (logo != null)
     {
         this.logo = new WebUrl(logo);
     }
     this.url         = new WebUrl(url);
     this.displayName = displayName;
     this.game        = game;
     if (banner != null)
     {
         this.banner = new WebUrl(banner);
     }
     this.name = name;
     if (videoBanner != null)
     {
         this.videoBanner = new WebUrl(videoBanner);
     }
     this.chat          = new WebUrl(chat);
     this.subscriptions = new WebUrl(subscriptions);
     this.features      = new WebUrl(features);
     this.commercial    = new WebUrl(commercial);
     this.streamKey     = new WebUrl(streamKey);
     this.editors       = new WebUrl(editors);
     this.videos        = new WebUrl(videos);
     this.self          = new WebUrl(self);
     this.follows       = new WebUrl(follows);
     this.createdAt     = createdAt;
     if (profileBanner != null)
     {
         this.profileBanner = new WebUrl(profileBanner);
     }
     if (primaryTeamName != null)
     {
         this.primaryTeamName = primaryTeamName;
     }
     if (primaryTeamDisplayName != null)
     {
         this.primaryTeamDisplayName = primaryTeamDisplayName;
     }
     this.views     = views;
     this.followers = followers;
 }
예제 #15
0
 public FeaturedStream(string channelUrl, string image, string text, JObject streamO, Twixel twixel)
 {
     this.image  = new WebUrl(image);
     this.text   = text;
     this.stream = twixel.LoadStream(streamO, channelUrl);
 }