diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs
index ddc099a92..f4b14d5a8 100644
--- a/MediaBrowser.Api/BaseApiService.cs
+++ b/MediaBrowser.Api/BaseApiService.cs
@@ -238,6 +238,54 @@ namespace MediaBrowser.Api
}) ?? name;
}
+
+ ///
+ /// Gets the name of the item by.
+ ///
+ /// The name.
+ /// The type.
+ /// The library manager.
+ /// Task{BaseItem}.
+ ///
+ protected async Task GetItemByName(string name, string type, ILibraryManager libraryManager)
+ {
+ BaseItem item;
+
+ if (type.IndexOf("Person", StringComparison.OrdinalIgnoreCase) == 0)
+ {
+ item = await GetPerson(name, libraryManager).ConfigureAwait(false);
+ }
+ else if (type.IndexOf("Artist", StringComparison.OrdinalIgnoreCase) == 0)
+ {
+ item = await GetArtist(name, libraryManager).ConfigureAwait(false);
+ }
+ else if (type.IndexOf("Genre", StringComparison.OrdinalIgnoreCase) == 0)
+ {
+ item = await GetGenre(name, libraryManager).ConfigureAwait(false);
+ }
+ else if (type.IndexOf("MusicGenre", StringComparison.OrdinalIgnoreCase) == 0)
+ {
+ item = await GetMusicGenre(name, libraryManager).ConfigureAwait(false);
+ }
+ else if (type.IndexOf("GameGenre", StringComparison.OrdinalIgnoreCase) == 0)
+ {
+ item = await GetGameGenre(name, libraryManager).ConfigureAwait(false);
+ }
+ else if (type.IndexOf("Studio", StringComparison.OrdinalIgnoreCase) == 0)
+ {
+ item = await GetStudio(name, libraryManager).ConfigureAwait(false);
+ }
+ else if (type.IndexOf("Year", StringComparison.OrdinalIgnoreCase) == 0)
+ {
+ item = await libraryManager.GetYear(int.Parse(name)).ConfigureAwait(false);
+ }
+ else
+ {
+ throw new ArgumentException();
+ }
+
+ return item;
+ }
}
///
diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs
index e7b4a42c9..678f89c2c 100644
--- a/MediaBrowser.Api/Images/ImageService.cs
+++ b/MediaBrowser.Api/Images/ImageService.cs
@@ -1,12 +1,9 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
-using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Entities.Audio;
-using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Providers;
@@ -39,6 +36,23 @@ namespace MediaBrowser.Api.Images
public string Id { get; set; }
}
+ [Route("/Artists/{Name}/Images", "GET")]
+ [Route("/Genres/{Name}/Images", "GET")]
+ [Route("/GameGenres/{Name}/Images", "GET")]
+ [Route("/MusicGenres/{Name}/Images", "GET")]
+ [Route("/Persons/{Name}/Images", "GET")]
+ [Route("/Studios/{Name}/Images", "GET")]
+ [Api(Description = "Gets information about an item's images")]
+ public class GetItemByNameImageInfos : IReturn>
+ {
+ ///
+ /// Gets or sets the id.
+ ///
+ /// The id.
+ [ApiMember(Name = "Name", Description = "Name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
+ public string Name { get; set; }
+ }
+
[Route("/Items/{Id}/Images/{Type}", "GET")]
[Route("/Items/{Id}/Images/{Type}/{Index}", "GET")]
[Api(Description = "Gets an item image")]
@@ -88,128 +102,73 @@ namespace MediaBrowser.Api.Images
public int NewIndex { get; set; }
}
- ///
- /// Class DeleteItemImage
- ///
- [Route("/Items/{Id}/Images/{Type}", "DELETE")]
- [Route("/Items/{Id}/Images/{Type}/{Index}", "DELETE")]
- [Api(Description = "Deletes an item image")]
- public class DeleteItemImage : DeleteImageRequest, IReturnVoid
+ [Route("/Artists/{Name}/Images/{Type}/{Index}/Index", "POST")]
+ [Route("/Genres/{Name}/Images/{Type}/{Index}/Index", "POST")]
+ [Route("/GameGenres/{Name}/Images/{Type}/{Index}/Index", "POST")]
+ [Route("/MusicGenres/{Name}/Images/{Type}/{Index}/Index", "POST")]
+ [Route("/Persons/{Name}/Images/{Type}/{Index}/Index", "POST")]
+ [Route("/Studios/{Name}/Images/{Type}/{Index}/Index", "POST")]
+ [Route("/Years/{Year}/Images/{Type}/{Index}/Index", "POST")]
+ [Api(Description = "Updates the index for an item image")]
+ public class UpdateItemByNameImageIndex : IReturnVoid
{
///
/// Gets or sets the id.
///
/// The id.
- [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
- public Guid Id { get; set; }
- }
+ [ApiMember(Name = "Name", Description = "Item name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
+ public string Name { get; set; }
+ ///
+ /// Gets or sets the type of the image.
+ ///
+ /// The type of the image.
+ [ApiMember(Name = "Type", Description = "Image Type", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
+ public ImageType Type { get; set; }
+
+ ///
+ /// Gets or sets the index.
+ ///
+ /// The index.
+ [ApiMember(Name = "Index", Description = "Image Index", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "POST")]
+ public int Index { get; set; }
+
+ ///
+ /// Gets or sets the new index.
+ ///
+ /// The new index.
+ [ApiMember(Name = "NewIndex", Description = "The new image index", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public int NewIndex { get; set; }
+ }
+
///
/// Class GetPersonImage
///
- [Route("/Persons/{Name}/Images/{Type}", "GET")]
- [Route("/Persons/{Name}/Images/{Type}/{Index}", "GET")]
- [Api(Description = "Gets a person image")]
- public class GetPersonImage : ImageRequest
- {
- ///
- /// Gets or sets the name.
- ///
- /// The name.
- [ApiMember(Name = "Name", Description = "Person name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
- public string Name { get; set; }
- }
-
- ///
- /// Class GetArtistImage
- ///
[Route("/Artists/{Name}/Images/{Type}", "GET")]
[Route("/Artists/{Name}/Images/{Type}/{Index}", "GET")]
- [Api(Description = "Gets an artist image")]
- public class GetArtistImage : ImageRequest
- {
- ///
- /// Gets or sets the name.
- ///
- /// The name.
- [ApiMember(Name = "Name", Description = "Artist name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
- public string Name { get; set; }
- }
-
- ///
- /// Class GetStudioImage
- ///
- [Route("/Studios/{Name}/Images/{Type}", "GET")]
- [Route("/Studios/{Name}/Images/{Type}/{Index}", "GET")]
- [Api(Description = "Gets a studio image")]
- public class GetStudioImage : ImageRequest
- {
- ///
- /// Gets or sets the name.
- ///
- /// The name.
- [ApiMember(Name = "Name", Description = "Studio name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
- public string Name { get; set; }
- }
-
- ///
- /// Class GetGenreImage
- ///
[Route("/Genres/{Name}/Images/{Type}", "GET")]
[Route("/Genres/{Name}/Images/{Type}/{Index}", "GET")]
- [Api(Description = "Gets a genre image")]
- public class GetGenreImage : ImageRequest
- {
- ///
- /// Gets or sets the name.
- ///
- /// The name.
- [ApiMember(Name = "Name", Description = "Genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
- public string Name { get; set; }
- }
-
- [Route("/MusicGenres/{Name}/Images/{Type}", "GET")]
- [Route("/MusicGenres/{Name}/Images/{Type}/{Index}", "GET")]
- [Api(Description = "Gets a genre image")]
- public class GetMusicGenreImage : ImageRequest
- {
- ///
- /// Gets or sets the name.
- ///
- /// The name.
- [ApiMember(Name = "Name", Description = "Genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
- public string Name { get; set; }
- }
-
[Route("/GameGenres/{Name}/Images/{Type}", "GET")]
[Route("/GameGenres/{Name}/Images/{Type}/{Index}", "GET")]
- [Api(Description = "Gets a genre image")]
- public class GetGameGenreImage : ImageRequest
+ [Route("/MusicGenres/{Name}/Images/{Type}", "GET")]
+ [Route("/MusicGenres/{Name}/Images/{Type}/{Index}", "GET")]
+ [Route("/Persons/{Name}/Images/{Type}", "GET")]
+ [Route("/Persons/{Name}/Images/{Type}/{Index}", "GET")]
+ [Route("/Studios/{Name}/Images/{Type}", "GET")]
+ [Route("/Studios/{Name}/Images/{Type}/{Index}", "GET")]
+ [Route("/Years/{Year}/Images/{Type}", "GET")]
+ [Route("/Years/{Year}/Images/{Type}/{Index}", "GET")]
+ [Api(Description = "Gets an item by name image")]
+ public class GetItemByNameImage : ImageRequest
{
///
/// Gets or sets the name.
///
/// The name.
- [ApiMember(Name = "Name", Description = "Genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
+ [ApiMember(Name = "Name", Description = "Item name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Name { get; set; }
}
- ///
- /// Class GetYearImage
- ///
- [Route("/Years/{Year}/Images/{Type}", "GET")]
- [Route("/Years/{Year}/Images/{Type}/{Index}", "GET")]
- [Api(Description = "Gets a year image")]
- public class GetYearImage : ImageRequest
- {
- ///
- /// Gets or sets the year.
- ///
- /// The year.
- [ApiMember(Name = "Year", Description = "Year", IsRequired = true, DataType = "int", ParameterType = "path", Verb = "GET")]
- public int Year { get; set; }
- }
-
///
/// Class GetUserImage
///
@@ -226,6 +185,47 @@ namespace MediaBrowser.Api.Images
public Guid Id { get; set; }
}
+ ///
+ /// Class DeleteItemImage
+ ///
+ [Route("/Items/{Id}/Images/{Type}", "DELETE")]
+ [Route("/Items/{Id}/Images/{Type}/{Index}", "DELETE")]
+ [Api(Description = "Deletes an item image")]
+ public class DeleteItemImage : DeleteImageRequest, IReturnVoid
+ {
+ ///
+ /// Gets or sets the id.
+ ///
+ /// The id.
+ [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
+ public Guid Id { get; set; }
+ }
+
+ [Route("/Artists/{Name}/Images/{Type}", "DELETE")]
+ [Route("/Artists/{Name}/Images/{Type}/{Index}", "DELETE")]
+ [Route("/Genres/{Name}/Images/{Type}", "DELETE")]
+ [Route("/Genres/{Name}/Images/{Type}/{Index}", "DELETE")]
+ [Route("/GameGenres/{Name}/Images/{Type}", "DELETE")]
+ [Route("/GameGenres/{Name}/Images/{Type}/{Index}", "DELETE")]
+ [Route("/MusicGenres/{Name}/Images/{Type}", "DELETE")]
+ [Route("/MusicGenres/{Name}/Images/{Type}/{Index}", "DELETE")]
+ [Route("/Persons/{Name}/Images/{Type}", "DELETE")]
+ [Route("/Persons/{Name}/Images/{Type}/{Index}", "DELETE")]
+ [Route("/Studios/{Name}/Images/{Type}", "DELETE")]
+ [Route("/Studios/{Name}/Images/{Type}/{Index}", "DELETE")]
+ [Route("/Years/{Year}/Images/{Type}", "DELETE")]
+ [Route("/Years/{Year}/Images/{Type}/{Index}", "DELETE")]
+ [Api(Description = "Deletes an item image")]
+ public class DeleteItemByNameImage : DeleteImageRequest, IReturnVoid
+ {
+ ///
+ /// Gets or sets the id.
+ ///
+ /// The id.
+ [ApiMember(Name = "Name", Description = "Item name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
+ public string Name { get; set; }
+ }
+
///
/// Class DeleteUserImage
///
@@ -286,6 +286,37 @@ namespace MediaBrowser.Api.Images
public Stream RequestStream { get; set; }
}
+ [Route("/Artists/{Name}/Images/{Type}", "POST")]
+ [Route("/Artists/{Name}/Images/{Type}/{Index}", "POST")]
+ [Route("/Genres/{Name}/Images/{Type}", "POST")]
+ [Route("/Genres/{Name}/Images/{Type}/{Index}", "POST")]
+ [Route("/GameGenres/{Name}/Images/{Type}", "POST")]
+ [Route("/GameGenres/{Name}/Images/{Type}/{Index}", "POST")]
+ [Route("/MusicGenres/{Name}/Images/{Type}", "POST")]
+ [Route("/MusicGenres/{Name}/Images/{Type}/{Index}", "POST")]
+ [Route("/Persons/{Name}/Images/{Type}", "POST")]
+ [Route("/Persons/{Name}/Images/{Type}/{Index}", "POST")]
+ [Route("/Studios/{Name}/Images/{Type}", "POST")]
+ [Route("/Studios/{Name}/Images/{Type}/{Index}", "POST")]
+ [Route("/Years/{Year}/Images/{Type}", "POST")]
+ [Route("/Years/{Year}/Images/{Type}/{Index}", "POST")]
+ [Api(Description = "Posts an item image")]
+ public class PostItemByNameImage : DeleteImageRequest, IRequiresRequestStream, IReturnVoid
+ {
+ ///
+ /// Gets or sets the id.
+ ///
+ /// The id.
+ [ApiMember(Name = "Name", Description = "Item name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
+ public string Name { get; set; }
+
+ ///
+ /// The raw Http Request Input Stream
+ ///
+ /// The request stream.
+ public Stream RequestStream { get; set; }
+ }
+
///
/// Class ImageService
///
@@ -306,7 +337,7 @@ namespace MediaBrowser.Api.Images
private readonly IProviderManager _providerManager;
private readonly IItemRepository _itemRepo;
-
+
///
/// Initializes a new instance of the class.
///
@@ -337,6 +368,28 @@ namespace MediaBrowser.Api.Images
return ToOptimizedResult(result);
}
+ public object Get(GetItemByNameImageInfos request)
+ {
+ var result = GetItemByNameImageInfos(request).Result;
+
+ return ToOptimizedResult(result);
+ }
+
+ ///
+ /// Gets the item by name image infos.
+ ///
+ /// The request.
+ /// Task{List{ImageInfo}}.
+ public async Task> GetItemByNameImageInfos(GetItemByNameImageInfos request)
+ {
+ var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
+ var type = pathInfo.GetArgumentValue(0);
+
+ var item = await GetItemByName(request.Name, type, _libraryManager).ConfigureAwait(false);
+
+ return await GetItemImageInfos(item).ConfigureAwait(false);
+ }
+
///
/// Gets the item image infos.
///
@@ -476,80 +529,16 @@ namespace MediaBrowser.Api.Images
return GetImage(request, item);
}
- ///
- /// Gets the specified request.
- ///
- /// The request.
- /// System.Object.
- public object Get(GetYearImage request)
+ public object Get(GetItemByNameImage request)
{
- var item = _libraryManager.GetYear(request.Year).Result;
+ var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
+ var type = pathInfo.GetArgumentValue(0);
+
+ var item = GetItemByName(request.Name, type, _libraryManager).Result;
return GetImage(request, item);
}
- ///
- /// Gets the specified request.
- ///
- /// The request.
- /// System.Object.
- public object Get(GetStudioImage request)
- {
- var item = GetStudio(request.Name, _libraryManager).Result;
-
- return GetImage(request, item);
- }
-
- ///
- /// Gets the specified request.
- ///
- /// The request.
- /// System.Object.
- public object Get(GetPersonImage request)
- {
- var item = GetPerson(request.Name, _libraryManager).Result;
-
- return GetImage(request, item);
- }
-
- ///
- /// Gets the specified request.
- ///
- /// The request.
- /// System.Object.
- public object Get(GetArtistImage request)
- {
- var item = GetArtist(request.Name, _libraryManager).Result;
-
- return GetImage(request, item);
- }
-
- ///
- /// Gets the specified request.
- ///
- /// The request.
- /// System.Object.
- public object Get(GetGenreImage request)
- {
- var item = GetGenre(request.Name, _libraryManager).Result;
-
- return GetImage(request, item);
- }
-
- public object Get(GetMusicGenreImage request)
- {
- var item = GetMusicGenre(request.Name, _libraryManager).Result;
-
- return GetImage(request, item);
- }
-
- public object Get(GetGameGenreImage request)
- {
- var item = GetGameGenre(request.Name, _libraryManager).Result;
-
- return GetImage(request, item);
- }
-
///
/// Posts the specified request.
///
@@ -568,6 +557,21 @@ namespace MediaBrowser.Api.Images
Task.WaitAll(task);
}
+ public void Post(PostItemByNameImage request)
+ {
+ var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
+ var type = pathInfo.GetArgumentValue(0);
+ var name = pathInfo.GetArgumentValue(1);
+
+ request.Type = (ImageType)Enum.Parse(typeof(ImageType), pathInfo.GetArgumentValue(3), true);
+
+ var item = GetItemByName(name, type, _libraryManager).Result;
+
+ var task = PostImage(item, request.RequestStream, request.Type, RequestContext.ContentType);
+
+ Task.WaitAll(task);
+ }
+
///
/// Posts the specified request.
///
@@ -612,6 +616,22 @@ namespace MediaBrowser.Api.Images
Task.WaitAll(task);
}
+ ///
+ /// Deletes the specified request.
+ ///
+ /// The request.
+ public void Delete(DeleteItemByNameImage request)
+ {
+ var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
+ var type = pathInfo.GetArgumentValue(0);
+
+ var item = GetItemByName(request.Name, type, _libraryManager).Result;
+
+ var task = item.DeleteImage(request.Type, request.Index);
+
+ Task.WaitAll(task);
+ }
+
///
/// Posts the specified request.
///
@@ -625,6 +645,22 @@ namespace MediaBrowser.Api.Images
Task.WaitAll(task);
}
+ ///
+ /// Posts the specified request.
+ ///
+ /// The request.
+ public void Post(UpdateItemByNameImageIndex request)
+ {
+ var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
+ var type = pathInfo.GetArgumentValue(0);
+
+ var item = GetItemByName(request.Name, type, _libraryManager).Result;
+
+ var task = UpdateItemIndex(item, request.Type, request.Index, request.NewIndex);
+
+ Task.WaitAll(task);
+ }
+
///
/// Updates the index of the item.
///
diff --git a/MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs b/MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs
index 07885346b..4196db497 100644
--- a/MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using ServiceStack.ServiceHost;
using ServiceStack.Text.Controller;
@@ -215,36 +214,7 @@ namespace MediaBrowser.Api.UserLibrary
/// Task.
protected async Task MarkFavorite(Guid userId, string type, string name, bool isFavorite)
{
- BaseItem item;
-
- if (string.Equals(type, "Persons"))
- {
- item = await GetPerson(name, LibraryManager).ConfigureAwait(false);
- }
- else if (string.Equals(type, "Artists"))
- {
- item = await GetArtist(name, LibraryManager).ConfigureAwait(false);
- }
- else if (string.Equals(type, "Genres"))
- {
- item = await GetGenre(name, LibraryManager).ConfigureAwait(false);
- }
- else if (string.Equals(type, "MusicGenres"))
- {
- item = await GetMusicGenre(name, LibraryManager).ConfigureAwait(false);
- }
- else if (string.Equals(type, "GameGenres"))
- {
- item = await GetGameGenre(name, LibraryManager).ConfigureAwait(false);
- }
- else if (string.Equals(type, "Studios"))
- {
- item = await GetStudio(name, LibraryManager).ConfigureAwait(false);
- }
- else
- {
- throw new ArgumentException();
- }
+ var item = await GetItemByName(name, type, LibraryManager).ConfigureAwait(false);
var key = item.GetUserDataKey();
@@ -267,36 +237,7 @@ namespace MediaBrowser.Api.UserLibrary
/// Task.
protected async Task MarkLike(Guid userId, string type, string name, bool? likes)
{
- BaseItem item;
-
- if (string.Equals(type, "Persons"))
- {
- item = await GetPerson(name, LibraryManager).ConfigureAwait(false);
- }
- else if (string.Equals(type, "Artists"))
- {
- item = await GetArtist(name, LibraryManager).ConfigureAwait(false);
- }
- else if (string.Equals(type, "Genres"))
- {
- item = await GetGenre(name, LibraryManager).ConfigureAwait(false);
- }
- else if (string.Equals(type, "MusicGenres"))
- {
- item = await GetMusicGenre(name, LibraryManager).ConfigureAwait(false);
- }
- else if (string.Equals(type, "GameGenres"))
- {
- item = await GetGameGenre(name, LibraryManager).ConfigureAwait(false);
- }
- else if (string.Equals(type, "Studios"))
- {
- item = await GetStudio(name, LibraryManager).ConfigureAwait(false);
- }
- else
- {
- throw new ArgumentException();
- }
+ var item = await GetItemByName(name, type, LibraryManager).ConfigureAwait(false);
var key = item.GetUserDataKey();
diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs
index bef98bf9d..737fa9fd6 100644
--- a/MediaBrowser.Controller/Entities/TV/Episode.cs
+++ b/MediaBrowser.Controller/Entities/TV/Episode.cs
@@ -73,6 +73,10 @@ namespace MediaBrowser.Controller.Entities.TV
}
}
+ ///
+ /// Gets all genres.
+ ///
+ /// All genres.
[IgnoreDataMember]
public override IEnumerable AllGenres
{
@@ -83,6 +87,10 @@ namespace MediaBrowser.Controller.Entities.TV
}
}
+ ///
+ /// Gets all studios.
+ ///
+ /// All studios.
[IgnoreDataMember]
public override IEnumerable AllStudios
{
diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js
index a75da62dc..e989d8ff1 100644
--- a/MediaBrowser.WebDashboard/ApiClient.js
+++ b/MediaBrowser.WebDashboard/ApiClient.js
@@ -80,18 +80,15 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
else if ($.browser.firefox || $.browser.mozilla) {
name = "Firefox";
}
-
- if (name)
- {
- if ($.browser.version)
- {
- name += " " + $.browser.version;
- }
- }
- else
- {
- name = "Web Browser";
- }
+
+ if (name) {
+ if ($.browser.version) {
+ name += " " + $.browser.version;
+ }
+ }
+ else {
+ name = "Web Browser";
+ }
if ($.browser.ipad) {
name += " Ipad";
@@ -1046,17 +1043,41 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
});
};
- self.deleteItemImage = function (itemId, imageType, imageIndex) {
-
- if (!itemId) {
- throw new Error("null itemId");
- }
+ self.deleteItemImage = function (itemId, itemType, itemName, imageType, imageIndex) {
if (!imageType) {
throw new Error("null imageType");
}
- var url = self.getUrl("Items/" + itemId + "/Images/" + imageType);
+ if (!itemType) {
+ throw new Error("null itemType");
+ }
+
+ var url;
+
+ if (itemType == "Artist") {
+ url = self.getUrl("Artists/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "Genre") {
+ url = self.getUrl("Genres/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "GameGenre") {
+ url = self.getUrl("GameGenres/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "MusicGenre") {
+ url = self.getUrl("MusicGenres/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "Person") {
+ url = self.getUrl("Persons/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "Studio") {
+ url = self.getUrl("Studios/" + self.encodeName(itemName) + "/Images");
+ }
+ else {
+ url = self.getUrl("Items/" + itemId + "/Images");
+ }
+
+ url += "/" + imageType;
if (imageIndex != null) {
url += "/" + imageIndex;
@@ -1068,17 +1089,41 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
});
};
- self.updateItemImageIndex = function (itemId, imageType, imageIndex, newIndex) {
-
- if (!itemId) {
- throw new Error("null itemId");
- }
+ self.updateItemImageIndex = function (itemId, itemType, itemName, imageType, imageIndex, newIndex) {
if (!imageType) {
throw new Error("null imageType");
}
- var url = self.getUrl("Items/" + itemId + "/Images/" + imageType + "/" + imageIndex + "/Index", { newIndex: newIndex });
+ if (!itemType) {
+ throw new Error("null itemType");
+ }
+
+ var url;
+
+ var options = { newIndex: newIndex };
+
+ if (itemType == "Artist") {
+ url = self.getUrl("Artists/" + self.encodeName(itemName) + "/Images/" + imageType + "/" + imageIndex + "/Index", options);
+ }
+ else if (itemType == "Genre") {
+ url = self.getUrl("Genres/" + self.encodeName(itemName) + "/Images/" + imageType + "/" + imageIndex + "/Index", options);
+ }
+ else if (itemType == "GameGenre") {
+ url = self.getUrl("GameGenres/" + self.encodeName(itemName) + "/Images/" + imageType + "/" + imageIndex + "/Index", options);
+ }
+ else if (itemType == "MusicGenre") {
+ url = self.getUrl("MusicGenres/" + self.encodeName(itemName) + "/Images/" + imageType + "/" + imageIndex + "/Index", options);
+ }
+ else if (itemType == "Person") {
+ url = self.getUrl("Persons/" + self.encodeName(itemName) + "/Images/" + imageType + "/" + imageIndex + "/Index", options);
+ }
+ else if (itemType == "Studio") {
+ url = self.getUrl("Studios/" + self.encodeName(itemName) + "/Images/" + imageType + "/" + imageIndex + "/Index", options);
+ }
+ else {
+ url = self.getUrl("Items/" + itemId + "/Images/" + imageType + "/" + imageIndex + "/Index", options);
+ }
return self.ajax({
type: "POST",
@@ -1086,13 +1131,35 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
});
};
- self.getItemImageInfos = function (itemId) {
+ self.getItemImageInfos = function (itemId, itemType, itemName) {
- if (!itemId) {
- throw new Error("null itemId");
+ if (!itemType) {
+ throw new Error("null itemType");
}
- var url = self.getUrl("Items/" + itemId + "/Images");
+ var url;
+
+ if (itemType == "Artist") {
+ url = self.getUrl("Artists/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "Genre") {
+ url = self.getUrl("Genres/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "GameGenre") {
+ url = self.getUrl("GameGenres/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "MusicGenre") {
+ url = self.getUrl("MusicGenres/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "Person") {
+ url = self.getUrl("Persons/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "Studio") {
+ url = self.getUrl("Studios/" + self.encodeName(itemName) + "/Images");
+ }
+ else {
+ url = self.getUrl("Items/" + itemId + "/Images");
+ }
return self.ajax({
type: "GET",
@@ -1191,7 +1258,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
return deferred.promise();
};
- self.uploadItemImage = function (itemId, imageType, file) {
+ self.uploadItemImage = function (itemId, itemType, itemName, imageType, file) {
if (!itemId) {
throw new Error("null itemId");
@@ -1209,6 +1276,32 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("File must be an image.");
}
+ var url;
+
+ if (itemType == "Artist") {
+ url = self.getUrl("Artists/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "Genre") {
+ url = self.getUrl("Genres/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "GameGenre") {
+ url = self.getUrl("GameGenres/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "MusicGenre") {
+ url = self.getUrl("MusicGenres/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "Person") {
+ url = self.getUrl("Persons/" + self.encodeName(itemName) + "/Images");
+ }
+ else if (itemType == "Studio") {
+ url = self.getUrl("Studios/" + self.encodeName(itemName) + "/Images");
+ }
+ else {
+ url = self.getUrl("Items/" + itemId + "/Images");
+ }
+
+ url += "/" + imageType;
+
var deferred = $.Deferred();
var reader = new FileReader();
@@ -1227,8 +1320,6 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
// Split by a comma to remove the url: prefix
var data = e.target.result.split(',')[1];
- var url = self.getUrl("Items/" + itemId + "/Images/" + imageType);
-
self.ajax({
type: "POST",
url: url,
@@ -2243,6 +2334,27 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
});
};
+ self.getAncestorItems = function (itemId, userId) {
+
+ if (!itemId) {
+ throw new Error("null itemId");
+ }
+
+ var options = {};
+
+ if (userId) {
+ options.userId = userId;
+ }
+
+ var url = self.getUrl("Items/" + itemId + "/Ancestors", options);
+
+ return self.ajax({
+ type: "GET",
+ url: url,
+ dataType: "json"
+ });
+ };
+
/**
* Gets items based on a query, typically for children of a folder
* @param {String} userId
@@ -3509,13 +3621,12 @@ MediaBrowser.SHA1 = function (msg) {
/(iphone)/.exec(ua) ||
/(android)/.exec(ua) ||
[];
-
- var browser = match[1] || "";
-
- if (ua.indexOf("like gecko") != -1 && ua.indexOf('webkit') == -1 && ua.indexOf('opera') == -1)
- {
- browser = "msie";
- }
+
+ var browser = match[1] || "";
+
+ if (ua.indexOf("like gecko") != -1 && ua.indexOf('webkit') == -1 && ua.indexOf('opera') == -1) {
+ browser = "msie";
+ }
return {
browser: browser,
diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config
index 8b53d9d78..8fdd0ef05 100644
--- a/MediaBrowser.WebDashboard/packages.config
+++ b/MediaBrowser.WebDashboard/packages.config
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file