Exemplo n.º 1
0
            private async Task <Models.API.v5.UploadVideo.UploadVideoListing> createVideoAsync(string channelId, string title, string description = null, string game = null, string language = "en", string tagList = "", Enums.Viewable viewable = Enums.Viewable.Public, DateTime?viewableAt = null, string accessToken = null)
            {
                List <KeyValuePair <string, string> > getParams = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("channel_id", channelId), new KeyValuePair <string, string>("title", title)
                };

                if (description != null)
                {
                    getParams.Add(new KeyValuePair <string, string>("description", description));
                }
                if (game != null)
                {
                    getParams.Add(new KeyValuePair <string, string>("game", game));
                }
                if (language != null)
                {
                    getParams.Add(new KeyValuePair <string, string>("language", language));
                }
                if (tagList != null)
                {
                    getParams.Add(new KeyValuePair <string, string>("tag_list", tagList));
                }
                if (viewable == Enums.Viewable.Public)
                {
                    getParams.Add(new KeyValuePair <string, string>("viewable", "public"));
                }
                else
                {
                    getParams.Add(new KeyValuePair <string, string>("viewable", "private"));
                }
                //TODO: Create RFC3339 date out of viewableAt
                return(await Api.PostGenericAsync <Models.API.v5.UploadVideo.UploadVideoListing>($"https://api.twitch.tv/kraken/videos", null, getParams, accessToken));
            }
Exemplo n.º 2
0
            public async Task <Models.API.v5.UploadVideo.UploadedVideo> UploadVideoAsync(string channelId, string videoPath, string title, string description, string game, string language = "en", string tagList = "", Enums.Viewable viewable = Enums.Viewable.Public, System.DateTime?viewableAt = null, string accessToken = null)
            {
                Api.Settings.DynamicScopeValidation(Enums.AuthScopes.Channel_Editor, accessToken);
                var listing = await createVideoAsync(channelId, title, description, game, language, tagList, viewable, viewableAt);

                uploadVideoParts(videoPath, listing.Upload);
                await completeVideoUpload(listing.Upload, accessToken);

                return(listing.Video);
            }