The Free Software Media System - Server Backend & API
add metadata editor info endpoint
Luke Pulverentie5e39e8e56de
diff --git a/MediaBrowser.Api/ConfigurationService.cs b/MediaBrowser.Api/ConfigurationService.csindex 5fe606e16e..3eb0296fcb 100644--- a/MediaBrowser.Api/ConfigurationService.cs+++ b/MediaBrowser.Api/ConfigurationService.cs@@ -123,7 +123,7 @@ namespace MediaBrowser.Apipublic void Post(AutoSetMetadataOptions request){- _configurationManager.DisableMetadataService("Media Browser Legacy Xml");+ _configurationManager.DisableMetadataService("Media Browser Xml");_configurationManager.SaveConfiguration();}diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.csindex 65c51befff..601feabd53 100644--- a/MediaBrowser.Api/ItemUpdateService.cs+++ b/MediaBrowser.Api/ItemUpdateService.cs@@ -2,7 +2,9 @@using MediaBrowser.Controller.Entities.Audio;using MediaBrowser.Controller.Entities.TV;using MediaBrowser.Controller.Library;+using MediaBrowser.Controller.Localization;using MediaBrowser.Controller.Net;+using MediaBrowser.Controller.Providers;using MediaBrowser.Model.Dto;using ServiceStack;using System;@@ -20,14 +22,40 @@ namespace MediaBrowser.Apipublic 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]public class ItemUpdateService : BaseApiService{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;+ _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)diff --git a/MediaBrowser.Common/Configuration/ConfigurationHelper.cs b/MediaBrowser.Common/Configuration/ConfigurationHelper.csindex 8c904b0dbf..7212b70e1d 100644--- a/MediaBrowser.Common/Configuration/ConfigurationHelper.cs+++ b/MediaBrowser.Common/Configuration/ConfigurationHelper.cs@@ -55,20 +55,5 @@ namespace MediaBrowser.Common.Configurationreturn 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;- }}}diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.csindex 6bbd69f04b..1a536b4ffb 100644--- a/MediaBrowser.Common/Plugins/BasePlugin.cs+++ b/MediaBrowser.Common/Plugins/BasePlugin.cs@@ -164,11 +164,7 @@ namespace MediaBrowser.Common.Plugins/// <summary>/// The _configuration sync lock/// </summary>- private object _configurationSyncLock = new object();- /// <summary>- /// The _configuration initialized- /// </summary>- private bool _configurationInitialized;+ private readonly object _configurationSyncLock = new object();/// <summary>/// The _configuration/// </summary>@@ -182,17 +178,39 @@ namespace MediaBrowser.Common.Pluginsget{// 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;}protected set{_configuration = value;+ }+ }- if (value == null)- {- _configurationInitialized = false;- }+ private TConfigurationType LoadConfiguration()+ {+ 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));}}diff --git a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs b/MediaBrowser.LocalMetadata/BaseXmlProvider.csindex 6f8047e4ce..82e7809e89 100644--- a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs+++ b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs@@ -90,7 +90,7 @@ namespace MediaBrowser.LocalMetadata{get{- return "Media Browser Legacy Xml";+ return "Media Browser Xml";}}diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csprojindex 8994b16c37..ec41ffe0b5 100644--- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj+++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj@@ -461,6 +461,9 @@<Compile Include="..\MediaBrowser.Model\Dto\MediaSourceType.cs"><Link>Dto\MediaSourceType.cs</Link></Compile>+ <Compile Include="..\MediaBrowser.Model\Dto\MetadataEditorInfo.cs">+ <Link>Dto\MetadataEditorInfo.cs</Link>+ </Compile><Compile Include="..\MediaBrowser.Model\Dto\RatingType.cs"><Link>Dto\RatingType.cs</Link></Compile>diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csprojindex fbde4c92d6..01aaad2ac1 100644--- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj+++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj@@ -426,6 +426,9 @@<Compile Include="..\MediaBrowser.Model\Dto\MediaSourceType.cs"><Link>Dto\MediaSourceType.cs</Link></Compile>+ <Compile Include="..\MediaBrowser.Model\Dto\MetadataEditorInfo.cs">+ <Link>Dto\MetadataEditorInfo.cs</Link>+ </Compile><Compile Include="..\MediaBrowser.Model\Dto\RatingType.cs"><Link>Dto\RatingType.cs</Link></Compile>diff --git a/MediaBrowser.Model/Dto/DtoOptions.cs b/MediaBrowser.Model/Dto/DtoOptions.csindex 6a61c7ef2b..069d71fceb 100644--- a/MediaBrowser.Model/Dto/DtoOptions.cs+++ b/MediaBrowser.Model/Dto/DtoOptions.cs@@ -10,7 +10,6 @@ namespace MediaBrowser.Model.Dtopublic List<ImageType> ImageTypes { get; set; }public int ImageTypeLimit { get; set; }public bool EnableImages { get; set; }- public bool EnableSettings { get; set; }public DtoOptions(){diff --git a/MediaBrowser.Model/Dto/MetadataEditorInfo.cs b/MediaBrowser.Model/Dto/MetadataEditorInfo.csnew file mode 100644index 0000000000..66bdb8ce3e--- /dev/null+++ b/MediaBrowser.Model/Dto/MetadataEditorInfo.cs@@ -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>();+ }+ }+}diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csprojindex 47bb62a321..0dd5442edf 100644--- a/MediaBrowser.Model/MediaBrowser.Model.csproj+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj@@ -128,6 +128,7 @@<Compile Include="Drawing\ImageOrientation.cs" /><Compile Include="Dto\DtoOptions.cs" /><Compile Include="Dto\IHasServerId.cs" />+ <Compile Include="Dto\MetadataEditorInfo.cs" /><Compile Include="MediaInfo\LiveMediaInfoResult.cs" /><Compile Include="Dto\MediaSourceType.cs" /><Compile Include="Dto\StreamOptions.cs" />diff --git a/MediaBrowser.Model/Querying/ItemFields.cs b/MediaBrowser.Model/Querying/ItemFields.csindex 0bbb29742e..f288bfe48e 100644--- a/MediaBrowser.Model/Querying/ItemFields.cs+++ b/MediaBrowser.Model/Querying/ItemFields.cs@@ -156,6 +156,11 @@ namespace MediaBrowser.Model.Querying/// </summary>SeasonName,+ /// <summary>+ /// The settings+ /// </summary>+ Settings,+/// <summary>/// The short overview/// </summary>diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.csindex bbf1d8e3ad..a14a8ad08f 100644--- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs+++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs@@ -71,8 +71,7 @@ namespace MediaBrowser.Server.Implementations.Dto{var options = new DtoOptions{- Fields = fields,- EnableSettings = true+ Fields = fields};// Get everything@@ -677,7 +676,7 @@ namespace MediaBrowser.Server.Implementations.Dtodto.IsUnidentified = item.IsUnidentified;}- if (options.EnableSettings)+ if (fields.Contains(ItemFields.Settings)){dto.LockedFields = item.LockedFields;dto.LockData = item.IsLocked;@@ -1170,7 +1169,7 @@ namespace MediaBrowser.Server.Implementations.Dtodto.SeasonCount = series.SeasonCount;- if (options.EnableSettings)+ if (fields.Contains(ItemFields.Settings)){dto.DisplaySpecialsWithSeasons = series.DisplaySpecialsWithSeasons;}diff --git a/MediaBrowser.Server.Startup.Common/Migrations/RenameXmlOptions.cs b/MediaBrowser.Server.Startup.Common/Migrations/RenameXmlOptions.csindex a955b57eaf..be8ae2f814 100644--- a/MediaBrowser.Server.Startup.Common/Migrations/RenameXmlOptions.cs+++ b/MediaBrowser.Server.Startup.Common/Migrations/RenameXmlOptions.cs@@ -42,9 +42,9 @@ namespace MediaBrowser.Server.Startup.Common.Migrations{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;}}