aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/ConfigurationService.cs2
-rw-r--r--MediaBrowser.Api/ItemUpdateService.cs30
-rw-r--r--MediaBrowser.Common/Configuration/ConfigurationHelper.cs15
-rw-r--r--MediaBrowser.Common/Plugins/BasePlugin.cs38
-rw-r--r--MediaBrowser.LocalMetadata/BaseXmlProvider.cs2
-rw-r--r--MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj3
-rw-r--r--MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj3
-rw-r--r--MediaBrowser.Model/Dto/DtoOptions.cs1
-rw-r--r--MediaBrowser.Model/Dto/MetadataEditorInfo.cs23
-rw-r--r--MediaBrowser.Model/MediaBrowser.Model.csproj1
-rw-r--r--MediaBrowser.Model/Querying/ItemFields.cs5
-rw-r--r--MediaBrowser.Server.Implementations/Dto/DtoService.cs7
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/RenameXmlOptions.cs4
13 files changed, 99 insertions, 35 deletions
diff --git a/MediaBrowser.Api/ConfigurationService.cs b/MediaBrowser.Api/ConfigurationService.cs
index 5fe606e16..3eb0296fc 100644
--- a/MediaBrowser.Api/ConfigurationService.cs
+++ b/MediaBrowser.Api/ConfigurationService.cs
@@ -123,7 +123,7 @@ namespace MediaBrowser.Api
public 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.cs
index 65c51beff..601feabd5 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.Api
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]
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.cs
index 8c904b0db..7212b70e1 100644
--- a/MediaBrowser.Common/Configuration/ConfigurationHelper.cs
+++ b/MediaBrowser.Common/Configuration/ConfigurationHelper.cs
@@ -55,20 +55,5 @@ namespace MediaBrowser.Common.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;
- }
}
}
diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs
index 6bbd69f04..1a536b4ff 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.Plugins
get
{
// 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.cs
index 6f8047e4c..82e7809e8 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.csproj
index 8994b16c3..ec41ffe0b 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.csproj
index fbde4c92d..01aaad2ac 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.cs
index 6a61c7ef2..069d71fce 100644
--- a/MediaBrowser.Model/Dto/DtoOptions.cs
+++ b/MediaBrowser.Model/Dto/DtoOptions.cs
@@ -10,7 +10,6 @@ namespace MediaBrowser.Model.Dto
public 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.cs
new file mode 100644
index 000000000..66bdb8ce3
--- /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.csproj
index 47bb62a32..0dd5442ed 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.cs
index 0bbb29742..f288bfe48 100644
--- a/MediaBrowser.Model/Querying/ItemFields.cs
+++ b/MediaBrowser.Model/Querying/ItemFields.cs
@@ -157,6 +157,11 @@ namespace MediaBrowser.Model.Querying
SeasonName,
/// <summary>
+ /// The settings
+ /// </summary>
+ Settings,
+
+ /// <summary>
/// The short overview
/// </summary>
ShortOverview,
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
index bbf1d8e3a..a14a8ad08 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.Dto
dto.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.Dto
dto.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.cs
index a955b57ea..be8ae2f81 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;
}
}