diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.cs
index ecd9f6fb6e..4e7c19a336 100644
--- a/MediaBrowser.Api/LibraryService.cs
+++ b/MediaBrowser.Api/LibraryService.cs
@@ -127,6 +127,13 @@ namespace MediaBrowser.Api
public Guid? UserId { get; set; }
}
+ [Route("/Items/{ItemId}", "POST")]
+ [Api(("Updates an item"))]
+ public class UpdateItem : BaseItemDto, IReturnVoid
+ {
+ public string ItemId { get; set; }
+ }
+
///
/// Class LibraryService
///
@@ -147,6 +154,7 @@ namespace MediaBrowser.Api
/// The item repo.
/// The library manager.
/// The user manager.
+ /// The user data repository.
public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager,
IUserDataRepository userDataRepository)
{
@@ -222,6 +230,67 @@ namespace MediaBrowser.Api
}
}
+ public void Post(UpdateItem request)
+ {
+ var task = UpdateItem(request);
+
+ Task.WaitAll(task);
+ }
+
+ private Task UpdateItem(UpdateItem request)
+ {
+ var item = DtoBuilder.GetItemByClientId(request.ItemId, _userManager, _libraryManager);
+
+ item.Name = request.Name;
+ item.ForcedSortName = request.SortName;
+ item.DisplayMediaType = request.DisplayMediaType;
+ item.CommunityRating = request.CommunityRating;
+ item.HomePageUrl = request.HomePageUrl;
+ item.Budget = request.Budget;
+ item.Revenue = request.Revenue;
+ item.CriticRating = request.CriticRating;
+ item.CriticRatingSummary = request.CriticRatingSummary;
+ item.IndexNumber = request.IndexNumber;
+ item.ParentIndexNumber = request.ParentIndexNumber;
+
+ item.EndDate = request.EndDate;
+ item.PremiereDate = request.PremiereDate;
+ item.ProductionYear = request.ProductionYear;
+ item.AspectRatio = request.AspectRatio;
+ item.Language = request.Language;
+ item.OfficialRating = request.OfficialRating;
+ item.CustomRating = request.CustomRating;
+
+
+ foreach (var pair in request.ProviderIds.ToList())
+ {
+ if (string.IsNullOrEmpty(pair.Value))
+ {
+ request.ProviderIds.Remove(pair.Key);
+ }
+ }
+
+ item.ProviderIds = request.ProviderIds;
+
+ var game = item as BaseGame;
+
+ if (game != null)
+ {
+ game.PlayersSupported = request.Players;
+ }
+
+ var song = item as Audio;
+
+ if (song != null)
+ {
+ song.Album = request.Album;
+ song.AlbumArtist = request.AlbumArtist;
+ song.Artist = request.Artists[0];
+ }
+
+ return _libraryManager.UpdateItem(item, CancellationToken.None);
+ }
+
///
/// Deletes the specified request.
///
diff --git a/MediaBrowser.Model/DTO/BaseItemDto.cs b/MediaBrowser.Model/DTO/BaseItemDto.cs
index e2280f2172..05f958f257 100644
--- a/MediaBrowser.Model/DTO/BaseItemDto.cs
+++ b/MediaBrowser.Model/DTO/BaseItemDto.cs
@@ -66,6 +66,12 @@ namespace MediaBrowser.Model.Dto
/// The official rating.
public string OfficialRating { get; set; }
+ ///
+ /// Gets or sets the custom rating.
+ ///
+ /// The custom rating.
+ public string CustomRating { get; set; }
+
///
/// Gets or sets the overview.
///
diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js
index 799c267eb2..2442141e6c 100644
--- a/MediaBrowser.WebDashboard/ApiClient.js
+++ b/MediaBrowser.WebDashboard/ApiClient.js
@@ -1714,6 +1714,22 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
});
};
+ self.updateItem = function (item) {
+
+ if (!item) {
+ throw new Error("null item");
+ }
+
+ var url = self.getUrl("Items/" + item.Id);
+
+ return self.ajax({
+ type: "POST",
+ url: url,
+ data: JSON.stringify(item),
+ contentType: "application/json"
+ });
+ };
+
/**
* Updates plugin security info
*/
diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config
index fcfa61b2b6..b575b4c458 100644
--- a/MediaBrowser.WebDashboard/packages.config
+++ b/MediaBrowser.WebDashboard/packages.config
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file