/// <summary>
        ///
        /// </summary>
        /// <param name="videoId"></param>
        /// <param name="reference_id"></param>
        /// <returns></returns>
        private RPCResponse <BCVideo> RemoveLogoOverlay(long video_id, string video_reference_id)
        {
            // Generate post objects
            Dictionary <string, object> postParams = new Dictionary <string, object>();

            //add video to the post params
            RPCRequest rpc = new RPCRequest();

            rpc.method = "remove_logo_overlay";
            if (video_id > -1)
            {
                rpc.parameters += ",\"video_id\": \"" + video_id.ToString() + "\"";
            }
            else if (video_reference_id != null)
            {
                rpc.parameters += ",\"video_reference_id\": \"" + video_reference_id + "\"";
            }
            rpc.parameters += ", \"token\": \"" + Account.WriteToken.Value + "\"";
            postParams.Add("json", rpc.ToJSON());

            //Get the JSon reader returned from the APIRequest
            RPCResponse <BCVideo> rpcr = BCAPIRequest.ExecuteWrite <BCVideo>(postParams, Account);

            return(rpcr);
        }
Example #2
0
        /// <summary>
        /// Retrieve a playlist based on its publisher-assigned reference id.
        /// </summary>
        /// <param name="reference_id">
        /// The reference id of the playlist we'd like to retrieve.
        /// </param>
        /// <param name="video_fields">
        /// A comma-separated list of the fields you wish to have populated in the videos contained in the returned object. Passing null populates with all fields. (defaults to all)
        /// </param>
        /// <param name="custom_fields">
        /// A comma-separated list of the custom fields you wish to have populated in the videos contained in the returned object. Passing null populates with all fields. (defaults to all)
        /// </param>
        /// <param name="playlist_fields">
        /// A comma-separated list of the fields you wish to have populated in the playlists contained in the returned object. Passing null populates with all fields.
        /// </param>
        /// <returns>
        /// Returns a BCPlaylist item
        /// </returns>
        public BCPlaylist FindPlaylistByReferenceId(string reference_id, List <VideoFields> video_fields, List <string> custom_fields, List <PlaylistFields> playlist_fields, MediaDeliveryTypeEnum media_delivery)
        {
            Dictionary <String, String> reqparams = new Dictionary <string, string>();

            //Build the REST parameter list
            reqparams.Add("command", "find_playlist_by_reference_id");
            reqparams.Add("reference_id", reference_id);
            reqparams.Add("media_delivery", media_delivery.ToString());
            if (playlist_fields != null)
            {
                reqparams.Add("playlist_fields", playlist_fields.ToFieldString());
            }
            if (video_fields != null)
            {
                reqparams.Add("video_fields", video_fields.ToFieldString());
            }
            if (custom_fields != null)
            {
                reqparams.Add("custom_fields", Implode(custom_fields));
            }

            //Get the JSon reader returned from the APIRequest
            string jsonStr = BCAPIRequest.ExecuteRead(reqparams, Account).JsonResult;

            return(JSON.Converter.Deserialize <BCPlaylist>(jsonStr));
        }
        /// <summary>
        /// Shares the specified video with a list of sharee accounts
        /// </summary>
        /// <param name="video_id">
        /// The id of the video whose status you'd like to get.
        /// </param>
        /// <param name="auto_accept">
        /// If the target account has the option enabled, setting this flag to true will bypass
        /// the approval process, causing the shared video to automatically appear in the target
        /// account's library. If the target account does not have the option enabled, or this
        /// flag is unspecified or false, then the shared video will be queued up to be approved
        /// by the target account before appearing in their library.
        /// defaults to false
        /// </param>
        /// <param name="sharee_account_ids">
        /// List of Account IDs to share video with.
        /// </param>
        /// <returns></returns>
        public RPCResponse <BCCollection <long> > ShareVideo(long video_id, bool auto_accept, List <long> sharee_account_ids)
        {
            // Generate post objects
            Dictionary <string, object> postParams = new Dictionary <string, object>();

            //add video to the post params
            RPCRequest rpc = new RPCRequest();

            rpc.method      = "share_video";
            rpc.parameters  = "\"video_id\": " + video_id;
            rpc.parameters += ", \"auto_accept\": " + auto_accept.ToString().ToLower();
            rpc.parameters += ", \"sharee_account_ids\": [";
            for (int i = 0; i < sharee_account_ids.Count; i++)
            {
                if (i > 0)
                {
                    rpc.parameters += ", ";
                }
                rpc.parameters += "\"" + sharee_account_ids[i].ToString() + "\"";
            }
            rpc.parameters += "]";
            rpc.parameters += ", \"token\": \"" + Account.WriteToken.Value + "\"";
            postParams.Add("json", rpc.ToJSON());

            //Get the JSon reader returned from the APIRequest
            RPCResponse <BCCollection <long> > rpcr = BCAPIRequest.ExecuteWrite <BCCollection <long> >(postParams, Account);

            return(rpcr);
        }
        /// <summary>
        /// Deletes a video.
        /// </summary>
        /// <param name="video_id">
        /// The id of the video you'd like to delete
        /// </param>
        /// <param name="reference_id">
        /// The publisher-assigned reference id of the video you'd like to delete.
        /// </param>
        /// <param name="cascade">
        /// Set this to true if you want to delete this video even if it is part of a
        /// manual playlist or assigned to a player. The video will be removed from
        /// all playlists and players in which it appears, then deleted.
        /// defaults to true
        /// </param>
        /// <param name="delete_shares">
        /// Set this to true if you want also to delete shared copies of this video.
        /// Note that this will delete all shared copies from sharee accounts, regardless
        /// of whether or not those accounts are currently using the video in playlists or players.
        /// defaults to true
        /// </param>
        private RPCResponse DeleteVideo(long video_id, string reference_id, bool cascade, bool delete_shares)
        {
            // Generate post objects
            Dictionary <string, object> postParams = new Dictionary <string, object>();

            //add video to the post params
            RPCRequest rpc = new RPCRequest();

            rpc.method = "delete_video";
            if (video_id > -1)
            {
                rpc.parameters = "\"video_id\": " + video_id.ToString();
            }
            else if (reference_id != null)
            {
                rpc.parameters = "\"reference_id\": \"" + reference_id.ToString() + "\"";
            }
            rpc.parameters += ", \"token\": \"" + Account.WriteToken.Value + "\"";
            rpc.parameters += ", \"cascade\": " + cascade.ToString().ToLower();
            rpc.parameters += ", \"delete_shares\": " + delete_shares.ToString().ToLower();
            postParams.Add("json", rpc.ToJSON());

            //Get the JSon reader returned from the APIRequest
            RPCResponse rpcr = BCAPIRequest.ExecuteWrite(postParams, Account);

            return(rpcr);
        }
        private RPCResponse DeleteCaptioning(long video_id, string video_reference_id)
        {
            Dictionary <string, object> postParams = new Dictionary <string, object>();

            Builder builder = new Builder()
                              .AppendField("token", Account.WriteToken.Value);

            // Either a video_id or video_reference_id is required
            if (video_id > 0)
            {
                builder.Append(",").AppendField("video_id", video_id);
            }
            else if (!string.IsNullOrEmpty(video_reference_id))
            {
                builder.Append(",").AppendField("video_reference_id", video_reference_id);
            }
            else
            {
                throw new System.ArgumentException("A video_id or video_reference_id is required for delete_captioning");
            }

            RPCRequest rpc = new RPCRequest();

            rpc.method     = "delete_captioning";
            rpc.parameters = builder.ToString();
            postParams.Add("json", rpc.ToJSON());

            // Get the JSon reader returned from the APIRequest
            RPCResponse rpcr = BCAPIRequest.ExecuteWrite(postParams, this.Account);

            return(rpcr);
        }
Example #6
0
        private static void MakeRequest(BCQueryResult qr, Dictionary <string, string> reqparams, BCObjectType itemType, BCAccount account)
        {
            QueryResultPair qrp = BCAPIRequest.ExecuteRead(reqparams, account);

            qrp.JsonResult = qrp.JsonResult.Replace("\"items\":", "\"" + itemType.ToString() + "\":");
            qr.QueryResults.Add(qrp);
            qr.Merge(JSON.Converter.Deserialize <BCQueryResult>(qrp.JsonResult));
        }
        /// <summary>
        /// Adds a Captioning to an existing video
        /// http://docs.brightcove.com/en/media/reference.html#Video_Write
        /// The captions can either be uploaded to BC or be referred to by an external url
        /// BrightCove supports the DFXP and SMPTE-TT formats
        /// http://support.brightcove.com/en/docs/using-captions-smart-player-api
        /// </summary>
        /// <param name="caption_source">Metadata about the captions</param>
        /// <param name="options">Parameters (options) including the ID of the video that MUST be set</param>
        /// <param name="captions">a buffer containing DFXP or SMPTE-TT caption data</param>
        /// <returns>the captionSources object</returns>
        public RPCResponse <BCCaptionSources> AddCaptioning(BCCaptionSource caption_source, BCAddCaptioningOptions options, byte[] captions)
        {
            Dictionary <string, object> postParams = new Dictionary <string, object>();

            Builder builder = new Builder()
                              .AppendObject("caption_source", caption_source.ToJSON(JSONType.Create))
                              .Append(",").AppendField("token", Account.WriteToken.Value);

            if (!string.IsNullOrEmpty(options.filename))
            {
                builder.Append(",").AppendField("filename", options.filename);
            }

            if (options.maxsize > 0)
            {
                builder.Append(",").AppendField("maxsize", options.maxsize);
            }

            if (!string.IsNullOrEmpty(options.file))
            {
                throw new System.ArgumentException("The file property not supported.  Pass the captions in as a byte array.");
            }

            if (!string.IsNullOrEmpty(options.file_checksum))
            {
                builder.Append(",").AppendField("file_checksum", options.file_checksum);
            }

            // Either a video_id or video_reference_id is required
            if (options.video_id > 0)
            {
                builder.Append(",").AppendField("video_id", options.video_id);
            }
            else if (!string.IsNullOrEmpty(options.video_reference_id))
            {
                builder.Append(",").AppendField("video_reference_id", options.video_reference_id);
            }
            else
            {
                throw new System.ArgumentException("A video_id or video_reference_id is required for add_captioning");
            }

            RPCRequest rpc = new RPCRequest();

            rpc.method     = "add_captioning";
            rpc.parameters = builder.ToString();
            postParams.Add("json", rpc.ToJSON());

            postParams.Add("file", new UploadBufferParameter(captions, "captions.dfxp"));

            // Get the JSon reader returned from the APIRequest
            // RPCResponse<BCCaptionSources> rpcr = BCAPIRequest.ExecuteWriteFile<BCCaptionSources>(postParams, this.Account, @"C:\dev\svn\BrightCove\TestFormApp\sample_captions.dfxp");
            RPCResponse <BCCaptionSources> rpcr = BCAPIRequest.ExecuteWriteNew <BCCaptionSources>(postParams, this.Account);

            return(rpcr);
        }
        /// <summary>
        /// Call this function in an HTTP POST request to determine the status of an upload.
        /// </summary>
        /// <param name="video_id">
        /// The id of the video whose status you'd like to get.
        /// </param>
        /// <param name="reference_id">
        /// The publisher-assigned reference id of the video whose status you'd like to get.
        /// </param>
        /// <returns>
        /// an UploadStatusEnum that specifies the current state of the upload.
        /// </returns>
        private RPCResponse <UploadStatusEnum> GetUploadStatus(long video_id, string reference_id)
        {
            // Generate post objects
            Dictionary <string, object> postParams = new Dictionary <string, object>();

            //add video to the post params
            RPCRequest rpc = new RPCRequest();

            rpc.method = "get_upload_status";
            if (video_id > -1)
            {
                rpc.parameters = "\"video_id\": " + video_id.ToString();
            }
            else if (reference_id != null)
            {
                rpc.parameters = "\"reference_id\": " + video_id.ToString();
            }
            rpc.parameters += " ,\"token\": \"" + Account.WriteToken.Value + "\"";

            postParams.Add("json", rpc.ToJSON());

            //Get the JSon reader returned from the APIRequest
            RPCResponse rpcr = BCAPIRequest.ExecuteWrite(postParams, Account);
            RPCResponse <UploadStatusEnum> rpcr2 = new RPCResponse <UploadStatusEnum>();

            rpcr2.error = rpcr.error;
            rpcr2.id    = rpcr.id;

            switch (rpcr.result)
            {
            case "COMPLETE":
                rpcr2.result = UploadStatusEnum.COMPLETE;
                break;

            case "ERROR":
                rpcr2.result = UploadStatusEnum.ERROR;
                break;

            case "PROCESSING":
                rpcr2.result = UploadStatusEnum.PROCESSING;
                break;

            case "UPLOADING":
                rpcr2.result = UploadStatusEnum.UPLOADING;
                break;

            default:
                rpcr2.result = UploadStatusEnum.UNDEFINED;
                break;
            }
            return(rpcr2);
        }
        /// <summary>
        /// Upload a file to your Brightcove account
        /// </summary>
        /// <param name="video">
        /// The metadata for the video you'd like to create. This takes the form of a
        /// JSON object of name/value pairs, each of which corresponds to a settable
        /// property of the Video object.
        /// </param>
        /// <param name="filename">
        /// The name of the file that's being uploaded. You don't need to specify this in
        /// the JSON if it is specified in the file part of the POST.
        /// </param>
        /// <param name="file">
        /// A byte array of the video file you're uploading. This takes the
        /// form of a file part, in a multipart/form-data HTTP request. This input stream and
        /// the filename and maxSide parameters are automatically inferred from that file part.
        /// </param>
        /// <param name="encode_to">
        /// If the file requires transcoding, use this parameter to specify the target encoding. Valid
        /// values are MP4 or FLV, representing the H264 and VP6 codecs respectively. Note that transcoding
        /// of FLV files to another codec is not currently supported. This parameter is optional and defaults to FLV.
        /// </param>
        /// <param name="create_multiple_renditions">
        /// If the file is a supported transcodeable type, this optional flag can be used to control the
        /// number of transcoded renditions. If true (default), multiple renditions at varying encoding
        /// rates and dimensions are created. Setting this to false will cause a single transcoded VP6
        /// rendition to be created at the standard encoding rate and dimensions.
        /// </param>
        /// <param name="H264NoProcessing">
        /// If the video file is H.264 encoded and if create_multiple_ renditions=true, then multiple
        /// VP6 renditions are created and in addition the H.264 source is retained as an additional rendition.
        /// </param>
        /// <param name="preserve_source_rendition">
        /// Use this option to prevent H.264 source files from being transcoded. This parameter cannot be
        /// used in combination with create_multiple_renditions. It is optional and defaults to false.
        /// </param>
        /// <param name="maxsize">
        /// The maximum size that the file will be. This is used as a limiter to know when
        /// something has gone wrong with the upload. The maxSize is same as the file you uploaded.
        /// You don't need to specify this in the JSON if it is specified in the file part of the POST.
        /// </param>
        /// <param name="file_checksum">
        /// An optional MD5 hash of the file. The checksum can be used to verify that the file checked
        /// into your Brightcove Media Library is the same as the file you uploaded.
        /// </param>
        /// <returns>
        /// The id of the video that's been created. if null or error returns -1
        /// </returns>
        private RPCResponse <long> CreateVideo(BCVideo video, string filename, byte[] file, BCEncodeType encode_to, bool create_multiple_renditions, bool H264NoProcessing, bool preserve_source_rendition, long maxsize, string file_checksum)
        {
            // Generate post objects
            Dictionary <string, object> postParams = new Dictionary <string, object>();

            //add video to the post params
            RPCRequest rpc = new RPCRequest();

            rpc.method     = "create_video";
            rpc.parameters = "\"video\": " + video.ToCreateJSON() + ", \"token\": \"" + Account.WriteToken.Value + "\"";
            if (maxsize > -1)
            {
                rpc.parameters += ", \"maxsize\": " + maxsize.ToString();
            }
            if (file_checksum != null)
            {
                rpc.parameters += ", \"file_checksum\": \"" + file_checksum + "\"";
            }
            rpc.parameters += ", \"filename\": \"" + filename + "\"";
            if (!encode_to.Equals(BCEncodeType.UNDEFINED))
            {
                rpc.parameters += ", \"encode_to\": " + encode_to.ToString();
            }
            rpc.parameters += ", \"create_multiple_renditions\": " + create_multiple_renditions.ToString().ToLower();
            rpc.parameters += ", \"H264NoProcessing\": " + H264NoProcessing.ToString().ToLower();
            rpc.parameters += ", \"preserve_source_rendition\": " + preserve_source_rendition.ToString().ToLower();
            postParams.Add("json", rpc.ToJSON());

            //add the file to the post
            postParams.Add("file", new FileParameter(file, filename));

            //Get the JSon reader returned from the APIRequest
            RPCResponse        rpcr  = BCAPIRequest.ExecuteWrite(postParams, this.Account);
            RPCResponse <long> rpcr2 = new RPCResponse <long>();

            rpcr2.error = rpcr.error;
            rpcr2.id    = rpcr.id;
            if (!string.IsNullOrEmpty(rpcr.result))
            {
                rpcr2.result = long.Parse(rpcr.result);
            }
            else
            {
                rpcr2.result = -1;
            }

            return(rpcr2);
        }
        /// <summary>
        /// Updates the video you specify
        /// </summary>
        /// <param name="video">
        /// The metadata for the video you'd like to update. This takes the form of a JSON object of name/value pairs, each of which corresponds to a settable property of the Video object.
        /// </param>
        /// <returns></returns>
        public RPCResponse <BCVideo> UpdateVideo(BCVideo video)
        {
            // Generate post objects
            Dictionary <string, object> postParams = new Dictionary <string, object>();

            //add video to the post params
            RPCRequest rpc = new RPCRequest();

            rpc.method     = "update_video";
            rpc.parameters = "\"video\": " + video.ToJSON() + " ,\"token\": \"" + Account.WriteToken.Value + "\"";
            postParams.Add("json", rpc.ToJSON());

            //Get the JSon reader returned from the APIRequest
            RPCResponse <BCVideo> rpcr = BCAPIRequest.ExecuteWrite <BCVideo>(postParams, Account);

            return(rpcr);
        }
        /// <summary>
        /// Creates a playlist. This method must be called using an HTTP POST request and JSON parameters.
        /// </summary>
        /// <param name="playlist">
        /// The metadata for the playlist you'd like to create. This takes the form of a JSON object of
        /// name/value pairs, each of which corresponds to a settable property of the Playlist object.
        /// Populate the videoIds property of the playlist, not the videos property.
        /// </param>
        /// <returns>
        /// The ID of the Playlist you created.
        /// </returns>
        public RPCResponse <long> CreatePlaylist(BCPlaylist playlist)
        {
            // Generate post objects
            Dictionary <string, object> postParams = new Dictionary <string, object>();

            //add video to the post params
            RPCRequest rpc = new RPCRequest();

            rpc.method     = "create_playlist";
            rpc.parameters = "\"playlist\": " + playlist.ToCreateJSON() + " ,\"token\": \"" + Account.WriteToken.Value + "\"";
            postParams.Add("json", rpc.ToJSON());

            //Get the JSon reader returned from the APIRequest
            RPCResponse <long> rpcr = BCAPIRequest.ExecuteWrite <long>(postParams, Account);

            return(rpcr);
        }
Example #12
0
        /// <summary>
        /// Add a new thumbnail or video still image to a video, or assign an existing image to another video.
        /// </summary>
        /// <param name="image">
        /// The metadata for the image you'd like to create (or update). This takes the form of a
        /// JSON object of name/value pairs, each of which corresponds to a property of the Image object.
        /// </param>
        /// <param name="filename">
        /// The name of the file that's being uploaded. You don't need to specify this in the JSON
        /// if it is specified in the file part of the POST.
        /// </param>
        /// <param name="maxsize">
        /// The maximum size that the file will be. This is used as a limiter to know when something
        /// has gone wrong with the upload. The maxSize is same as the file you uploaded. You don't
        /// need to specify this in the JSON if it is specified in the file part of the POST.
        /// </param>
        /// <param name="file">
        /// An input stream associated with the image file you're uploading. This takes the form of a
        /// file part, in a multipart/form-data HTTP request. This input stream and the filename and
        /// maxSize parameters are automatically inferred from that file part.
        /// </param>
        /// <param name="file_checksum">
        /// An optional MD5 hash of the file. The checksum can be used to verify that the file checked
        /// into your Brightcove Media Library is the same as the file you uploaded.
        /// </param>
        /// <param name="video_id">
        /// The ID of the video you'd like to assign an image to.
        /// </param>
        /// <param name="video_reference_id">
        /// The publisher-assigned reference ID of the video you'd like to assign an image to.
        /// </param>
        /// <param name="resize">
        /// Set this to false if you don't want your image to be automatically resized to the default
        /// size for its type. By default images will be resized.
        /// </param>
        /// <returns></returns>
        private RPCResponse <BCImage> AddImage(BCImage image, string filename, byte[] file, long video_id, string video_reference_id, bool resize, long maxsize, string file_checksum)
        {
            // Generate post objects
            Dictionary <string, object> postParams = new Dictionary <string, object>();

            //add video to the post params
            RPCRequest rpc = new RPCRequest();

            rpc.method      = "add_image";
            rpc.parameters  = "\"image\": " + image.ToJSON();
            rpc.parameters += ", \"filename\": \"" + filename + "\"";
            if (video_id > -1)
            {
                rpc.parameters += ",\"video_id\": \"" + video_id.ToString() + "\"";
            }
            else if (video_reference_id != null)
            {
                rpc.parameters += ",\"video_reference_id\": \"" + video_reference_id + "\"";
            }
            if (maxsize > -1)
            {
                rpc.parameters += ", \"maxsize\": \"" + maxsize.ToString() + "\"";
            }

            if (file_checksum != null)
            {
                rpc.parameters += ", \"file_checksum\": \"" + file_checksum + "\"";
            }
            rpc.parameters += ", \"token\": \"" + Account.WriteToken.Value + "\"";
            postParams.Add("json", rpc.ToJSON());

            //add the file to the post
            if (file != null && !string.IsNullOrEmpty(filename))
            {
                postParams.Add("file", new FileParameter(file, filename));
            }

            //Get the JSon reader returned from the APIRequest
            RPCResponse <BCImage> rpcr = BCAPIRequest.ExecuteWrite <BCImage>(postParams, Account);

            return(rpcr);
        }
        private static BCQueryResult MultipleQueryHandler(Dictionary <String, String> reqparams, BCObjectType itemType, AccountConfigElement account)
        {
            //Get the JSon reader returned from the APIRequest
            BCQueryResult qr = new BCQueryResult();

            qr.TotalCount = 0;

            try {
                //set some global request paramameters
                if (!reqparams.ContainsKey("page_number"))
                {
                    reqparams.Add("page_number", "0");
                }

                //set if not set or
                if (!reqparams.ContainsKey("page_size"))
                {
                    qr.MaxToGet = -1;
                }
                else
                {
                    qr.MaxToGet = Convert.ToInt32(reqparams["page_size"]);
                }

                //get initial query
                double maxPageNum = 0;

                QueryResultPair qrp = BCAPIRequest.ExecuteRead(reqparams, account);
                //convert the result for deserialization
                qrp.JsonResult = qrp.JsonResult.Replace("\"items\":", "\"" + itemType.ToString() + "\":");
                qr.QueryResults.Add(qrp);
                qr.Merge(JSON.Converter.Deserialize <BCQueryResult>(qrp.JsonResult));

                //make sure you get the correct page num
                if (qr.TotalCount > 0)
                {
                    //if you want all use the total count to calculate the number of pages
                    if (qr.MaxToGet.Equals(-1))
                    {
                        maxPageNum = Math.Ceiling((double)(qr.TotalCount / 100));
                    }
                    //or just use the max you want to calculate the number of pages
                    else
                    {
                        maxPageNum = Math.Ceiling((double)(qr.MaxToGet / 100));
                    }
                }

                //if there are more to get move to next page and keep getting them
                for (int pageNum = 1; pageNum <= maxPageNum; pageNum++)
                {
                    //update page each iteration
                    reqparams["page_number"] = pageNum.ToString();

                    QueryResultPair qrp2 = BCAPIRequest.ExecuteRead(reqparams, account);
                    //convert the result for deserialization
                    qrp2.JsonResult = qrp2.JsonResult.Replace("\"items\":", "\"" + itemType.ToString() + "\":");
                    qr.QueryResults.Add(qrp2);
                    qr.Merge(JSON.Converter.Deserialize <BCQueryResult>(qrp2.JsonResult));
                }

                //sorting on our end

                if (itemType.Equals(BCObjectType.videos) && reqparams.ContainsKey("sort_by"))
                {
                    //PUBLISH_DATE,
                    if (reqparams["sort_by"].Equals("PUBLISH_DATE"))
                    {
                        qr.Videos.Sort(BCVideo.PublishDateComparison);
                    }
                    //PLAYS_TOTAL,
                    else if (reqparams["sort_by"].Equals("PLAYS_TOTAL"))
                    {
                        qr.Videos.Sort(BCVideo.TotalPlaysComparison);
                    }
                    //PLAYS_TRAILING_WEEK
                    else if (reqparams["sort_by"].Equals("PLAYS_TRAILING_WEEK"))
                    {
                        qr.Videos.Sort(BCVideo.PlaysTrailingComparison);
                    }
                    //MODIFIED_DATE,
                    else if (reqparams["sort_by"].Equals("MODIFIED_DATE"))
                    {
                        qr.Videos.Sort(BCVideo.ModifiedDateComparison);
                    }
                    //CREATION_DATE,
                    else
                    {
                        qr.Videos.Sort(BCVideo.CreationDateComparison);
                    }

                    //if they want asc
                    if (reqparams["sort_order"].Equals("DESC"))
                    {
                        qr.Videos.Reverse();
                    }

                    //trim if specified
                    if (qr.Videos.Count > qr.MaxToGet && !qr.MaxToGet.Equals(-1) && qr.MaxToGet < qr.TotalCount)
                    {
                        List <BCVideo> vidTemp = qr.Videos.GetRange(0, Convert.ToInt32(qr.MaxToGet));

                        qr.Videos.Clear();
                        qr.Videos.AddRange(vidTemp);
                    }
                }
            }
            catch (Exception ex) {
                throw new Exception(ex.ToString());
            }

            return(qr);
        }