예제 #1
0
        /// <summary>
        /// Update a label.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        protected override object Update(ExportOperation operation)
        {
            var synchronizer = MediaFrameworkContext.GetItemSynchronizer(operation.Item);

            if (synchronizer == null)
            {
                return(null);
            }

            var authenticator = new OoyalaAthenticator(operation.AccountItem);
            var context       = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            var lab = (Label)synchronizer.CreateEntity(operation.Item);

            return(context.Update <Label, Label>(
                       "update_label",
                       new Label {
                Name = lab.Name, ParentId = !string.IsNullOrEmpty(lab.ParentId) ? lab.ParentId : "root"
            },
                       new List <Parameter>
            {
                new Parameter
                {
                    Type = ParameterType.UrlSegment,
                    Name = "id",
                    Value = lab.Id
                }
            }).Data);
        }
예제 #2
0
        protected virtual void MarkAs(Item accountItem, Video video, string mark)
        {
            var authenticator = new OoyalaAthenticator(accountItem);
            var context       = new RestContext(Constants.SitecoreRestSharpService, authenticator);
            var i             = 0;

            while (i < 5)
            {
                var res = context.Update <Video, Video>(
                    "update_video_upload_status",
                    new Video {
                    Status = mark
                },
                    new List <Parameter>
                {
                    new Parameter
                    {
                        Type  = ParameterType.UrlSegment,
                        Name  = "embedcode",
                        Value = video.EmbedCode
                    }
                });

                if (res.StatusCode == HttpStatusCode.OK)
                {
                    return;
                }

                Thread.Sleep(5000);
                i++;
            }
        }
        /// <summary>
        /// Updates a player.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        protected override object Update(ExportOperation operation)
        {
            var synchronizer = MediaFrameworkContext.GetItemSynchronizer(operation.Item);

            if (synchronizer == null)
            {
                return(null);
            }

            var authenticator = new OoyalaAthenticator(operation.AccountItem);
            var context       = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            var player = (Player)synchronizer.CreateEntity(operation.Item);

            string playerId = player.Id;

            player.Id = null;

            return(context.Update <Player, Player>(
                       "update_player",
                       player,
                       new List <Parameter>
            {
                new Parameter
                {
                    Type = ParameterType.UrlSegment,
                    Name = "id",
                    Value = playerId
                }
            }).Data);
        }
        /// <summary>
        /// Updates player for an asset.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        /// <param name="assetEmbedCode">
        /// The asset embed code.
        /// </param>
        protected virtual void UpdatePlayer(ExportOperation operation, string assetEmbedCode)
        {
            var authenticator = new OoyalaAthenticator(operation.AccountItem);
            var context       = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            string playerId = this.GetPlayerId(operation.Item);

            context.Update <RestEmptyType, RestEmptyType>(
                "update_player_of_asset",
                null,
                new List <Parameter>
            {
                new Parameter
                {
                    Type  = ParameterType.UrlSegment,
                    Name  = "embedcode",
                    Value = assetEmbedCode
                },

                new Parameter
                {
                    Type  = ParameterType.UrlSegment,
                    Name  = "id",
                    Value = playerId
                }
            });
        }
예제 #5
0
        protected override void Delete(ExportOperation operation)
        {
            var synchronizer = MediaFrameworkContext.GetItemSynchronizer(operation.Item);

            if (synchronizer == null)
            {
                return;
            }

            var video = (Video)synchronizer.CreateEntity(operation.Item);

            var inactivatedVideo = new Video
            {
                Id        = video.Id,
                ItemState = ItemState.INACTIVE
            };

            var authenticator = new BrightcoveAthenticator(operation.AccountItem);

            var context = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            var updateData = new PostData("update_video", authenticator, "video", inactivatedVideo);

            var data = context.Update <PostData, ResultData <Video> >("update_data", updateData).Data;
        }
        /// <summary>
        /// Updates list of the assigned labels.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        /// <param name="assetEmbedCode">
        /// The asset embed code.
        /// </param>
        protected virtual void UpdateLabels(ExportOperation operation, string assetEmbedCode)
        {
            var authenticator = new OoyalaAthenticator(operation.AccountItem);
            var context       = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            List <string> labels = this.GetLabels(operation.Item);

            context.Update <List <string>, PagedCollection <Label> >(
                "update_labels_of_asset",
                labels,
                new List <Parameter>
            {
                new Parameter {
                    Type = ParameterType.UrlSegment, Name = "embedcode", Value = assetEmbedCode
                }
            });
        }
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="operation"></param>
        /// <returns></returns>
        protected override object Update(ExportOperation operation)
        {
            var synchronizer = MediaFrameworkContext.GetItemSynchronizer(operation.Item);

            if (synchronizer == null)
            {
                return(null);
            }

            var video = (Video)synchronizer.CreateEntity(operation.Item);

            video.ThumbnailUrl      = null;
            video.CreationDate      = null;
            video.VideoStillURL     = null;
            video.PublishedDate     = null;
            video.PlaysTrailingWeek = null;
            video.PlaysTotal        = null;
            video.LastModifiedDate  = null;
            video.Length            = null;

            if (video.CustomFields != null && video.CustomFields.Count == 0)
            {
                video.CustomFields = null;
            }

            var authenticator = new BrightcoveAthenticator(operation.AccountItem);

            var context = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            var updateData = new PostData("update_video", authenticator, "video", video);

            var data = context.Update <PostData, ResultData <Video> >("update_data", updateData).Data;

            if (data != null && data.Result != null)
            {
                if (data.Result.CustomFields == null)
                {
                    data.Result.CustomFields = video.CustomFields;
                }

                return(data.Result);
            }

            return(null);
        }
예제 #8
0
        /// <summary>
        /// Updates a video.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        protected override object Update(ExportOperation operation)
        {
            var synchronizer = MediaFrameworkContext.GetItemSynchronizer(operation.Item);

            if (synchronizer == null)
            {
                return(null);
            }

            var authenticator = new OoyalaAthenticator(operation.AccountItem);
            var context       = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            var video = (Video)synchronizer.CreateEntity(operation.Item);

            string embedCode = video.EmbedCode;

            video.EmbedCode            = null;
            video.CreatedAt            = null;
            video.UpdatedAt            = null;
            video.Duration             = null;
            video.PostProcessingStatus = null;
            video.PreviewImageUrl      = null;
            video.Status           = null;
            video.AssetType        = null;
            video.Metadata         = null;
            video.OriginalFileName = null;

            this.UpdateLabels(operation, embedCode);
            this.UpdatePlayer(operation, embedCode);
            this.UpdateMetadata(operation, embedCode);

            return(context.Update <Video, Video>(
                       "update_video",
                       video,
                       new List <Parameter>
            {
                new Parameter
                {
                    Type = ParameterType.UrlSegment,
                    Name = "embedcode",
                    Value = embedCode
                }
            }).Data);
        }
예제 #9
0
        /// <summary>
        /// Updates a lineup.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        /// <param name="channelEmbedCode">
        /// The channel Embed Code.
        /// </param>
        /// <returns>
        /// The <see cref="List"/>.
        /// </returns>
        protected virtual List <string> UpdateLineup(ExportOperation operation, string channelEmbedCode)
        {
            var authenticator = new OoyalaAthenticator(operation.AccountItem);
            var context       = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            List <string> lineup = this.GetLineup(operation.Item);

            return(context.Update <List <string>, List <string> >(
                       "update_channel_lineup",
                       lineup,
                       new List <Parameter>
            {
                new Parameter
                {
                    Type = ParameterType.UrlSegment,
                    Name = "embedcode",
                    Value = channelEmbedCode
                }
            }).Data);
        }
        /// <summary>
        /// Updates metadata for an asset.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        /// <param name="assetEmbedCode">
        /// The asset embed code.
        /// </param>
        /// <returns>
        /// The <see cref="Dictionary"/>.
        /// </returns>
        protected virtual Dictionary <string, string> UpdateMetadata(ExportOperation operation, string assetEmbedCode)
        {
            var authenticator = new OoyalaAthenticator(operation.AccountItem);
            var context       = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            Dictionary <string, string> metadata = this.GetMetadata(operation.Item);

            return(context.Update <Dictionary <string, string>, Dictionary <string, string> >(
                       "update_metadata_of_asset",
                       metadata,
                       new List <Parameter>
            {
                new Parameter
                {
                    Type = ParameterType.UrlSegment,
                    Name = "embedcode",
                    Value = assetEmbedCode
                }
            }).Data);
        }
        protected override object Update(ExportOperation operation)
        {
            var synchronizer = MediaFrameworkContext.GetItemSynchronizer(operation.Item);

            if (synchronizer == null)
            {
                return(null);
            }

            var playlist = (PlayList)synchronizer.CreateEntity(operation.Item);

            playlist.ReferenceId  = null;
            playlist.ThumbnailUrl = null;

            //Video ids used only for EXPLICIT playlist.
            //In other case will be used filter tags & tag inclusion
            if (playlist.PlaylistType == PlaylistType.EXPLICIT.ToString())
            {
                playlist.FilterTags   = null;
                playlist.TagInclusion = null;
            }
            else
            {
                playlist.VideoIds = null;
            }

            var authenticator = new BrightcoveAthenticator(operation.AccountItem);

            var updateData = new PostData("update_playlist", authenticator, "playlist", playlist);

            var context = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            var data = context.Update <PostData, ResultData <PlayList> >("update_data", updateData).Data;

            return(data != null ? data.Result : null);
        }