mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-07 16:28:56 +01:00
start on content type setting
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user