diff --git a/README.md b/README.md index 1008cc2..0778889 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,21 @@ Performs an API search query. Default: Type: Mixed +### Return Value + + true + +search_unfiltered +----------------- +Performs an unfiltered API search query, which will return all videos including deleted, inactive, and scheduled videos. + +**Note:** `_unfiltered` methods are not enabled by default — they must be enabled by Brightcove Support + +- **pParams** *Either an object containing the API parameters to apply to the given command, or a single value which is applied to the command's default selector; for "any", "all" or "none" arguments, use a string value for a single search term, or an array value for multiple search terms* + + Default: + Type: Mixed + ### Return Value true \ No newline at end of file diff --git a/bc-mapi.js b/bc-mapi.js index 9661723..47f8497 100644 --- a/bc-mapi.js +++ b/bc-mapi.js @@ -17,7 +17,7 @@ var BCMAPI = new function () { this.token = ""; this.callback = "BCMAPI.flush"; - this.url = "http://api.brightcove.com/services/library"; + this.url = "//api.brightcove.com/services/library"; this.request = this.url; this.calls = [ { "command" : "find_all_videos", "def" : false }, @@ -41,7 +41,8 @@ var BCMAPI = new function () { { "command" : "find_playlist_by_reference_id", "def" : "reference_id" }, { "command" : "find_playlists_by_reference_ids", "def" : "reference_ids" }, { "command" : "find_playlists_for_player_id", "def" : "player_id" }, - { "command" : "search_videos", "def" : "all" } + { "command" : "search_videos", "def" : "all" }, + { "command" : "search_videos_unfiltered", "def" : "all"} ]; /** @@ -52,11 +53,15 @@ var BCMAPI = new function () { */ this.inject = function (pQuery) { var pElement = document.createElement("script"); + // if url has been modified, make sure it is protocol-neutral + if (this.url.indexOf("//") !== 0) { + this.url = this.url.substring(this.url.indexOf("//")); + } this.request = this.url + "?" + pQuery; pElement.setAttribute("src", this.request); pElement.setAttribute("type", "text/javascript"); document.getElementsByTagName("head")[0].appendChild(pElement); - + return true; }; @@ -68,6 +73,7 @@ var BCMAPI = new function () { * @return true */ this.find = function (pCommand, pParams) { + var tempArray; pCommand = pCommand.toLowerCase().replace(/(find_)|(_)|(get_)/g, ""); pParams = pParams || null; var pDefault = null; @@ -77,14 +83,14 @@ var BCMAPI = new function () { if (typeof this.calls[pCall].command == "undefined") { continue; } - + if (pCommand == this.calls[pCall].command.toLowerCase().replace(/(find_)|(_)|(get_)/g, "")) { pCommand = this.calls[pCall].command; - + if (typeof this.calls[pCall].def != "undefined") { pDefault = this.calls[pCall].def; } - + break; } } @@ -95,14 +101,14 @@ var BCMAPI = new function () { for (var pParam in pParams) { if (pParam == "any" || pParam == "all" || pParam == "none") { if (this.isArray(pParams[pParam])) { - for (var idx in pParams[pParam]) { - pQuery += "&" + pParam + "=" + encodeURIComponent(pParams[pParam][idx]); - } - } else { - pQuery += "&" + pParam + "=" + encodeURIComponent(pParams[pParam]); + for (var idx in pParams[pParam]) { + pQuery += "&" + pParam + "=" + encodeURIComponent(pParams[pParam][idx]); + } + } else { + pQuery += "&" + pParam + "=" + encodeURIComponent(pParams[pParam]); } } - if (pParam == "selector" && pParam !== "all") { + if (pParam == "selector" && pParam !== "all") { pQuery += "&" + pDefault + "=" + encodeURIComponent(pParams[pParam]); } else { pQuery += "&" + pParam + "=" + encodeURIComponent(pParams[pParam]); @@ -138,7 +144,17 @@ var BCMAPI = new function () { this.search = function (pParams) { return this.find("search_videos", pParams); }; - + + /** + * Performs an API search_videos_unfiltered query + * @since 1.0 + * @param mixed [pParams] Either an object containing the API parameters to apply to the given command, or a single value which is applied to the command's default selector + * @return true + */ + this.search_unfiltered = function (pParams) { + return this.find("search_videos_unfiltered", pParams); + }; + /** * Determines if param member is an array * @since 1.1