Beispiel #1
0
        /// <summary>
        /// Deletes a video.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        protected override void Delete(ExportOperation operation)
        {
            var synchronizer = MediaFrameworkContext.GetItemSynchronizer(operation.Item);

            if (synchronizer == null)
            {
                return;
            }

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

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

            context.Delete <Video, RestEmptyType>(
                "delete_video",
                parameters:
                new List <Parameter>
            {
                new Parameter
                {
                    Name  = "embedcode",
                    Type  = ParameterType.UrlSegment,
                    Value = video.EmbedCode
                }
            });
        }
Beispiel #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++;
            }
        }
Beispiel #3
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);
        }
        /// <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);
        }
Beispiel #5
0
        protected virtual Video CreateVideo(Item accountItem, VideoToUpload video)
        {
            var authenticator = new OoyalaAthenticator(accountItem);
            var context       = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            return(context.Create <VideoToUpload, Video>("upload_video_create", video).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
                }
            });
        }
Beispiel #7
0
        /// <summary>
        /// Creates a channel.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        protected override object Create(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 channel = (Channel)synchronizer.CreateEntity(operation.Item);

            channel.EmbedCode            = null;
            channel.CreatedAt            = null;
            channel.UpdatedAt            = null;
            channel.Duration             = null;
            channel.PostProcessingStatus = null;
            channel.Metadata             = null;
            channel.PreviewImageUrl      = null;
            channel.Status = null;

            var createdChannel = context.Create <Channel, Channel>("create_channel", channel).Data;

            this.UpdateLineup(operation, createdChannel.EmbedCode);
            this.UpdateLabels(operation, createdChannel.EmbedCode);
            this.UpdatePlayer(operation, createdChannel.EmbedCode);
            this.UpdateMetadata(operation, createdChannel.EmbedCode);

            return(createdChannel);
        }
Beispiel #8
0
        /// <summary>
        /// Deletes a label.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        protected override void Delete(ExportOperation operation)
        {
            var synchronizer = MediaFrameworkContext.GetItemSynchronizer(operation.Item);

            if (synchronizer == null)
            {
                return;
            }

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

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

            context.Delete <Label, RestEmptyType>(
                "delete_label",
                parameters:
                new List <Parameter>
            {
                new Parameter
                {
                    Type  = ParameterType.UrlSegment,
                    Name  = "id",
                    Value = label.Id
                }
            });
        }
        /// <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
                }
            });
        }
Beispiel #10
0
        protected virtual List <string> GetUploadingUrls(Item accountItem, Video video)
        {
            var authenticator = new OoyalaAthenticator(accountItem);
            var context       = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            return(context.Read <List <string> >(
                       "get_uploading_URLs",
                       new List <Parameter>
            {
                new Parameter
                {
                    Type = ParameterType.UrlSegment,
                    Name = "embedcode",
                    Value = video.EmbedCode
                }
            }).Data);
        }
Beispiel #11
0
        protected virtual void DeleteVideo(Item accountItem, Video video)
        {
            var authenticator = new OoyalaAthenticator(accountItem);
            var context       = new RestContext(Constants.SitecoreRestSharpService, authenticator);

            context.Delete <Video, RestEmptyType>(
                "delete_video",
                parameters:
                new List <Parameter>
            {
                new Parameter
                {
                    Name  = "embedcode",
                    Type  = ParameterType.UrlSegment,
                    Value = video.EmbedCode
                }
            });
        }
Beispiel #12
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);
        }
        /// <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);
        }
        /// <summary>
        /// Creates a player.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        protected override object Create(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);

            player.Id        = null;
            player.IsDefault = false;

            return(context.Create <Player, Player>("create_player", player).Data);
        }
Beispiel #15
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);
        }
Beispiel #16
0
        /// <summary>
        /// Creates a label.
        /// </summary>
        /// <param name="operation">
        /// The operation.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        protected override object Create(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 label = (Label)synchronizer.CreateEntity(operation.Item);

            return(context.Create <Label, Label>(
                       "create_label",
                       new Label
            {
                Name = label.Name,
                ParentId = !string.IsNullOrEmpty(label.ParentId) ? label.ParentId : "root"
            }).Data);
        }
Beispiel #17
0
        public virtual IEnumerable <object> GetData(Item accountItem)
        {
            var authenticator = new OoyalaAthenticator(accountItem);

            return(this.GetWithPaging(authenticator));
        }