From c9d9c6ff1f882ec43f8a9d0c956e0a603f9a4916 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 8 Nov 2013 10:35:11 -0500 Subject: [PATCH 01/12] add image saver logging --- MediaBrowser.Server.Implementations/Dto/DtoService.cs | 3 ++- .../IO/DirectoryWatchers.cs | 3 ++- .../Providers/ImageSaver.cs | 11 ++++++++++- .../Providers/ProviderManager.cs | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 0104196e0..a62821a3a 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -165,7 +165,8 @@ namespace MediaBrowser.Server.Implementations.Dto { var folder = (Folder)item; - dto.ChildCount = folder.GetChildren(user, true).Count(); + dto.ChildCount = folder.GetChildren(user, true) + .Count(); if (!(folder is UserRootFolder)) { diff --git a/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs b/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs index 03739cc8f..ffb351222 100644 --- a/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs +++ b/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs @@ -67,7 +67,8 @@ namespace MediaBrowser.Server.Implementations.IO public async void RemoveTempIgnore(string path) { // This is an arbitraty amount of time, but delay it because file system writes often trigger events after RemoveTempIgnore has been called. - await Task.Delay(2000).ConfigureAwait(false); + // Seeing long delays in some situations, especially over the network. + await Task.Delay(40000).ConfigureAwait(false); string val; _tempIgnoredPaths.TryRemove(path, out val); diff --git a/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs b/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs index b8686800f..ff11b9a2b 100644 --- a/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs +++ b/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs @@ -13,6 +13,7 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Model.Logging; namespace MediaBrowser.Server.Implementations.Providers { @@ -37,17 +38,19 @@ namespace MediaBrowser.Server.Implementations.Providers /// private readonly IDirectoryWatchers _directoryWatchers; private readonly IFileSystem _fileSystem; + private readonly ILogger _logger; /// /// Initializes a new instance of the class. /// /// The config. /// The directory watchers. - public ImageSaver(IServerConfigurationManager config, IDirectoryWatchers directoryWatchers, IFileSystem fileSystem) + public ImageSaver(IServerConfigurationManager config, IDirectoryWatchers directoryWatchers, IFileSystem fileSystem, ILogger logger) { _config = config; _directoryWatchers = directoryWatchers; _fileSystem = fileSystem; + _logger = logger; _remoteImageCache = new FileSystemRepository(config.ApplicationPaths.DownloadedImagesDataPath); } @@ -170,7 +173,12 @@ namespace MediaBrowser.Server.Implementations.Providers /// Task. private async Task SaveImageToLocation(Stream source, string path, CancellationToken cancellationToken) { + _logger.Debug("Saving image to {0}", path); + + var parentFolder = Path.GetDirectoryName(path); + _directoryWatchers.TemporarilyIgnore(path); + _directoryWatchers.TemporarilyIgnore(parentFolder); try { @@ -196,6 +204,7 @@ namespace MediaBrowser.Server.Implementations.Providers finally { _directoryWatchers.RemoveTempIgnore(path); + _directoryWatchers.RemoveTempIgnore(parentFolder); } } diff --git a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs index 0252373f0..7b2a038f4 100644 --- a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs +++ b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs @@ -349,7 +349,7 @@ namespace MediaBrowser.Server.Implementations.Providers /// Task. public Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, string sourceUrl, CancellationToken cancellationToken) { - return new ImageSaver(ConfigurationManager, _directoryWatchers, _fileSystem).SaveImage(item, source, mimeType, type, imageIndex, sourceUrl, cancellationToken); + return new ImageSaver(ConfigurationManager, _directoryWatchers, _fileSystem, _logger).SaveImage(item, source, mimeType, type, imageIndex, sourceUrl, cancellationToken); } /// From 4dc0a1e44aaf8fdf7d7c68cdfc7aea292c11bc61 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Fri, 8 Nov 2013 10:57:37 -0500 Subject: [PATCH 02/12] TotalHits was removed from package retrieval - too slow --- MediaBrowser.Model/Updates/PackageInfo.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/MediaBrowser.Model/Updates/PackageInfo.cs b/MediaBrowser.Model/Updates/PackageInfo.cs index 13c4d6194..2263f29fd 100644 --- a/MediaBrowser.Model/Updates/PackageInfo.cs +++ b/MediaBrowser.Model/Updates/PackageInfo.cs @@ -117,12 +117,6 @@ namespace MediaBrowser.Model.Updates /// The name. public string guid { get; set; } - /// - /// Gets or sets the total number of machines who have checked registration for this package (if premium). - /// - /// The total hits. - public int totalHits { get; set; } - /// /// Gets or sets the total number of ratings for this package. /// From dbd014569408c0e67437ca6d408c57f0e6445987 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Fri, 8 Nov 2013 15:53:09 -0500 Subject: [PATCH 03/12] Latest reviews in plug-in detail page --- MediaBrowser.Api/PackageReviewService.cs | 77 ++- .../Entities/PackageReviewInfo.cs | 5 + MediaBrowser.WebDashboard/ApiClient.js | 563 +++++++++--------- 3 files changed, 352 insertions(+), 293 deletions(-) diff --git a/MediaBrowser.Api/PackageReviewService.cs b/MediaBrowser.Api/PackageReviewService.cs index 1aca596c0..cb3c80a83 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 9d71622c3..c350935f4 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 e72d48e3e..e16ba0e33 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); From 09f44715bb72e3d1f514f429d2e40acad1086550 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 8 Nov 2013 16:21:51 -0500 Subject: [PATCH 04/12] upgrade js api client --- MediaBrowser.WebDashboard/ApiClient.js | 400 +++++++++++----------- MediaBrowser.WebDashboard/packages.config | 2 +- MediaBrowser.sln | 3 + 3 files changed, 204 insertions(+), 201 deletions(-) diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js index e16ba0e33..a5621ff4d 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,7 +47,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi } }; - deviceName = (function() { + deviceName = (function () { var name = ""; @@ -83,11 +83,11 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi return name; }()); - self.deviceId = function() { + self.deviceId = function () { return deviceId; }; - self.encodeName = function(name) { + self.encodeName = function (name) { name = name.split('/').join('-'); @@ -100,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"); @@ -127,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"); @@ -148,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 }; @@ -198,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); }; @@ -210,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"); @@ -228,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"); @@ -243,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"); @@ -258,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"); @@ -273,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"); @@ -328,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"); @@ -345,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"); @@ -362,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"); @@ -381,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"); @@ -392,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); @@ -403,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); @@ -414,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); @@ -425,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); @@ -436,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); @@ -447,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); @@ -458,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); @@ -469,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); @@ -480,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); @@ -494,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"); @@ -508,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"); @@ -522,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"); @@ -536,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"); @@ -558,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"); @@ -572,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"); @@ -586,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"); @@ -603,7 +603,7 @@ 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"); @@ -620,7 +620,7 @@ 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"); @@ -636,7 +636,7 @@ 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"); @@ -652,7 +652,7 @@ 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"); @@ -668,7 +668,7 @@ 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"); @@ -684,7 +684,7 @@ 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"); @@ -700,7 +700,7 @@ 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"); @@ -719,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"); @@ -749,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"); @@ -762,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"); @@ -775,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"); @@ -797,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" }); @@ -811,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" }); @@ -825,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"; @@ -841,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"); @@ -855,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"); @@ -869,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"); @@ -883,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"); @@ -900,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"); @@ -915,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); @@ -929,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"); @@ -947,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"); @@ -965,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"; @@ -983,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"); @@ -1001,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"); @@ -1025,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"); @@ -1054,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"); @@ -1079,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"); @@ -1108,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"); @@ -1137,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"); @@ -1156,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"); @@ -1178,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"); @@ -1218,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"); @@ -1232,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"); @@ -1268,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"); @@ -1299,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"); @@ -1314,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); @@ -1331,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"); @@ -1353,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]; @@ -1374,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(); }); }; @@ -1389,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"); @@ -1431,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]; @@ -1450,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(); }); }; @@ -1468,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"); @@ -1483,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"); @@ -1501,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"); @@ -1525,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"); @@ -1546,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"); @@ -1567,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"); @@ -1591,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"); @@ -1615,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"); @@ -1639,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"); @@ -1660,7 +1660,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getPublicUsers = function() { + self.getPublicUsers = function () { var url = self.getUrl("users/public"); @@ -1674,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 || {}); @@ -1688,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"); @@ -1702,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); @@ -1725,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; @@ -1760,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; @@ -1795,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; @@ -1830,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; @@ -1865,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; @@ -1900,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; @@ -1935,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; @@ -1970,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; @@ -2007,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; @@ -2043,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"; @@ -2060,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"; @@ -2090,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"; @@ -2134,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"); @@ -2161,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"); @@ -2188,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"); @@ -2197,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); @@ -2217,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"); @@ -2226,7 +2226,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi var url = self.getUrl("Users/" + userId + "/Password"); var postData = { - + }; postData.resetPassword = true; @@ -2242,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"); @@ -2258,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"); @@ -2274,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"); @@ -2290,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"); @@ -2306,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"); @@ -2322,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"); @@ -2338,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"); @@ -2354,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"); @@ -2373,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"); @@ -2389,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"); @@ -2410,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"); @@ -2431,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"); @@ -2456,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"); @@ -2476,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"); @@ -2514,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"); @@ -2532,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"); @@ -2553,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"); @@ -2571,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"); @@ -2589,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"); @@ -2610,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"); @@ -2631,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"); @@ -2652,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"); @@ -2670,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"); @@ -2694,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"); @@ -2715,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"); @@ -2736,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); @@ -2750,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"); @@ -2768,7 +2768,7 @@ 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; @@ -2779,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"); @@ -2804,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"); @@ -2829,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"); @@ -2856,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"); @@ -2883,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"); @@ -2904,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"); @@ -2925,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"); @@ -2946,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"); @@ -2967,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"); @@ -2988,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"); @@ -3015,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"); @@ -3036,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"); @@ -3057,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"); @@ -3078,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"); @@ -3099,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"); @@ -3120,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"); @@ -3146,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"); @@ -3165,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"); @@ -3184,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"); @@ -3203,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"); @@ -3222,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"); @@ -3241,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"); @@ -3260,7 +3260,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; - self.getItemCounts = function(userId) { + self.getItemCounts = function (userId) { var options = {}; @@ -3282,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"); @@ -3306,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"); @@ -3347,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"); @@ -3391,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"); @@ -3412,7 +3412,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi } var params = { - + }; if (positionTicks) { @@ -3427,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"); @@ -3445,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"); @@ -3463,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"); @@ -3481,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"); @@ -3499,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"); @@ -3517,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); @@ -3526,7 +3526,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi url: url, }); }; - + self.getPackageReviews = function (packageId, minRating, maxRating, limit, forceTitle) { if (!packageId) { diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config index 5ab968880..846153190 100644 --- a/MediaBrowser.WebDashboard/packages.config +++ b/MediaBrowser.WebDashboard/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/MediaBrowser.sln b/MediaBrowser.sln index 744debbcd..0c5360b49 100644 --- a/MediaBrowser.sln +++ b/MediaBrowser.sln @@ -237,4 +237,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(Performance) = preSolution + HasPerformanceSessions = true + EndGlobalSection EndGlobal From 04f165283bb383a9bb7b339444c693a559a57be9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 8 Nov 2013 16:22:02 -0500 Subject: [PATCH 05/12] try to avoid album year of zero --- .../Drawing/IImageProcessor.cs | 2 +- MediaBrowser.Providers/Music/LastfmHelper.cs | 19 ++++++++++++++----- .../Drawing/ImageProcessor.cs | 14 ++++++++++---- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/MediaBrowser.Controller/Drawing/IImageProcessor.cs b/MediaBrowser.Controller/Drawing/IImageProcessor.cs index e4c68a8ab..1a8583489 100644 --- a/MediaBrowser.Controller/Drawing/IImageProcessor.cs +++ b/MediaBrowser.Controller/Drawing/IImageProcessor.cs @@ -68,7 +68,7 @@ namespace MediaBrowser.Controller.Drawing /// The image enhancers. /// Guid. Guid GetImageCacheTag(BaseItem item, ImageType imageType, string originalImagePath, DateTime dateModified, - IEnumerable imageEnhancers); + List imageEnhancers); /// /// Processes the image. diff --git a/MediaBrowser.Providers/Music/LastfmHelper.cs b/MediaBrowser.Providers/Music/LastfmHelper.cs index f529fd44a..d58aa714b 100644 --- a/MediaBrowser.Providers/Music/LastfmHelper.cs +++ b/MediaBrowser.Providers/Music/LastfmHelper.cs @@ -25,8 +25,13 @@ namespace MediaBrowser.Providers.Music } } - artist.PremiereDate = yearFormed > 0 ? new DateTime(yearFormed, 1, 1, 0, 0, 0, DateTimeKind.Utc) : (DateTime?)null; - artist.ProductionYear = yearFormed; + if (yearFormed > 0) + { + artist.PremiereDate = new DateTime(yearFormed, 1, 1, 0, 0, 0, DateTimeKind.Utc); + + artist.ProductionYear = yearFormed; + } + if (data.tags != null && !artist.LockedFields.Contains(MetadataFields.Tags)) { AddTags(artist, data.tags); @@ -102,10 +107,14 @@ namespace MediaBrowser.Providers.Music DateTime release; - if (DateTime.TryParse(data.releasedate, out release) && release.Year != 1901) + if (DateTime.TryParse(data.releasedate, out release)) { - item.PremiereDate = release; - item.ProductionYear = release.Year; + // Lastfm sends back null as sometimes 1901, other times 0 + if (release.Year > 1901) + { + item.PremiereDate = release; + item.ProductionYear = release.Year; + } } if (data.toptags != null && !item.LockedFields.Contains(MetadataFields.Tags)) diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs index 78dcf6fd0..fd980abc8 100644 --- a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs +++ b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs @@ -589,7 +589,7 @@ namespace MediaBrowser.Server.Implementations.Drawing var supportedEnhancers = GetSupportedEnhancers(item, imageType); - return GetImageCacheTag(item, imageType, imagePath, dateModified, supportedEnhancers); + return GetImageCacheTag(item, imageType, imagePath, dateModified, supportedEnhancers.ToList()); } /// @@ -602,7 +602,7 @@ namespace MediaBrowser.Server.Implementations.Drawing /// The image enhancers. /// Guid. /// item - public Guid GetImageCacheTag(BaseItem item, ImageType imageType, string originalImagePath, DateTime dateModified, IEnumerable imageEnhancers) + public Guid GetImageCacheTag(BaseItem item, ImageType imageType, string originalImagePath, DateTime dateModified, List imageEnhancers) { if (item == null) { @@ -619,6 +619,12 @@ namespace MediaBrowser.Server.Implementations.Drawing throw new ArgumentNullException("originalImagePath"); } + // Optimization + if (imageEnhancers.Count == 0) + { + return (originalImagePath + dateModified.Ticks).GetMD5(); + } + // Cache name is created with supported enhancers combined with the last config change so we pick up new config changes var cacheKeys = imageEnhancers.Select(i => i.GetConfigurationCacheKey(item, imageType)).ToList(); cacheKeys.Add(originalImagePath + dateModified.Ticks); @@ -879,7 +885,7 @@ namespace MediaBrowser.Server.Implementations.Drawing { try { - return i.Supports(item as BaseItem, imageType); + return i.Supports(item, imageType); } catch (Exception ex) { @@ -888,7 +894,7 @@ namespace MediaBrowser.Server.Implementations.Drawing return false; } - }).ToList(); + }); } public void Dispose() From ecc89234458e4a01e9362cce86934dd35deb6879 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 8 Nov 2013 16:39:57 -0500 Subject: [PATCH 06/12] encode review input --- MediaBrowser.Api/PackageReviewService.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Api/PackageReviewService.cs b/MediaBrowser.Api/PackageReviewService.cs index cb3c80a83..e0d52ee8a 100644 --- a/MediaBrowser.Api/PackageReviewService.cs +++ b/MediaBrowser.Api/PackageReviewService.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Globalization; +using System.Net; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Constants; @@ -140,13 +141,16 @@ namespace MediaBrowser.Api public void Post(CreateReviewRequest request) { + var reviewText = WebUtility.HtmlEncode(request.Review ?? string.Empty); + var title = WebUtility.HtmlEncode(request.Title ?? string.Empty); + var review = new Dictionary { { "id", request.Id.ToString(CultureInfo.InvariantCulture) }, { "mac", _netManager.GetMacAddress() }, { "rating", request.Rating.ToString(CultureInfo.InvariantCulture) }, { "recommend", request.Recommend.ToString() }, - { "title", request.Title }, - { "review", request.Review }, + { "title", title }, + { "review", reviewText }, }; Task.WaitAll(_httpClient.Post(Constants.MbAdminUrl + "/service/packageReview/update", review, CancellationToken.None)); From 39278e4b837d66774faff7de0437c455a674ef15 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Fri, 8 Nov 2013 17:02:43 -0500 Subject: [PATCH 07/12] Remove registration indicator (will find something else) --- MediaBrowser.sln | 3 --- 1 file changed, 3 deletions(-) diff --git a/MediaBrowser.sln b/MediaBrowser.sln index 0c5360b49..744debbcd 100644 --- a/MediaBrowser.sln +++ b/MediaBrowser.sln @@ -237,7 +237,4 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection EndGlobal From 9d7d8c3c94cc818a154db2853c0dfb2e123a95f7 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 9 Nov 2013 13:43:53 -0500 Subject: [PATCH 08/12] Ignore xbmc actors folder --- .../Library/CoreResolutionIgnoreRule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs index ae4ae2fa9..95ec416b6 100644 --- a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs +++ b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs @@ -25,7 +25,8 @@ namespace MediaBrowser.Server.Implementations.Library "ps3_vprm", "adv_obj", "extrafanart", - "extrathumbs" + "extrathumbs", + ".actors" }.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); From b043336977f78ea4b26d9ae3154b037f8879ecd6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 9 Nov 2013 13:44:09 -0500 Subject: [PATCH 09/12] Add SeriesPrimaryImageTag --- .../Dto/DtoService.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index a62821a3a..d327796f9 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -1052,6 +1052,13 @@ namespace MediaBrowser.Server.Implementations.Dto { dto.SeriesThumbImageTag = GetImageCacheTag(series, ImageType.Thumb, series.GetImage(ImageType.Thumb)); } + + var imagePath = series.PrimaryImagePath; + + if (!string.IsNullOrEmpty(imagePath)) + { + dto.SeriesPrimaryImageTag = GetImageCacheTag(series, ImageType.Primary, imagePath); + } } // Add SeasonInfo @@ -1065,6 +1072,13 @@ namespace MediaBrowser.Server.Implementations.Dto dto.SeriesName = series.Name; dto.AirTime = series.AirTime; dto.SeriesStudio = series.Studios.FirstOrDefault(); + + var imagePath = series.PrimaryImagePath; + + if (!string.IsNullOrEmpty(imagePath)) + { + dto.SeriesPrimaryImageTag = GetImageCacheTag(series, ImageType.Primary, imagePath); + } } var game = item as Game; From 391675a345cb31130cd232789fcc18d80cfae957 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 9 Nov 2013 13:44:38 -0500 Subject: [PATCH 10/12] make web client images more efficient by using max height instead of height --- .../DefaultTheme/DefaultThemeService.cs | 146 ------------------ MediaBrowser.Api/DefaultTheme/Models.cs | 5 - MediaBrowser.Model/Dto/BaseItemDto.cs | 6 + 3 files changed, 6 insertions(+), 151 deletions(-) diff --git a/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs b/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs index bb23f7f7e..df69f68f8 100644 --- a/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs +++ b/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs @@ -288,9 +288,6 @@ namespace MediaBrowser.Api.DefaultTheme var view = new TvView(); - SetFavoriteGenres(view, series, user); - SetFavoriteStudios(view, series, user); - var fields = new List(); var seriesWithBestBackdrops = FilterItemsForBackdropDisplay(seriesWithBackdrops).ToList(); @@ -401,146 +398,6 @@ namespace MediaBrowser.Api.DefaultTheme return ToOptimizedResult(view); } - private void SetFavoriteGenres(TvView view, IEnumerable inputItems, User user) - { - var all = inputItems.SelectMany(i => i.Genres) - .Distinct(StringComparer.OrdinalIgnoreCase); - - view.FavoriteGenres = all.Select(i => - { - try - { - var itemByName = _libraryManager.GetGenre(i); - - var counts = itemByName.GetItemByNameCounts(user); - - var count = counts == null ? 0 : counts.SeriesCount; - - if (count > 0 && _userDataManager.GetUserData(user.Id, itemByName.GetUserDataKey()).IsFavorite) - { - return new ItemByNameInfo - { - Name = itemByName.Name, - ItemCount = count - }; - } - } - catch (Exception ex) - { - _logger.ErrorException("Error getting genre {0}", ex, i); - - } - - return null; - - }).Where(i => i != null).ToList(); - } - - private void SetFavoriteStudios(TvView view, IEnumerable inputItems, User user) - { - var all = inputItems.SelectMany(i => i.Studios) - .Distinct(StringComparer.OrdinalIgnoreCase); - - view.FavoriteStudios = all.Select(i => - { - try - { - var itemByName = _libraryManager.GetStudio(i); - - var counts = itemByName.GetItemByNameCounts(user); - - var count = counts == null ? 0 : counts.SeriesCount; - - if (count > 0 && _userDataManager.GetUserData(user.Id, itemByName.GetUserDataKey()).IsFavorite) - { - return new ItemByNameInfo - { - Name = itemByName.Name, - ItemCount = count - }; - } - } - catch (Exception ex) - { - _logger.ErrorException("Error getting studio {0}", ex, i); - - } - - return null; - - }).Where(i => i != null).ToList(); - } - - private void SetFavoriteGenres(MoviesView view, IEnumerable inputItems, User user) - { - var all = inputItems.SelectMany(i => i.Genres) - .Distinct(StringComparer.OrdinalIgnoreCase); - - view.FavoriteGenres = all.Select(i => - { - try - { - var itemByName = _libraryManager.GetGenre(i); - - var counts = itemByName.GetItemByNameCounts(user); - - var count = counts == null ? 0 : counts.MovieCount; - - if (count > 0 && _userDataManager.GetUserData(user.Id, itemByName.GetUserDataKey()).IsFavorite) - { - return new ItemByNameInfo - { - Name = itemByName.Name, - ItemCount = count - }; - } - } - catch (Exception ex) - { - _logger.ErrorException("Error getting genre {0}", ex, i); - - } - - return null; - - }).Where(i => i != null).ToList(); - } - - private void SetFavoriteStudios(MoviesView view, IEnumerable inputItems, User user) - { - var all = inputItems.SelectMany(i => i.Studios) - .Distinct(StringComparer.OrdinalIgnoreCase); - - view.FavoriteStudios = all.Select(i => - { - try - { - var itemByName = _libraryManager.GetStudio(i); - - var counts = itemByName.GetItemByNameCounts(user); - - var count = counts == null ? 0 : counts.MovieCount; - - if (count > 0 && _userDataManager.GetUserData(user.Id, itemByName.GetUserDataKey()).IsFavorite) - { - return new ItemByNameInfo - { - Name = itemByName.Name, - ItemCount = count - }; - } - } - catch (Exception ex) - { - _logger.ErrorException("Error getting studio {0}", ex, i); - - } - - return null; - - }).Where(i => i != null).ToList(); - } - public object Get(GetMovieView request) { var user = _userManager.GetUserById(request.UserId); @@ -557,9 +414,6 @@ namespace MediaBrowser.Api.DefaultTheme var movies = items.OfType() .ToList(); - SetFavoriteGenres(view, movies, user); - SetFavoriteStudios(view, movies, user); - var trailers = items.OfType() .ToList(); diff --git a/MediaBrowser.Api/DefaultTheme/Models.cs b/MediaBrowser.Api/DefaultTheme/Models.cs index bdff82de2..5219c44f9 100644 --- a/MediaBrowser.Api/DefaultTheme/Models.cs +++ b/MediaBrowser.Api/DefaultTheme/Models.cs @@ -34,9 +34,6 @@ namespace MediaBrowser.Api.DefaultTheme public List LatestTrailers { get; set; } public List LatestMovies { get; set; } - - public List FavoriteGenres { get; set; } - public List FavoriteStudios { get; set; } } public class TvView : BaseView @@ -47,8 +44,6 @@ namespace MediaBrowser.Api.DefaultTheme public List RomanceItems { get; set; } public List ComedyItems { get; set; } - public List FavoriteGenres { get; set; } - public List FavoriteStudios { get; set; } public List SeriesIdsInProgress { get; set; } public List LatestEpisodes { get; set; } diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 501095f24..1d50a5933 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -383,6 +383,12 @@ namespace MediaBrowser.Model.Dto /// The album image tag. public Guid? AlbumPrimaryImageTag { get; set; } + /// + /// Gets or sets the series primary image tag. + /// + /// The series primary image tag. + public Guid? SeriesPrimaryImageTag { get; set; } + /// /// Gets or sets the album artist. /// From 90e75c05b76a8a8dcb31dded553eae7258eca624 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 9 Nov 2013 14:04:51 -0500 Subject: [PATCH 11/12] rename da.txt to dk.txt --- .../Localization/Ratings/{da.txt => dk.txt} | 0 .../MediaBrowser.Server.Implementations.csproj | 2 +- MediaBrowser.sln | 3 +++ 3 files changed, 4 insertions(+), 1 deletion(-) rename MediaBrowser.Server.Implementations/Localization/Ratings/{da.txt => dk.txt} (100%) diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/da.txt b/MediaBrowser.Server.Implementations/Localization/Ratings/dk.txt similarity index 100% rename from MediaBrowser.Server.Implementations/Localization/Ratings/da.txt rename to MediaBrowser.Server.Implementations/Localization/Ratings/dk.txt diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 017dc2b54..ac451e1eb 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -250,7 +250,7 @@ - + diff --git a/MediaBrowser.sln b/MediaBrowser.sln index 744debbcd..0c5360b49 100644 --- a/MediaBrowser.sln +++ b/MediaBrowser.sln @@ -237,4 +237,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(Performance) = preSolution + HasPerformanceSessions = true + EndGlobalSection EndGlobal From 0bf016d0ff500a2a2ffc51a22f90748b79d6dbbc Mon Sep 17 00:00:00 2001 From: Mark Linton Date: Sun, 10 Nov 2013 10:11:42 -0800 Subject: [PATCH 12/12] Expose Rar support --- .../Archiving/ZipClient.cs | 39 +++++++++++++++++++ MediaBrowser.Model/IO/IZipClient.cs | 16 ++++++++ 2 files changed, 55 insertions(+) diff --git a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs b/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs index 2b66617af..23d40cf67 100644 --- a/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs +++ b/MediaBrowser.Common.Implementations/Archiving/ZipClient.cs @@ -1,4 +1,5 @@ using MediaBrowser.Model.IO; +using SharpCompress.Archive.Rar; using SharpCompress.Archive.SevenZip; using SharpCompress.Archive.Tar; using SharpCompress.Common; @@ -123,5 +124,43 @@ namespace MediaBrowser.Common.Implementations.Archiving } } } + + /// + /// Extracts all from rar. + /// + /// The source file. + /// The target path. + /// if set to true [overwrite existing files]. + public void ExtractAllFromRar(string sourceFile, string targetPath, bool overwriteExistingFiles) + { + using (var fileStream = File.OpenRead(sourceFile)) + { + ExtractAllFromRar(fileStream, targetPath, overwriteExistingFiles); + } + } + + /// + /// Extracts all from rar. + /// + /// The source. + /// The target path. + /// if set to true [overwrite existing files]. + public void ExtractAllFromRar(Stream source, string targetPath, bool overwriteExistingFiles) + { + using (var archive = RarArchive.Open(source)) + { + using (var reader = archive.ExtractAllEntries()) + { + var options = ExtractOptions.ExtractFullPath; + + if (overwriteExistingFiles) + { + options = options | ExtractOptions.Overwrite; + } + + reader.WriteAllToDirectory(targetPath, options); + } + } + } } } diff --git a/MediaBrowser.Model/IO/IZipClient.cs b/MediaBrowser.Model/IO/IZipClient.cs index 1fa3e0271..ba0725da5 100644 --- a/MediaBrowser.Model/IO/IZipClient.cs +++ b/MediaBrowser.Model/IO/IZipClient.cs @@ -54,5 +54,21 @@ namespace MediaBrowser.Model.IO /// The target path. /// if set to true [overwrite existing files]. void ExtractAllFromTar(Stream source, string targetPath, bool overwriteExistingFiles); + + /// + /// Extracts all from rar. + /// + /// The source file. + /// The target path. + /// if set to true [overwrite existing files]. + void ExtractAllFromRar(string sourceFile, string targetPath, bool overwriteExistingFiles); + + /// + /// Extracts all from rar. + /// + /// The source. + /// The target path. + /// if set to true [overwrite existing files]. + void ExtractAllFromRar(Stream source, string targetPath, bool overwriteExistingFiles); } }