diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-12-21 13:58:17 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-12-21 13:58:17 -0500 |
| commit | 74520804f80974ec018a6c45f4e221276ded4cd3 (patch) | |
| tree | 6315b8ab2ab96d4e2006148a7c0615ce0e9ff0ea /MediaBrowser.Api/ItemUpdateService.cs | |
| parent | 659128073eda8178de75f2234467b03da747691c (diff) | |
start on content type setting
Diffstat (limited to 'MediaBrowser.Api/ItemUpdateService.cs')
| -rw-r--r-- | MediaBrowser.Api/ItemUpdateService.cs | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 601feabd5..953f7b3bb 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -6,6 +6,7 @@ using MediaBrowser.Controller.Localization; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Entities; using ServiceStack; using System; using System.Collections.Generic; @@ -28,6 +29,16 @@ namespace MediaBrowser.Api [ApiMember(Name = "ItemId", Description = "The id of the item", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] public string ItemId { get; set; } } + + [Route("/Items/{ItemId}/ContentType", "POST", Summary = "Updates an item's content type")] + public class UpdateItemContentType : IReturnVoid + { + [ApiMember(Name = "ItemId", Description = "The id of the item", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public string ItemId { get; set; } + + [ApiMember(Name = "ContentType", Description = "The content type of the item", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")] + public string ContentType { get; set; } + } [Authenticated] public class ItemUpdateService : BaseApiService @@ -55,9 +66,102 @@ namespace MediaBrowser.Api Cultures = _localizationManager.GetCultures().ToList() }; + var locationType = item.LocationType; + if (locationType == LocationType.FileSystem || + locationType == LocationType.Offline) + { + var collectionType = _libraryManager.GetInheritedContentType(item); + if (string.IsNullOrWhiteSpace(collectionType)) + { + info.ContentTypeOptions = GetContentTypeOptions(true); + info.ContentType = _libraryManager.GetContentType(item); + } + } + return ToOptimizedResult(info); } + public void Post(UpdateItemContentType request) + { + + } + + private List<NameValuePair> GetContentTypeOptions(bool isForItem) + { + var list = new List<NameValuePair>(); + + if (isForItem) + { + list.Add(new NameValuePair + { + Name = "FolderTypeInherit", + Value = "" + }); + } + + list.Add(new NameValuePair + { + Name = "FolderTypeMovies", + Value = "movies" + }); + list.Add(new NameValuePair + { + Name = "FolderTypeMusic", + Value = "music" + }); + list.Add(new NameValuePair + { + Name = "FolderTypeTvShows", + Value = "tvshows" + }); + + if (!isForItem) + { + list.Add(new NameValuePair + { + Name = "FolderTypeBooks", + Value = "books" + }); + list.Add(new NameValuePair + { + Name = "FolderTypeGames", + Value = "games" + }); + } + + list.Add(new NameValuePair + { + Name = "FolderTypeHomeVideos", + Value = "homevideos" + }); + list.Add(new NameValuePair + { + Name = "FolderTypeMusicVideos", + Value = "musicvideos" + }); + list.Add(new NameValuePair + { + Name = "FolderTypePhotos", + Value = "photos" + }); + + if (!isForItem) + { + list.Add(new NameValuePair + { + Name = "FolderTypeMixed", + Value = "" + }); + } + + foreach (var val in list) + { + val.Name = _localizationManager.GetLocalizedString(val.Name); + } + + return list; + } + public void Post(UpdateItem request) { var task = UpdateItem(request); |
