add metadata editor info endpoint

pull/702/head
Luke Pulverenti 10 years ago
parent 7b0306dce7
commit e5e39e8e56

@ -123,7 +123,7 @@ namespace MediaBrowser.Api
public void Post(AutoSetMetadataOptions request) public void Post(AutoSetMetadataOptions request)
{ {
_configurationManager.DisableMetadataService("Media Browser Legacy Xml"); _configurationManager.DisableMetadataService("Media Browser Xml");
_configurationManager.SaveConfiguration(); _configurationManager.SaveConfiguration();
} }

@ -2,7 +2,9 @@
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using ServiceStack; using ServiceStack;
using System; using System;
@ -20,14 +22,40 @@ namespace MediaBrowser.Api
public string ItemId { get; set; } public string ItemId { get; set; }
} }
[Route("/Items/{ItemId}/MetadataEditor", "GET", Summary = "Gets metadata editor info for an item")]
public class GetMetadataEditorInfo : IReturn<MetadataEditorInfo>
{
[ApiMember(Name = "ItemId", Description = "The id of the item", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string ItemId { get; set; }
}
[Authenticated] [Authenticated]
public class ItemUpdateService : BaseApiService public class ItemUpdateService : BaseApiService
{ {
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
private readonly IProviderManager _providerManager;
private readonly ILocalizationManager _localizationManager;
public ItemUpdateService(ILibraryManager libraryManager) public ItemUpdateService(ILibraryManager libraryManager, IProviderManager providerManager, ILocalizationManager localizationManager)
{ {
_libraryManager = libraryManager; _libraryManager = libraryManager;
_providerManager = providerManager;
_localizationManager = localizationManager;
}
public object Get(GetMetadataEditorInfo request)
{
var item = _libraryManager.GetItemById(request.ItemId);
var info = new MetadataEditorInfo
{
ParentalRatingOptions = _localizationManager.GetParentalRatings().ToList(),
ExternalIdInfos = _providerManager.GetExternalIdInfos(item).ToList(),
Countries = _localizationManager.GetCountries().ToList(),
Cultures = _localizationManager.GetCultures().ToList()
};
return ToOptimizedResult(info);
} }
public void Post(UpdateItem request) public void Post(UpdateItem request)

@ -55,20 +55,5 @@ namespace MediaBrowser.Common.Configuration
return configuration; return configuration;
} }
} }
/// <summary>
/// Reads an xml configuration file from the file system
/// It will immediately save the configuration after loading it, just
/// in case there are new serializable properties
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="path">The path.</param>
/// <param name="xmlSerializer">The XML serializer.</param>
/// <returns>``0.</returns>
public static T GetXmlConfiguration<T>(string path, IXmlSerializer xmlSerializer)
where T : class
{
return GetXmlConfiguration(typeof(T), path, xmlSerializer) as T;
}
} }
} }

@ -164,11 +164,7 @@ namespace MediaBrowser.Common.Plugins
/// <summary> /// <summary>
/// The _configuration sync lock /// The _configuration sync lock
/// </summary> /// </summary>
private object _configurationSyncLock = new object(); private readonly object _configurationSyncLock = new object();
/// <summary>
/// The _configuration initialized
/// </summary>
private bool _configurationInitialized;
/// <summary> /// <summary>
/// The _configuration /// The _configuration
/// </summary> /// </summary>
@ -182,17 +178,39 @@ namespace MediaBrowser.Common.Plugins
get get
{ {
// Lazy load // Lazy load
LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => ConfigurationHelper.GetXmlConfiguration(ConfigurationType, ConfigurationFilePath, XmlSerializer) as TConfigurationType); if (_configuration == null)
{
lock (_configurationSyncLock)
{
if (_configuration == null)
{
_configuration = LoadConfiguration();
}
}
}
return _configuration; return _configuration;
} }
protected set protected set
{ {
_configuration = value; _configuration = value;
}
}
if (value == null) private TConfigurationType LoadConfiguration()
{ {
_configurationInitialized = false; var path = ConfigurationFilePath;
}
try
{
return (TConfigurationType)XmlSerializer.DeserializeFromFile(typeof(TConfigurationType), path);
}
catch (FileNotFoundException)
{
return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
}
catch (Exception ex)
{
return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
} }
} }

@ -90,7 +90,7 @@ namespace MediaBrowser.LocalMetadata
{ {
get get
{ {
return "Media Browser Legacy Xml"; return "Media Browser Xml";
} }
} }

@ -461,6 +461,9 @@
<Compile Include="..\MediaBrowser.Model\Dto\MediaSourceType.cs"> <Compile Include="..\MediaBrowser.Model\Dto\MediaSourceType.cs">
<Link>Dto\MediaSourceType.cs</Link> <Link>Dto\MediaSourceType.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\Dto\MetadataEditorInfo.cs">
<Link>Dto\MetadataEditorInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\RatingType.cs"> <Compile Include="..\MediaBrowser.Model\Dto\RatingType.cs">
<Link>Dto\RatingType.cs</Link> <Link>Dto\RatingType.cs</Link>
</Compile> </Compile>

@ -426,6 +426,9 @@
<Compile Include="..\MediaBrowser.Model\Dto\MediaSourceType.cs"> <Compile Include="..\MediaBrowser.Model\Dto\MediaSourceType.cs">
<Link>Dto\MediaSourceType.cs</Link> <Link>Dto\MediaSourceType.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\Dto\MetadataEditorInfo.cs">
<Link>Dto\MetadataEditorInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\RatingType.cs"> <Compile Include="..\MediaBrowser.Model\Dto\RatingType.cs">
<Link>Dto\RatingType.cs</Link> <Link>Dto\RatingType.cs</Link>
</Compile> </Compile>

@ -10,7 +10,6 @@ namespace MediaBrowser.Model.Dto
public List<ImageType> ImageTypes { get; set; } public List<ImageType> ImageTypes { get; set; }
public int ImageTypeLimit { get; set; } public int ImageTypeLimit { get; set; }
public bool EnableImages { get; set; } public bool EnableImages { get; set; }
public bool EnableSettings { get; set; }
public DtoOptions() public DtoOptions()
{ {

@ -0,0 +1,23 @@
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Providers;
using System.Collections.Generic;
namespace MediaBrowser.Model.Dto
{
public class MetadataEditorInfo
{
public List<ParentalRating> ParentalRatingOptions { get; set; }
public List<CountryInfo> Countries { get; set; }
public List<CultureDto> Cultures { get; set; }
public List<ExternalIdInfo> ExternalIdInfos { get; set; }
public MetadataEditorInfo()
{
ParentalRatingOptions = new List<ParentalRating>();
Countries = new List<CountryInfo>();
Cultures = new List<CultureDto>();
ExternalIdInfos = new List<ExternalIdInfo>();
}
}
}

@ -128,6 +128,7 @@
<Compile Include="Drawing\ImageOrientation.cs" /> <Compile Include="Drawing\ImageOrientation.cs" />
<Compile Include="Dto\DtoOptions.cs" /> <Compile Include="Dto\DtoOptions.cs" />
<Compile Include="Dto\IHasServerId.cs" /> <Compile Include="Dto\IHasServerId.cs" />
<Compile Include="Dto\MetadataEditorInfo.cs" />
<Compile Include="MediaInfo\LiveMediaInfoResult.cs" /> <Compile Include="MediaInfo\LiveMediaInfoResult.cs" />
<Compile Include="Dto\MediaSourceType.cs" /> <Compile Include="Dto\MediaSourceType.cs" />
<Compile Include="Dto\StreamOptions.cs" /> <Compile Include="Dto\StreamOptions.cs" />

@ -156,6 +156,11 @@ namespace MediaBrowser.Model.Querying
/// </summary> /// </summary>
SeasonName, SeasonName,
/// <summary>
/// The settings
/// </summary>
Settings,
/// <summary> /// <summary>
/// The short overview /// The short overview
/// </summary> /// </summary>

@ -71,8 +71,7 @@ namespace MediaBrowser.Server.Implementations.Dto
{ {
var options = new DtoOptions var options = new DtoOptions
{ {
Fields = fields, Fields = fields
EnableSettings = true
}; };
// Get everything // Get everything
@ -677,7 +676,7 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.IsUnidentified = item.IsUnidentified; dto.IsUnidentified = item.IsUnidentified;
} }
if (options.EnableSettings) if (fields.Contains(ItemFields.Settings))
{ {
dto.LockedFields = item.LockedFields; dto.LockedFields = item.LockedFields;
dto.LockData = item.IsLocked; dto.LockData = item.IsLocked;
@ -1170,7 +1169,7 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.SeasonCount = series.SeasonCount; dto.SeasonCount = series.SeasonCount;
if (options.EnableSettings) if (fields.Contains(ItemFields.Settings))
{ {
dto.DisplaySpecialsWithSeasons = series.DisplaySpecialsWithSeasons; dto.DisplaySpecialsWithSeasons = series.DisplaySpecialsWithSeasons;
} }

@ -42,9 +42,9 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
{ {
for (var i = 0; i < options.Length; i++) for (var i = 0; i < options.Length; i++)
{ {
if (string.Equals(options[i], "Media Browser Xml", StringComparison.OrdinalIgnoreCase)) if (string.Equals(options[i], "Media Browser Legacy Xml", StringComparison.OrdinalIgnoreCase))
{ {
options[i] = "Media Browser Legacy Xml"; options[i] = "Media Browser Xml";
changed = true; changed = true;
} }
} }

Loading…
Cancel
Save