예제 #1
0
 /// <summary>タグを追加するストリームを取得する</summary>
 /// <param name="AddItem">追加するタグ</param>
 /// <param name="IsGetToken">トークンを取得するかどうか</param>
 public Streams<TagResponse> OpenAddTagStreams(Tag AddItem, bool IsGetToken = true)
 {
     return OpenEditTagStreams(AddItem, PostTexts.AddVideoTag, IsGetToken);
 }
예제 #2
0
 /// <summary>タグを追加する</summary>
 /// <param name="AddItem">追加するタグ</param>
 /// <param name="IsGetToken">トークンを取得するかどうか</param>
 public TagResponse AddTag(Tag AddItem, bool IsGetToken = true)
 {
     var streams = OpenEditTagStreams(AddItem, PostTexts.AddVideoTag, IsGetToken);
     return streams.Run(streams.UntreatedCount);
 }
예제 #3
0
 /// <summary>タグを削除する</summary>
 /// <param name="RemoveItem">削除するタグ</param>
 /// <param name="IsGetToken">トークンを取得するかどうか</param>
 public TagResponse RemoveTag(Tag RemoveItem, bool IsGetToken = true)
 {
     var streams = OpenEditTagStreams(RemoveItem, PostTexts.RemoveVideoTag, IsGetToken);
     return streams.Run(streams.UntreatedCount);
 }
예제 #4
0
        private Streams<TagResponse> OpenEditTagStreams(Tag Tag, string PostText, bool IsGetToken)
        {
            var videoPageStreamData = OpenVideoPageStreamData();
            var streamDataList = new List<StreamData>();
            TagResponse result = null;

            if (videoPageStreamData != null)
                streamDataList.Add(videoPageStreamData);

            var uploadStreamData = context.Client.OpenUploadStreams(
                string.Format(ApiUrls.EditVideoTag, target.ID),
                ContentType.Form).GetStreamDatas();

            uploadStreamData[0].GetWriteData = () =>
            {
                if (IsGetToken)
                    host.token = HtmlTextRegex.VideoTagToken.Match(htmlCache).Groups["value"].Value;

                if (watchAuthKey == null)
                    watchAuthKey = HtmlTextRegex.WatchAuthKey.Match(htmlCache).Groups["value"].Value;

                return Encoding.UTF8.GetBytes(
                    string.Format(
                        PostText,
                        Tag.Name,
                        host.token,
                        watchAuthKey,
                        (Tag.IsLock == true) ? "1" : "0"));
            };
            uploadStreamData[1].SetReadData = (data) =>
            {
                var serialize = new DataContractJsonSerializer(typeof(Serial.EditTag.Contract));
                result = converter.ConvertTagResponse(
                    (Serial.EditTag.Contract)serialize.ReadObject(new MemoryStream(data)));
                target.Tags = result.Tags;
            };
            streamDataList.AddRange(uploadStreamData);

            return new Streams<TagResponse>(
                streamDataList.ToArray(),
                () => result);
        }
예제 #5
0
 /// <summary>タグを削除するストリームを取得する</summary>
 /// <param name="RemoveItem">削除するタグ</param>
 /// <param name="IsGetToken">トークンを取得するかどうか</param>
 public Streams<TagResponse> OpenRemoveTagStreams(Tag RemoveItem, bool IsGetToken = true)
 {
     return OpenEditTagStreams(RemoveItem, PostTexts.RemoveVideoTag, IsGetToken);
 }