diff --git a/MediaBrowser.Api/PackageReviewService.cs b/MediaBrowser.Api/PackageReviewService.cs index 1aca596c0e..cb3c80a839 100644 --- a/MediaBrowser.Api/PackageReviewService.cs +++ b/MediaBrowser.Api/PackageReviewService.cs @@ -4,6 +4,8 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Constants; using MediaBrowser.Common.Net; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Serialization; using ServiceStack.ServiceHost; namespace MediaBrowser.Api @@ -51,16 +53,89 @@ namespace MediaBrowser.Api public string Review { get; set; } } + /// + /// Class InstallPackage + /// + [Route("/PackageReviews/{Id}", "GET")] + [Api(("Retrieve reviews for a package"))] + public class ReviewRequest : IReturn> + { + /// + /// Gets or sets the Id. + /// + /// The Id. + [ApiMember(Name = "Id", Description = "Package Id", IsRequired = true, DataType = "int", ParameterType = "path", Verb = "GET")] + public int Id { get; set; } + + /// + /// Gets or sets the max rating. + /// + /// The max rating. + [ApiMember(Name = "MaxRating", Description = "Retrieve only reviews less than or equal to this", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int MaxRating { get; set; } + + /// + /// Gets or sets the min rating. + /// + /// The max rating. + [ApiMember(Name = "MinRating", Description = "Retrieve only reviews greator than or equal to this", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int MinRating { get; set; } + + /// + /// Only retrieve reviews with at least a short review. + /// + /// True if should only get reviews with a title. + [ApiMember(Name = "ForceTitle", Description = "Whether or not to restrict results to those with a title", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool ForceTitle { get; set; } + + /// + /// Gets or sets the limit for the query. + /// + /// The max rating. + [ApiMember(Name = "Limit", Description = "Limit the result to this many reviews (ordered by latest)", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int Limit { get; set; } + + } public class PackageReviewService : BaseApiService { private readonly IHttpClient _httpClient; private readonly INetworkManager _netManager; + private readonly IJsonSerializer _serializer; - public PackageReviewService(IHttpClient client, INetworkManager net) + public PackageReviewService(IHttpClient client, INetworkManager net, IJsonSerializer serializer) { _httpClient = client; _netManager = net; + _serializer = serializer; + } + + public object Get(ReviewRequest request) + { + var parms = "?id=" + request.Id; + + if (request.MaxRating > 0) + { + parms += "&max=" + request.MaxRating; + } + if (request.MinRating > 0) + { + parms += "&min=" + request.MinRating; + } + if (request.MinRating > 0) + { + parms += "&limit=" + request.Limit; + } + if (request.ForceTitle) + { + parms += "&title=true"; + } + + var result = _httpClient.Get(Constants.MbAdminUrl + "/service/packageReview/retrieve"+parms, CancellationToken.None).Result; + + var reviews = _serializer.DeserializeFromStream>(result); + + return ToOptimizedResult(reviews); } public void Post(CreateReviewRequest request) diff --git a/MediaBrowser.Model/Entities/PackageReviewInfo.cs b/MediaBrowser.Model/Entities/PackageReviewInfo.cs index 9d71622c3b..c350935f40 100644 --- a/MediaBrowser.Model/Entities/PackageReviewInfo.cs +++ b/MediaBrowser.Model/Entities/PackageReviewInfo.cs @@ -33,5 +33,10 @@ namespace MediaBrowser.Model.Entities /// public string review { get; set; } + /// + /// Time of review + /// + public DateTime timestamp { get; set; } + } } diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js index e72d48e3e9..e16ba0e331 100644 --- a/MediaBrowser.WebDashboard/ApiClient.js +++ b/MediaBrowser.WebDashboard/ApiClient.js @@ -12,7 +12,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} clientName * @param {String} applicationVersion */ - return function (serverProtocol, serverHostName, serverPortNumber, clientName, applicationVersion) { + return function(serverProtocol, serverHostName, serverPortNumber, clientName, applicationVersion) { if (!serverProtocol) { throw new Error("Must supply a serverProtocol, e.g. http:"); @@ -30,7 +30,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets the server host name. */ - self.serverHostName = function () { + self.serverHostName = function() { return serverHostName; }; @@ -38,7 +38,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets or sets the current user id. */ - self.currentUserId = function (val) { + self.currentUserId = function(val) { if (val !== undefined) { currentUserId = val; @@ -47,26 +47,21 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi } }; - deviceName = (function () { + deviceName = (function() { var name = ""; if ($.browser.chrome) { name = "Chrome"; - } - else if ($.browser.safari) { + } else if ($.browser.safari) { name = "Safari"; - } - else if ($.browser.webkit) { + } else if ($.browser.webkit) { name = "WebKit"; - } - else if ($.browser.msie) { + } else if ($.browser.msie) { name = "Internet Explorer"; - } - else if ($.browser.opera) { + } else if ($.browser.opera) { name = "Opera"; - } - else if ($.browser.firefox || $.browser.mozilla) { + } else if ($.browser.firefox || $.browser.mozilla) { name = "Firefox"; } @@ -74,28 +69,25 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi if ($.browser.version) { name += " " + $.browser.version; } - } - else { + } else { name = "Web Browser"; } if ($.browser.ipad) { name += " Ipad"; - } - else if ($.browser.iphone) { + } else if ($.browser.iphone) { name += " Iphone"; - } - else if ($.browser.android) { + } else if ($.browser.android) { name += " Android"; } return name; }()); - self.deviceId = function () { + self.deviceId = function() { return deviceId; }; - self.encodeName = function (name) { + self.encodeName = function(name) { name = name.split('/').join('-'); @@ -108,7 +100,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Wraps around jQuery ajax methods to add additional info to the request. */ - self.ajax = function (request) { + self.ajax = function(request) { if (!request) { throw new Error("Request cannot be null"); @@ -135,7 +127,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} name * @param {Object} params */ - self.getUrl = function (name, params) { + self.getUrl = function(name, params) { if (!name) { throw new Error("Url name cannot be empty"); @@ -156,44 +148,44 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi return url; }; - self.openWebSocket = function (port) { + self.openWebSocket = function(port) { var url = "ws://" + serverHostName + ":" + port + "/mediabrowser"; webSocket = new WebSocket(url); - webSocket.onmessage = function (msg) { + webSocket.onmessage = function(msg) { msg = JSON.parse(msg.data); $(self).trigger("websocketmessage", [msg]); }; - webSocket.onopen = function () { - setTimeout(function () { + webSocket.onopen = function() { + setTimeout(function() { self.sendWebSocketMessage("Identity", clientName + "|" + deviceId + "|" + applicationVersion + "|" + deviceName); $(self).trigger("websocketopen"); }, 500); }; - webSocket.onerror = function () { - setTimeout(function () { + webSocket.onerror = function() { + setTimeout(function() { $(self).trigger("websocketerror"); }, 0); }; - webSocket.onclose = function () { - setTimeout(function () { + webSocket.onclose = function() { + setTimeout(function() { $(self).trigger("websocketclose"); }, 0); }; }; - self.closeWebSocket = function () { + self.closeWebSocket = function() { if (webSocket && webSocket.readyState === WebSocket.OPEN) { webSocket.close(); } }; - self.sendWebSocketMessage = function (name, data) { + self.sendWebSocketMessage = function(name, data) { var msg = { MessageType: name }; @@ -206,11 +198,11 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi webSocket.send(msg); }; - self.isWebSocketOpen = function () { + self.isWebSocketOpen = function() { return webSocket && webSocket.readyState === WebSocket.OPEN; }; - self.isWebSocketOpenOrConnecting = function () { + self.isWebSocketOpenOrConnecting = function() { return webSocket && (webSocket.readyState === WebSocket.OPEN || webSocket.readyState === WebSocket.CONNECTING); }; @@ -218,7 +210,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Gets an item from the server * Omit itemId to get the root folder. */ - self.getItem = function (userId, itemId) { + self.getItem = function(userId, itemId) { if (!userId) { throw new Error("null userId"); @@ -236,7 +228,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets the root folder from the server */ - self.getRootFolder = function (userId) { + self.getRootFolder = function(userId) { if (!userId) { throw new Error("null userId"); @@ -251,7 +243,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getNotificationSummary = function (userId) { + self.getNotificationSummary = function(userId) { if (!userId) { throw new Error("null userId"); @@ -266,7 +258,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getNotifications = function (userId, options) { + self.getNotifications = function(userId, options) { if (!userId) { throw new Error("null userId"); @@ -281,7 +273,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.markNotificationsRead = function (userId, idList, isRead) { + self.markNotificationsRead = function(userId, idList, isRead) { if (!userId) { throw new Error("null userId"); @@ -313,28 +305,22 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi if (options.artist) { urlPrefix = "Artists/" + self.encodeName(options.artist); delete options.artist; - } - else if (options.person) { + } else if (options.person) { urlPrefix = "Persons/" + self.encodeName(options.person); delete options.person; - } - else if (options.genre) { + } else if (options.genre) { urlPrefix = "Genres/" + self.encodeName(options.genre); delete options.genre; - } - else if (options.musicGenre) { + } else if (options.musicGenre) { urlPrefix = "MusicGenres/" + self.encodeName(options.musicGenre); delete options.musicGenre; - } - else if (options.gameGenre) { + } else if (options.gameGenre) { urlPrefix = "GameGenres/" + self.encodeName(options.gameGenre); delete options.gameGenre; - } - else if (options.studio) { + } else if (options.studio) { urlPrefix = "Studios/" + self.encodeName(options.studio); delete options.studio; - } - else { + } else { urlPrefix = "Items/" + options.itemId; delete options.itemId; } @@ -342,7 +328,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi return urlPrefix; } - self.getRemoteImageProviders = function (options) { + self.getRemoteImageProviders = function(options) { if (!options) { throw new Error("null options"); @@ -359,7 +345,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getAvailableRemoteImages = function (options) { + self.getAvailableRemoteImages = function(options) { if (!options) { throw new Error("null options"); @@ -376,7 +362,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.downloadRemoteImage = function (options) { + self.downloadRemoteImage = function(options) { if (!options) { throw new Error("null options"); @@ -395,7 +381,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets the current server status */ - self.getSystemInfo = function () { + self.getSystemInfo = function() { var url = self.getUrl("System/Info"); @@ -406,7 +392,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getInstantMixFromSong = function (itemId, options) { + self.getInstantMixFromSong = function(itemId, options) { var url = self.getUrl("Songs/" + itemId + "/InstantMix", options); @@ -417,7 +403,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getInstantMixFromAlbum = function (itemId, options) { + self.getInstantMixFromAlbum = function(itemId, options) { var url = self.getUrl("Albums/" + itemId + "/InstantMix", options); @@ -428,7 +414,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getInstantMixFromArtist = function (name, options) { + self.getInstantMixFromArtist = function(name, options) { var url = self.getUrl("Artists/" + self.encodeName(name) + "/InstantMix", options); @@ -439,7 +425,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getInstantMixFromMusicGenre = function (name, options) { + self.getInstantMixFromMusicGenre = function(name, options) { var url = self.getUrl("MusicGenres/" + self.encodeName(name) + "/InstantMix", options); @@ -450,7 +436,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getSimilarMovies = function (itemId, options) { + self.getSimilarMovies = function(itemId, options) { var url = self.getUrl("Movies/" + itemId + "/Similar", options); @@ -461,7 +447,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getSimilarTrailers = function (itemId, options) { + self.getSimilarTrailers = function(itemId, options) { var url = self.getUrl("Trailers/" + itemId + "/Similar", options); @@ -472,7 +458,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getSimilarShows = function (itemId, options) { + self.getSimilarShows = function(itemId, options) { var url = self.getUrl("Shows/" + itemId + "/Similar", options); @@ -483,7 +469,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getSimilarAlbums = function (itemId, options) { + self.getSimilarAlbums = function(itemId, options) { var url = self.getUrl("Albums/" + itemId + "/Similar", options); @@ -494,7 +480,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getSimilarGames = function (itemId, options) { + self.getSimilarGames = function(itemId, options) { var url = self.getUrl("Games/" + itemId + "/Similar", options); @@ -508,7 +494,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets all cultures known to the server */ - self.getCultures = function () { + self.getCultures = function() { var url = self.getUrl("Localization/cultures"); @@ -522,7 +508,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets all countries known to the server */ - self.getCountries = function () { + self.getCountries = function() { var url = self.getUrl("Localization/countries"); @@ -536,7 +522,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets plugin security info */ - self.getPluginSecurityInfo = function () { + self.getPluginSecurityInfo = function() { var url = self.getUrl("Plugins/SecurityInfo"); @@ -550,7 +536,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets the directory contents of a path on the server */ - self.getDirectoryContents = function (path, options) { + self.getDirectoryContents = function(path, options) { if (!path) { throw new Error("null path"); @@ -572,7 +558,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets a list of physical drives from the server */ - self.getDrives = function () { + self.getDrives = function() { var url = self.getUrl("Environment/Drives"); @@ -586,7 +572,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets a list of network devices from the server */ - self.getNetworkDevices = function () { + self.getNetworkDevices = function() { var url = self.getUrl("Environment/NetworkDevices"); @@ -600,7 +586,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Cancels a package installation */ - self.cancelPackageInstallation = function (installationId) { + self.cancelPackageInstallation = function(installationId) { if (!installationId) { throw new Error("null installationId"); @@ -617,17 +603,15 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Refreshes metadata for an item */ - self.refreshItem = function (itemId, force, recursive) { + self.refreshItem = function(itemId, force, recursive) { if (!itemId) { throw new Error("null itemId"); } var url = self.getUrl("Items/" + itemId + "/Refresh", { - forced: force || false, recursive: recursive || false - }); return self.ajax({ @@ -636,16 +620,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.refreshArtist = function (name, force) { + self.refreshArtist = function(name, force) { if (!name) { throw new Error("null name"); } var url = self.getUrl("Artists/" + self.encodeName(name) + "/Refresh", { - forced: force || false - }); return self.ajax({ @@ -654,16 +636,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.refreshGenre = function (name, force) { + self.refreshGenre = function(name, force) { if (!name) { throw new Error("null name"); } var url = self.getUrl("Genres/" + self.encodeName(name) + "/Refresh", { - forced: force || false - }); return self.ajax({ @@ -672,16 +652,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.refreshMusicGenre = function (name, force) { + self.refreshMusicGenre = function(name, force) { if (!name) { throw new Error("null name"); } var url = self.getUrl("MusicGenres/" + self.encodeName(name) + "/Refresh", { - forced: force || false - }); return self.ajax({ @@ -690,16 +668,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.refreshGameGenre = function (name, force) { + self.refreshGameGenre = function(name, force) { if (!name) { throw new Error("null name"); } var url = self.getUrl("GameGenres/" + self.encodeName(name) + "/Refresh", { - forced: force || false - }); return self.ajax({ @@ -708,16 +684,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.refreshPerson = function (name, force) { + self.refreshPerson = function(name, force) { if (!name) { throw new Error("null name"); } var url = self.getUrl("Persons/" + self.encodeName(name) + "/Refresh", { - forced: force || false - }); return self.ajax({ @@ -726,16 +700,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.refreshStudio = function (name, force) { + self.refreshStudio = function(name, force) { if (!name) { throw new Error("null name"); } var url = self.getUrl("Studios/" + self.encodeName(name) + "/Refresh", { - forced: force || false - }); return self.ajax({ @@ -747,7 +719,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Installs or updates a new plugin */ - self.installPlugin = function (name, guid, updateClass, version) { + self.installPlugin = function(name, guid, updateClass, version) { if (!name) { throw new Error("null name"); @@ -777,7 +749,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Instructs the server to perform a restart. */ - self.restartServer = function () { + self.restartServer = function() { var url = self.getUrl("System/Restart"); @@ -790,7 +762,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Instructs the server to perform a shutdown. */ - self.shutdownServer = function () { + self.shutdownServer = function() { var url = self.getUrl("System/Shutdown"); @@ -803,7 +775,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets information about an installable package */ - self.getPackageInfo = function (name, guid) { + self.getPackageInfo = function(name, guid) { if (!name) { throw new Error("null name"); @@ -825,7 +797,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets the latest available application update (if any) */ - self.getAvailableApplicationUpdate = function () { + self.getAvailableApplicationUpdate = function() { var url = self.getUrl("Packages/Updates", { PackageType: "System" }); @@ -839,7 +811,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets the latest available plugin updates (if any) */ - self.getAvailablePluginUpdates = function () { + self.getAvailablePluginUpdates = function() { var url = self.getUrl("Packages/Updates", { PackageType: "UserInstalled" }); @@ -853,7 +825,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets the virtual folder for a view. Specify a userId to get a user view, or omit for the default view. */ - self.getVirtualFolders = function (userId) { + self.getVirtualFolders = function(userId) { var url = userId ? "Users/" + userId + "/VirtualFolders" : "Library/VirtualFolders"; @@ -869,7 +841,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets all the paths of the locations in the physical root. */ - self.getPhysicalPaths = function () { + self.getPhysicalPaths = function() { var url = self.getUrl("Library/PhysicalPaths"); @@ -883,7 +855,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets the current server configuration */ - self.getServerConfiguration = function () { + self.getServerConfiguration = function() { var url = self.getUrl("System/Configuration"); @@ -897,7 +869,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets the server's scheduled tasks */ - self.getScheduledTasks = function () { + self.getScheduledTasks = function() { var url = self.getUrl("ScheduledTasks"); @@ -911,7 +883,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Starts a scheduled task */ - self.startScheduledTask = function (id) { + self.startScheduledTask = function(id) { if (!id) { throw new Error("null id"); @@ -928,7 +900,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets a scheduled task */ - self.getScheduledTask = function (id) { + self.getScheduledTask = function(id) { if (!id) { throw new Error("null id"); @@ -943,7 +915,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getNextUpEpisodes = function (options) { + self.getNextUpEpisodes = function(options) { var url = self.getUrl("Shows/NextUp", options); @@ -957,7 +929,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Stops a scheduled task */ - self.stopScheduledTask = function (id) { + self.stopScheduledTask = function(id) { if (!id) { throw new Error("null id"); @@ -975,7 +947,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Gets the configuration of a plugin * @param {String} Id */ - self.getPluginConfiguration = function (id) { + self.getPluginConfiguration = function(id) { if (!id) { throw new Error("null Id"); @@ -993,7 +965,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets a list of plugins that are available to be installed */ - self.getAvailablePlugins = function (options) { + self.getAvailablePlugins = function(options) { options = $.extend({}, options || {}); options.PackageType = "UserInstalled"; @@ -1011,7 +983,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Uninstalls a plugin * @param {String} Id */ - self.uninstallPlugin = function (id) { + self.uninstallPlugin = function(id) { if (!id) { throw new Error("null Id"); @@ -1029,7 +1001,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Removes a virtual folder from either the default view or a user view * @param {String} name */ - self.removeVirtualFolder = function (name, userId, refreshLibrary) { + self.removeVirtualFolder = function(name, userId, refreshLibrary) { if (!name) { throw new Error("null name"); @@ -1053,7 +1025,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Adds a virtual folder to either the default view or a user view * @param {String} name */ - self.addVirtualFolder = function (name, type, userId, refreshLibrary) { + self.addVirtualFolder = function(name, type, userId, refreshLibrary) { if (!name) { throw new Error("null name"); @@ -1082,7 +1054,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Renames a virtual folder, within either the default view or a user view * @param {String} name */ - self.renameVirtualFolder = function (name, newName, userId, refreshLibrary) { + self.renameVirtualFolder = function(name, newName, userId, refreshLibrary) { if (!name) { throw new Error("null name"); @@ -1107,7 +1079,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Adds an additional mediaPath to an existing virtual folder, within either the default view or a user view * @param {String} name */ - self.addMediaPath = function (virtualFolderName, mediaPath, userId, refreshLibrary) { + self.addMediaPath = function(virtualFolderName, mediaPath, userId, refreshLibrary) { if (!virtualFolderName) { throw new Error("null virtualFolderName"); @@ -1122,7 +1094,6 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi url += "/" + virtualFolderName + "/Paths"; url = self.getUrl(url, { - refreshLibrary: refreshLibrary ? true : false, path: mediaPath }); @@ -1137,7 +1108,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Removes a media path from a virtual folder, within either the default view or a user view * @param {String} name */ - self.removeMediaPath = function (virtualFolderName, mediaPath, userId, refreshLibrary) { + self.removeMediaPath = function(virtualFolderName, mediaPath, userId, refreshLibrary) { if (!virtualFolderName) { throw new Error("null virtualFolderName"); @@ -1152,7 +1123,6 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi url += "/" + virtualFolderName + "/Paths"; url = self.getUrl(url, { - refreshLibrary: refreshLibrary ? true : false, path: mediaPath }); @@ -1167,7 +1137,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Deletes a user * @param {String} id */ - self.deleteUser = function (id) { + self.deleteUser = function(id) { if (!id) { throw new Error("null id"); @@ -1186,7 +1156,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} userId * @param {String} imageType The type of image to delete, based on the server-side ImageType enum. */ - self.deleteUserImage = function (userId, imageType, imageIndex) { + self.deleteUserImage = function(userId, imageType, imageIndex) { if (!userId) { throw new Error("null userId"); @@ -1208,7 +1178,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.deleteItemImage = function (itemId, itemType, itemName, imageType, imageIndex) { + self.deleteItemImage = function(itemId, itemType, itemName, imageType, imageIndex) { if (!imageType) { throw new Error("null imageType"); @@ -1222,23 +1192,17 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi if (itemType == "Artist") { url = self.getUrl("Artists/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "Genre") { + } else if (itemType == "Genre") { url = self.getUrl("Genres/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "GameGenre") { + } else if (itemType == "GameGenre") { url = self.getUrl("GameGenres/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "MusicGenre") { + } else if (itemType == "MusicGenre") { url = self.getUrl("MusicGenres/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "Person") { + } else if (itemType == "Person") { url = self.getUrl("Persons/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "Studio") { + } else if (itemType == "Studio") { url = self.getUrl("Studios/" + self.encodeName(itemName) + "/Images"); - } - else { + } else { url = self.getUrl("Items/" + itemId + "/Images"); } @@ -1254,7 +1218,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.deleteItem = function (itemId) { + self.deleteItem = function(itemId) { if (!itemId) { throw new Error("null itemId"); @@ -1268,7 +1232,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateItemImageIndex = function (itemId, itemType, itemName, imageType, imageIndex, newIndex) { + self.updateItemImageIndex = function(itemId, itemType, itemName, imageType, imageIndex, newIndex) { if (!imageType) { throw new Error("null imageType"); @@ -1284,23 +1248,17 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi if (itemType == "Artist") { url = self.getUrl("Artists/" + self.encodeName(itemName) + "/Images/" + imageType + "/" + imageIndex + "/Index", options); - } - else if (itemType == "Genre") { + } else if (itemType == "Genre") { url = self.getUrl("Genres/" + self.encodeName(itemName) + "/Images/" + imageType + "/" + imageIndex + "/Index", options); - } - else if (itemType == "GameGenre") { + } else if (itemType == "GameGenre") { url = self.getUrl("GameGenres/" + self.encodeName(itemName) + "/Images/" + imageType + "/" + imageIndex + "/Index", options); - } - else if (itemType == "MusicGenre") { + } else if (itemType == "MusicGenre") { url = self.getUrl("MusicGenres/" + self.encodeName(itemName) + "/Images/" + imageType + "/" + imageIndex + "/Index", options); - } - else if (itemType == "Person") { + } else if (itemType == "Person") { url = self.getUrl("Persons/" + self.encodeName(itemName) + "/Images/" + imageType + "/" + imageIndex + "/Index", options); - } - else if (itemType == "Studio") { + } else if (itemType == "Studio") { url = self.getUrl("Studios/" + self.encodeName(itemName) + "/Images/" + imageType + "/" + imageIndex + "/Index", options); - } - else { + } else { url = self.getUrl("Items/" + itemId + "/Images/" + imageType + "/" + imageIndex + "/Index", options); } @@ -1310,7 +1268,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getItemImageInfos = function (itemId, itemType, itemName) { + self.getItemImageInfos = function(itemId, itemType, itemName) { if (!itemType) { throw new Error("null itemType"); @@ -1320,23 +1278,17 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi if (itemType == "Artist") { url = self.getUrl("Artists/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "Genre") { + } else if (itemType == "Genre") { url = self.getUrl("Genres/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "GameGenre") { + } else if (itemType == "GameGenre") { url = self.getUrl("GameGenres/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "MusicGenre") { + } else if (itemType == "MusicGenre") { url = self.getUrl("MusicGenres/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "Person") { + } else if (itemType == "Person") { url = self.getUrl("Persons/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "Studio") { + } else if (itemType == "Studio") { url = self.getUrl("Studios/" + self.encodeName(itemName) + "/Images"); - } - else { + } else { url = self.getUrl("Items/" + itemId + "/Images"); } @@ -1347,7 +1299,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getCriticReviews = function (itemId, options) { + self.getCriticReviews = function(itemId, options) { if (!itemId) { throw new Error("null itemId"); @@ -1362,7 +1314,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getSessions = function (options) { + self.getSessions = function(options) { var url = self.getUrl("Sessions", options); @@ -1379,7 +1331,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} imageType The type of image to delete, based on the server-side ImageType enum. * @param {Object} file The file from the input element */ - self.uploadUserImage = function (userId, imageType, file) { + self.uploadUserImage = function(userId, imageType, file) { if (!userId) { throw new Error("null userId"); @@ -1401,16 +1353,16 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi var reader = new FileReader(); - reader.onerror = function () { + reader.onerror = function() { deferred.reject(); }; - reader.onabort = function () { + reader.onabort = function() { deferred.reject(); }; // Closure to capture the file information. - reader.onload = function (e) { + reader.onload = function(e) { // Split by a comma to remove the url: prefix var data = e.target.result.split(',')[1]; @@ -1422,11 +1374,11 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi url: url, data: data, contentType: "image/" + file.name.substring(file.name.lastIndexOf('.') + 1) - }).done(function (result) { + }).done(function(result) { deferred.resolveWith(null, [result]); - }).fail(function () { + }).fail(function() { deferred.reject(); }); }; @@ -1437,7 +1389,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi return deferred.promise(); }; - self.uploadItemImage = function (itemId, itemType, itemName, imageType, file) { + self.uploadItemImage = function(itemId, itemType, itemName, imageType, file) { if (!itemId) { throw new Error("null itemId"); @@ -1459,23 +1411,17 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi if (itemType == "Artist") { url = self.getUrl("Artists/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "Genre") { + } else if (itemType == "Genre") { url = self.getUrl("Genres/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "GameGenre") { + } else if (itemType == "GameGenre") { url = self.getUrl("GameGenres/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "MusicGenre") { + } else if (itemType == "MusicGenre") { url = self.getUrl("MusicGenres/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "Person") { + } else if (itemType == "Person") { url = self.getUrl("Persons/" + self.encodeName(itemName) + "/Images"); - } - else if (itemType == "Studio") { + } else if (itemType == "Studio") { url = self.getUrl("Studios/" + self.encodeName(itemName) + "/Images"); - } - else { + } else { url = self.getUrl("Items/" + itemId + "/Images"); } @@ -1485,16 +1431,16 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi var reader = new FileReader(); - reader.onerror = function () { + reader.onerror = function() { deferred.reject(); }; - reader.onabort = function () { + reader.onabort = function() { deferred.reject(); }; // Closure to capture the file information. - reader.onload = function (e) { + reader.onload = function(e) { // Split by a comma to remove the url: prefix var data = e.target.result.split(',')[1]; @@ -1504,11 +1450,11 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi url: url, data: data, contentType: "image/" + file.name.substring(file.name.lastIndexOf('.') + 1) - }).done(function (result) { + }).done(function(result) { deferred.resolveWith(null, [result]); - }).fail(function () { + }).fail(function() { deferred.reject(); }); }; @@ -1522,7 +1468,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets the list of installed plugins on the server */ - self.getInstalledPlugins = function () { + self.getInstalledPlugins = function() { var url = self.getUrl("Plugins"); @@ -1537,7 +1483,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Gets a user by id * @param {String} id */ - self.getUser = function (id) { + self.getUser = function(id) { if (!id) { throw new Error("Must supply a userId"); @@ -1555,7 +1501,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets a studio */ - self.getStudio = function (name, userId) { + self.getStudio = function(name, userId) { if (!name) { throw new Error("null name"); @@ -1579,7 +1525,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets a genre */ - self.getGenre = function (name, userId) { + self.getGenre = function(name, userId) { if (!name) { throw new Error("null name"); @@ -1600,7 +1546,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getMusicGenre = function (name, userId) { + self.getMusicGenre = function(name, userId) { if (!name) { throw new Error("null name"); @@ -1621,7 +1567,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getGameGenre = function (name, userId) { + self.getGameGenre = function(name, userId) { if (!name) { throw new Error("null name"); @@ -1645,7 +1591,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets an artist */ - self.getArtist = function (name, userId) { + self.getArtist = function(name, userId) { if (!name) { throw new Error("null name"); @@ -1669,7 +1615,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets a year */ - self.getYear = function (yea, userId) { + self.getYear = function(yea, userId) { if (!name) { throw new Error("null name"); @@ -1693,7 +1639,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets a Person */ - self.getPerson = function (name, userId) { + self.getPerson = function(name, userId) { if (!name) { throw new Error("null name"); @@ -1714,7 +1660,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getPublicUsers = function () { + self.getPublicUsers = function() { var url = self.getUrl("users/public"); @@ -1728,7 +1674,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets all users from the server */ - self.getUsers = function (options) { + self.getUsers = function(options) { var url = self.getUrl("users", options || {}); @@ -1742,7 +1688,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets all available parental ratings from the server */ - self.getParentalRatings = function () { + self.getParentalRatings = function() { var url = self.getUrl("Localization/ParentalRatings"); @@ -1756,7 +1702,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets a list of all available conrete BaseItem types from the server */ - self.getItemTypes = function (options) { + self.getItemTypes = function(options) { var url = self.getUrl("Library/ItemTypes", options); @@ -1779,14 +1725,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * quality - A scale of 0-100. This should almost always be omitted as the default will suffice. * For best results do not specify both width and height together, as aspect ratio might be altered. */ - self.getUserImageUrl = function (userId, options) { + self.getUserImageUrl = function(userId, options) { if (!userId) { throw new Error("null userId"); } options = options || { - + }; var url = "Users/" + userId + "/Images/" + options.type; @@ -1814,14 +1760,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * quality - A scale of 0-100. This should almost always be omitted as the default will suffice. * For best results do not specify both width and height together, as aspect ratio might be altered. */ - self.getPersonImageUrl = function (name, options) { + self.getPersonImageUrl = function(name, options) { if (!name) { throw new Error("null name"); } options = options || { - + }; var url = "Persons/" + self.encodeName(name) + "/Images/" + options.type; @@ -1849,14 +1795,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * quality - A scale of 0-100. This should almost always be omitted as the default will suffice. * For best results do not specify both width and height together, as aspect ratio might be altered. */ - self.getYearImageUrl = function (year, options) { + self.getYearImageUrl = function(year, options) { if (!year) { throw new Error("null year"); } options = options || { - + }; var url = "Years/" + year + "/Images/" + options.type; @@ -1884,14 +1830,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * quality - A scale of 0-100. This should almost always be omitted as the default will suffice. * For best results do not specify both width and height together, as aspect ratio might be altered. */ - self.getGenreImageUrl = function (name, options) { + self.getGenreImageUrl = function(name, options) { if (!name) { throw new Error("null name"); } options = options || { - + }; var url = "Genres/" + self.encodeName(name) + "/Images/" + options.type; @@ -1919,14 +1865,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * quality - A scale of 0-100. This should almost always be omitted as the default will suffice. * For best results do not specify both width and height together, as aspect ratio might be altered. */ - self.getMusicGenreImageUrl = function (name, options) { + self.getMusicGenreImageUrl = function(name, options) { if (!name) { throw new Error("null name"); } options = options || { - + }; var url = "MusicGenres/" + self.encodeName(name) + "/Images/" + options.type; @@ -1954,14 +1900,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * quality - A scale of 0-100. This should almost always be omitted as the default will suffice. * For best results do not specify both width and height together, as aspect ratio might be altered. */ - self.getGameGenreImageUrl = function (name, options) { + self.getGameGenreImageUrl = function(name, options) { if (!name) { throw new Error("null name"); } options = options || { - + }; var url = "GameGenres/" + self.encodeName(name) + "/Images/" + options.type; @@ -1989,14 +1935,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * quality - A scale of 0-100. This should almost always be omitted as the default will suffice. * For best results do not specify both width and height together, as aspect ratio might be altered. */ - self.getArtistImageUrl = function (name, options) { + self.getArtistImageUrl = function(name, options) { if (!name) { throw new Error("null name"); } options = options || { - + }; var url = "Artists/" + self.encodeName(name) + "/Images/" + options.type; @@ -2024,14 +1970,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * quality - A scale of 0-100. This should almost always be omitted as the default will suffice. * For best results do not specify both width and height together, as aspect ratio might be altered. */ - self.getStudioImageUrl = function (name, options) { + self.getStudioImageUrl = function(name, options) { if (!name) { throw new Error("null name"); } options = options || { - + }; var url = "Studios/" + self.encodeName(name) + "/Images/" + options.type; @@ -2061,14 +2007,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * quality - A scale of 0-100. This should almost always be omitted as the default will suffice. * For best results do not specify both width and height together, as aspect ratio might be altered. */ - self.getImageUrl = function (itemId, options) { + self.getImageUrl = function(itemId, options) { if (!itemId) { throw new Error("itemId cannot be empty"); } options = options || { - + }; var url = "Items/" + itemId + "/Images/" + options.type; @@ -2097,14 +2043,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * quality - A scale of 0-100. This should almost always be omitted as the default will suffice. * For best results do not specify both width and height together, as aspect ratio might be altered. */ - self.getLogoImageUrl = function (item, options) { + self.getLogoImageUrl = function(item, options) { if (!item) { throw new Error("null item"); } options = options || { - + }; options.imageType = "logo"; @@ -2114,14 +2060,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi return logoItemId ? self.getImageUrl(logoItemId, options) : null; }; - self.getThumbImageUrl = function (item, options) { + self.getThumbImageUrl = function(item, options) { if (!item) { throw new Error("null item"); } options = options || { - + }; options.imageType = "thumb"; @@ -2144,14 +2090,14 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * quality - A scale of 0-100. This should almost always be omitted as the default will suffice. * For best results do not specify both width and height together, as aspect ratio might be altered. */ - self.getBackdropImageUrl = function (item, options) { + self.getBackdropImageUrl = function(item, options) { if (!item) { throw new Error("null item"); } options = options || { - + }; options.imageType = "backdrop"; @@ -2188,7 +2134,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} name * @param {String} password */ - self.authenticateUserByName = function (name, password) { + self.authenticateUserByName = function(name, password) { if (!name) { throw new Error("null name"); @@ -2215,7 +2161,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} userId * @param {String} password */ - self.authenticateUser = function (userId, password) { + self.authenticateUser = function(userId, password) { if (!userId) { throw new Error("null userId"); @@ -2242,7 +2188,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} currentPassword * @param {String} newPassword */ - self.updateUserPassword = function (userId, currentPassword, newPassword) { + self.updateUserPassword = function(userId, currentPassword, newPassword) { if (!userId) { throw new Error("null userId"); @@ -2251,7 +2197,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi var url = self.getUrl("Users/" + userId + "/Password"); var postData = { - + }; postData.currentPassword = MediaBrowser.SHA1(currentPassword); @@ -2271,7 +2217,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Resets a user's password * @param {String} userId */ - self.resetUserPassword = function (userId) { + self.resetUserPassword = function(userId) { if (!userId) { throw new Error("null userId"); @@ -2280,7 +2226,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi var url = self.getUrl("Users/" + userId + "/Password"); var postData = { - + }; postData.resetPassword = true; @@ -2296,7 +2242,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Updates the server's configuration * @param {Object} configuration */ - self.updateServerConfiguration = function (configuration) { + self.updateServerConfiguration = function(configuration) { if (!configuration) { throw new Error("null configuration"); @@ -2312,7 +2258,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateItem = function (item) { + self.updateItem = function(item) { if (!item) { throw new Error("null item"); @@ -2328,7 +2274,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateArtist = function (item) { + self.updateArtist = function(item) { if (!item) { throw new Error("null item"); @@ -2344,7 +2290,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updatePerson = function (item) { + self.updatePerson = function(item) { if (!item) { throw new Error("null item"); @@ -2360,7 +2306,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateStudio = function (item) { + self.updateStudio = function(item) { if (!item) { throw new Error("null item"); @@ -2376,7 +2322,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateGenre = function (item) { + self.updateGenre = function(item) { if (!item) { throw new Error("null item"); @@ -2392,7 +2338,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateMusicGenre = function (item) { + self.updateMusicGenre = function(item) { if (!item) { throw new Error("null item"); @@ -2408,7 +2354,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateGameGenre = function (item) { + self.updateGameGenre = function(item) { if (!item) { throw new Error("null item"); @@ -2427,7 +2373,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Updates plugin security info */ - self.updatePluginSecurityInfo = function (info) { + self.updatePluginSecurityInfo = function(info) { var url = self.getUrl("Plugins/SecurityInfo"); @@ -2443,7 +2389,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Creates a user * @param {Object} user */ - self.createUser = function (user) { + self.createUser = function(user) { if (!user) { throw new Error("null user"); @@ -2464,7 +2410,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * Updates a user * @param {Object} user */ - self.updateUser = function (user) { + self.updateUser = function(user) { if (!user) { throw new Error("null user"); @@ -2485,7 +2431,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} id * @param {Object} triggers */ - self.updateScheduledTaskTriggers = function (id, triggers) { + self.updateScheduledTaskTriggers = function(id, triggers) { if (!id) { throw new Error("null id"); @@ -2510,7 +2456,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} Id * @param {Object} configuration */ - self.updatePluginConfiguration = function (id, configuration) { + self.updatePluginConfiguration = function(id, configuration) { if (!id) { throw new Error("null Id"); @@ -2530,7 +2476,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getAncestorItems = function (itemId, userId) { + self.getAncestorItems = function(itemId, userId) { if (!itemId) { throw new Error("null itemId"); @@ -2568,7 +2514,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * recursive - Whether or not the query should be recursive * searchTerm - search term to use as a filter */ - self.getItems = function (userId, options) { + self.getItems = function(userId, options) { if (!userId) { throw new Error("null userId"); @@ -2586,7 +2532,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** Gets artists from an item */ - self.getArtists = function (userId, options) { + self.getArtists = function(userId, options) { if (!userId) { throw new Error("null userId"); @@ -2607,7 +2553,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** Gets genres from an item */ - self.getGenres = function (userId, options) { + self.getGenres = function(userId, options) { if (!userId) { throw new Error("null userId"); @@ -2625,7 +2571,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getMusicGenres = function (userId, options) { + self.getMusicGenres = function(userId, options) { if (!userId) { throw new Error("null userId"); @@ -2643,7 +2589,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getGameGenres = function (userId, options) { + self.getGameGenres = function(userId, options) { if (!userId) { throw new Error("null userId"); @@ -2664,7 +2610,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** Gets people from an item */ - self.getPeople = function (userId, options) { + self.getPeople = function(userId, options) { if (!userId) { throw new Error("null userId"); @@ -2685,7 +2631,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** Gets studios from an item */ - self.getStudios = function (userId, options) { + self.getStudios = function(userId, options) { if (!userId) { throw new Error("null userId"); @@ -2706,7 +2652,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets local trailers for an item */ - self.getLocalTrailers = function (userId, itemId) { + self.getLocalTrailers = function(userId, itemId) { if (!userId) { throw new Error("null userId"); @@ -2724,7 +2670,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getAdditionalVideoParts = function (userId, itemId) { + self.getAdditionalVideoParts = function(userId, itemId) { if (!itemId) { throw new Error("null itemId"); @@ -2748,7 +2694,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets theme songs for an item */ - self.getThemeSongs = function (userId, itemId) { + self.getThemeSongs = function(userId, itemId) { if (!itemId) { throw new Error("null itemId"); @@ -2769,7 +2715,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getThemeVideos = function (userId, itemId) { + self.getThemeVideos = function(userId, itemId) { if (!itemId) { throw new Error("null itemId"); @@ -2790,7 +2736,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getSearchHints = function (options) { + self.getSearchHints = function(options) { var url = self.getUrl("Search/Hints", options); @@ -2804,7 +2750,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets special features for an item */ - self.getSpecialFeatures = function (userId, itemId) { + self.getSpecialFeatures = function(userId, itemId) { if (!userId) { throw new Error("null userId"); @@ -2822,7 +2768,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getDateParamValue = function (date) { + self.getDateParamValue = function(date) { + function formatDigit(i) { return i < 10 ? "0" + i : i; } @@ -2832,7 +2779,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi return "" + d.getFullYear() + formatDigit(d.getMonth() + 1) + formatDigit(d.getDate()) + formatDigit(d.getHours()) + formatDigit(d.getMinutes()) + formatDigit(d.getSeconds()); }; - self.markPlayed = function (userId, itemId, date) { + self.markPlayed = function(userId, itemId, date) { if (!userId) { throw new Error("null userId"); @@ -2857,7 +2804,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.markUnplayed = function (userId, itemId) { + self.markUnplayed = function(userId, itemId) { if (!userId) { throw new Error("null userId"); @@ -2882,7 +2829,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} itemId * @param {Boolean} isFavorite */ - self.updateFavoriteStatus = function (userId, itemId, isFavorite) { + self.updateFavoriteStatus = function(userId, itemId, isFavorite) { if (!userId) { throw new Error("null userId"); @@ -2909,7 +2856,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} itemId * @param {Boolean} likes */ - self.updateUserItemRating = function (userId, itemId, likes) { + self.updateUserItemRating = function(userId, itemId, likes) { if (!userId) { throw new Error("null userId"); @@ -2936,7 +2883,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} name * @param {Boolean} isFavorite */ - self.updateFavoriteArtistStatus = function (userId, name, isFavorite) { + self.updateFavoriteArtistStatus = function(userId, name, isFavorite) { if (!userId) { throw new Error("null userId"); @@ -2957,7 +2904,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateFavoritePersonStatus = function (userId, name, isFavorite) { + self.updateFavoritePersonStatus = function(userId, name, isFavorite) { if (!userId) { throw new Error("null userId"); @@ -2978,7 +2925,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateFavoriteStudioStatus = function (userId, name, isFavorite) { + self.updateFavoriteStudioStatus = function(userId, name, isFavorite) { if (!userId) { throw new Error("null userId"); @@ -2999,7 +2946,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateFavoriteGenreStatus = function (userId, name, isFavorite) { + self.updateFavoriteGenreStatus = function(userId, name, isFavorite) { if (!userId) { throw new Error("null userId"); @@ -3020,7 +2967,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateFavoriteMusicGenreStatus = function (userId, name, isFavorite) { + self.updateFavoriteMusicGenreStatus = function(userId, name, isFavorite) { if (!userId) { throw new Error("null userId"); @@ -3041,7 +2988,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateFavoriteGameGenreStatus = function (userId, name, isFavorite) { + self.updateFavoriteGameGenreStatus = function(userId, name, isFavorite) { if (!userId) { throw new Error("null userId"); @@ -3068,7 +3015,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} name * @param {Boolean} likes */ - self.updateArtistRating = function (userId, name, likes) { + self.updateArtistRating = function(userId, name, likes) { if (!userId) { throw new Error("null userId"); @@ -3089,7 +3036,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updatePersonRating = function (userId, name, likes) { + self.updatePersonRating = function(userId, name, likes) { if (!userId) { throw new Error("null userId"); @@ -3110,7 +3057,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateStudioRating = function (userId, name, likes) { + self.updateStudioRating = function(userId, name, likes) { if (!userId) { throw new Error("null userId"); @@ -3131,7 +3078,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateGenreRating = function (userId, name, likes) { + self.updateGenreRating = function(userId, name, likes) { if (!userId) { throw new Error("null userId"); @@ -3152,7 +3099,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateMusicGenreRating = function (userId, name, likes) { + self.updateMusicGenreRating = function(userId, name, likes) { if (!userId) { throw new Error("null userId"); @@ -3173,7 +3120,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.updateGameGenreRating = function (userId, name, likes) { + self.updateGameGenreRating = function(userId, name, likes) { if (!userId) { throw new Error("null userId"); @@ -3199,7 +3146,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} userId * @param {String} name */ - self.clearArtistRating = function (userId, name) { + self.clearArtistRating = function(userId, name) { if (!userId) { throw new Error("null userId"); @@ -3218,7 +3165,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.clearPersonRating = function (userId, name) { + self.clearPersonRating = function(userId, name) { if (!userId) { throw new Error("null userId"); @@ -3237,7 +3184,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.clearStudioRating = function (userId, name) { + self.clearStudioRating = function(userId, name) { if (!userId) { throw new Error("null userId"); @@ -3256,7 +3203,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.clearGenreRating = function (userId, name) { + self.clearGenreRating = function(userId, name) { if (!userId) { throw new Error("null userId"); @@ -3275,7 +3222,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.clearMusicGenreRating = function (userId, name) { + self.clearMusicGenreRating = function(userId, name) { if (!userId) { throw new Error("null userId"); @@ -3294,7 +3241,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.clearGameGenreRating = function (userId, name) { + self.clearGameGenreRating = function(userId, name) { if (!userId) { throw new Error("null userId"); @@ -3313,7 +3260,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getItemCounts = function (userId) { + self.getItemCounts = function(userId) { var options = {}; @@ -3335,7 +3282,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} userId * @param {String} itemId */ - self.clearUserItemRating = function (userId, itemId) { + self.clearUserItemRating = function(userId, itemId) { if (!userId) { throw new Error("null userId"); @@ -3359,7 +3306,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} userId * @param {String} itemId */ - self.reportPlaybackStart = function (userId, itemId, canSeek, queueableMediaTypes) { + self.reportPlaybackStart = function(userId, itemId, canSeek, queueableMediaTypes) { if (!userId) { throw new Error("null userId"); @@ -3385,7 +3332,6 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi } var url = self.getUrl("Users/" + userId + "/PlayingItems/" + itemId, { - CanSeek: canSeek, QueueableMediaTypes: queueableMediaTypes }); @@ -3401,7 +3347,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} userId * @param {String} itemId */ - self.reportPlaybackProgress = function (userId, itemId, positionTicks, isPaused, isMuted) { + self.reportPlaybackProgress = function(userId, itemId, positionTicks, isPaused, isMuted) { if (!userId) { throw new Error("null userId"); @@ -3445,7 +3391,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi * @param {String} userId * @param {String} itemId */ - self.reportPlaybackStopped = function (userId, itemId, positionTicks) { + self.reportPlaybackStopped = function(userId, itemId, positionTicks) { if (!userId) { throw new Error("null userId"); @@ -3466,6 +3412,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi } var params = { + }; if (positionTicks) { @@ -3480,7 +3427,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.sendBrowseCommand = function (sessionId, options) { + self.sendBrowseCommand = function(sessionId, options) { if (!sessionId) { throw new Error("null sessionId"); @@ -3498,7 +3445,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.sendPlayCommand = function (sessionId, options) { + self.sendPlayCommand = function(sessionId, options) { if (!sessionId) { throw new Error("null sessionId"); @@ -3516,7 +3463,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.sendSystemCommand = function (sessionId, command) { + self.sendSystemCommand = function(sessionId, command) { if (!sessionId) { throw new Error("null sessionId"); @@ -3534,7 +3481,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.sendMessageCommand = function (sessionId, options) { + self.sendMessageCommand = function(sessionId, options) { if (!sessionId) { throw new Error("null sessionId"); @@ -3552,7 +3499,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.sendPlayStateCommand = function (sessionId, command, options) { + self.sendPlayStateCommand = function(sessionId, command, options) { if (!sessionId) { throw new Error("null sessionId"); @@ -3570,7 +3517,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.createPackageReview = function (review) { + self.createPackageReview = function(review) { var url = self.getUrl("PackageReviews/" + review.id, review); @@ -3579,7 +3526,39 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi url: url, }); }; - } + + self.getPackageReviews = function (packageId, minRating, maxRating, limit, forceTitle) { + + if (!packageId) { + throw new Error("null packageId"); + } + + var options = {}; + + if (minRating) { + options.MinRating = minRating; + } + if (maxRating) { + options.MaxRating = maxRating; + } + if (limit) { + options.Limit = limit; + } + if (forceTitle) { + options.ForceTitle = true; + } + + var url = self.getUrl("PackageReviews/" + packageId, options); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + + + }; }(jQuery, navigator, window.JSON, window.WebSocket, setTimeout, window);