The Free Software Media System - Server Backend & API
fix artist editor
Luke Pulverenti67505e24bdcc
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.csindex f6817e0e7b..8868daacab 100644--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs@@ -538,12 +538,6 @@ namespace MediaBrowser.Api.LiveTv[Authenticated]public class GetLiveTvRegistrationInfo : IReturn<MBRegistrationRecord>{- [ApiMember(Name = "ChannelId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]- public string ChannelId { get; set; }-- [ApiMember(Name = "ProgramId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]- public string ProgramId { get; set; }-[ApiMember(Name = "Feature", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]public string Feature { get; set; }}@@ -595,7 +589,7 @@ namespace MediaBrowser.Api.LiveTvpublic async Task<object> Get(GetLiveTvRegistrationInfo request){- var result = await _liveTvManager.GetRegistrationInfo(request.ChannelId, request.ProgramId, request.Feature).ConfigureAwait(false);+ var result = await _liveTvManager.GetRegistrationInfo(request.Feature).ConfigureAwait(false);return ToOptimizedResult(result);}diff --git a/MediaBrowser.Controller/Library/NameExtensions.cs b/MediaBrowser.Controller/Library/NameExtensions.csindex 6973dce64f..72f036b0a5 100644--- a/MediaBrowser.Controller/Library/NameExtensions.cs+++ b/MediaBrowser.Controller/Library/NameExtensions.cs@@ -54,7 +54,7 @@ namespace MediaBrowser.Controller.Library}}- class TextComparer : IComparer<string>, IEqualityComparer<string>+ public class DistinctNameComparer : IComparer<string>, IEqualityComparer<string>{public int Compare(string x, string y){@@ -63,7 +63,7 @@ namespace MediaBrowser.Controller.Libraryreturn 0;}- return string.Compare(x, y, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace);+ return string.Compare(x.RemoveDiacritics(), y.RemoveDiacritics(), StringComparison.OrdinalIgnoreCase);}public bool Equals(string x, string y)diff --git a/MediaBrowser.Controller/LiveTv/IHasRegistrationInfo.cs b/MediaBrowser.Controller/LiveTv/IHasRegistrationInfo.csdeleted file mode 100644index 3626c18e54..0000000000--- a/MediaBrowser.Controller/LiveTv/IHasRegistrationInfo.cs+++ /dev/null@@ -1,15 +0,0 @@-using MediaBrowser.Model.Entities;-using System.Threading.Tasks;--namespace MediaBrowser.Controller.LiveTv-{- public interface IHasRegistrationInfo- {- /// <summary>- /// Gets the registration information.- /// </summary>- /// <param name="feature">The feature.</param>- /// <returns>Task<MBRegistrationRecord>.</returns>- Task<MBRegistrationRecord> GetRegistrationInfo(string feature);- }-}diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.csindex ed64127c38..d30231eb96 100644--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs@@ -364,11 +364,9 @@ namespace MediaBrowser.Controller.LiveTv/// <summary>/// Gets the registration information./// </summary>- /// <param name="channelId">The channel identifier.</param>- /// <param name="programId">The program identifier.</param>/// <param name="feature">The feature.</param>/// <returns>Task<MBRegistrationRecord>.</returns>- Task<MBRegistrationRecord> GetRegistrationInfo(string channelId, string programId, string feature);+ Task<MBRegistrationRecord> GetRegistrationInfo(string feature);/// <summary>/// Adds the channel information.diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csprojindex 5e74a39994..7cfd56c1ee 100644--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj@@ -199,7 +199,6 @@<Compile Include="Library\NameExtensions.cs" /><Compile Include="Library\PlaybackStopEventArgs.cs" /><Compile Include="Library\UserDataSaveEventArgs.cs" />- <Compile Include="LiveTv\IHasRegistrationInfo.cs" /><Compile Include="LiveTv\IListingsProvider.cs" /><Compile Include="LiveTv\ITunerHost.cs" /><Compile Include="LiveTv\RecordingGroup.cs" />diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.csindex 44a2ae9540..26bf3107d3 100644--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs@@ -217,7 +217,7 @@ namespace MediaBrowser.Model.ConfigurationMigrations = new string[] { };CodecsUsed = new string[] { };SqliteCacheSize = 0;- ImageExtractionTimeoutMs = 10000;+ ImageExtractionTimeoutMs = 14000;EnableLocalizedGuids = true;DisplaySpecialsWithinSeasons = true;diff --git a/MediaBrowser.Providers/Music/AudioMetadataService.cs b/MediaBrowser.Providers/Music/AudioMetadataService.csindex 5321281869..67ddd89812 100644--- a/MediaBrowser.Providers/Music/AudioMetadataService.cs+++ b/MediaBrowser.Providers/Music/AudioMetadataService.cs@@ -6,6 +6,7 @@ using MediaBrowser.Model.Entities;using MediaBrowser.Model.Logging;using MediaBrowser.Providers.Manager;using System.Collections.Generic;+using System.Linq;using CommonIO;namespace MediaBrowser.Providers.Music@@ -21,7 +22,7 @@ namespace MediaBrowser.Providers.Musicif (replaceData || targetItem.Artists.Count == 0){- targetItem.Artists = sourceItem.Artists;+ targetItem.Artists = sourceItem.Artists.ToList();}if (replaceData || string.IsNullOrEmpty(targetItem.Album))diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.csindex be68162caf..9284f4fc74 100644--- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs+++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs@@ -1168,6 +1168,26 @@ namespace MediaBrowser.Server.Implementations.Dto};}).ToList();++ // Include artists that are not in the database yet, e.g., just added via metadata editor+ var foundArtists = artistItems.Items.Select(i => i.Item1.Name).ToList();+ dto.ArtistItems.AddRange(hasArtist.Artists+ .Except(foundArtists, new DistinctNameComparer())+ .Select(i =>+ {+ var artist = _libraryManager.GetArtist(i);+ if (artist != null)+ {+ return new NameIdPair+ {+ Name = artist.Name,+ Id = artist.Id.ToString("N")+ };+ }++ return null;++ }).Where(i => i != null));}var hasAlbumArtist = item as IHasAlbumArtist;diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.csindex 649024d160..8f5b42df06 100644--- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs@@ -33,7 +33,7 @@ using Microsoft.Win32;namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV{- public class EmbyTV : ILiveTvService, ISupportsNewTimerIds, IHasRegistrationInfo, IDisposable+ public class EmbyTV : ILiveTvService, ISupportsNewTimerIds, IDisposable{private readonly IApplicationHost _appHpst;private readonly ILogger _logger;@@ -46,7 +46,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTVprivate readonly LiveTvManager _liveTvManager;private readonly IFileSystem _fileSystem;- private readonly ISecurityManager _security;private readonly ILibraryMonitor _libraryMonitor;private readonly ILibraryManager _libraryManager;@@ -62,7 +61,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTVprivate readonly ConcurrentDictionary<string, ActiveRecordingInfo> _activeRecordings =new ConcurrentDictionary<string, ActiveRecordingInfo>(StringComparer.OrdinalIgnoreCase);- public EmbyTV(IApplicationHost appHost, ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IServerConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem, ISecurityManager security, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IProviderManager providerManager, IFileOrganizationService organizationService, IMediaEncoder mediaEncoder, IPowerManagement powerManagement)+ public EmbyTV(IApplicationHost appHost, ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IServerConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IProviderManager providerManager, IFileOrganizationService organizationService, IMediaEncoder mediaEncoder, IPowerManagement powerManagement){Current = this;@@ -71,7 +70,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV_httpClient = httpClient;_config = config;_fileSystem = fileSystem;- _security = security;_libraryManager = libraryManager;_libraryMonitor = libraryMonitor;_providerManager = providerManager;@@ -1114,7 +1112,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTVif (config.EnableRecordingEncoding){- var regInfo = await _security.GetRegistrationStatus("embytvrecordingconversion").ConfigureAwait(false);+ var regInfo = await _liveTvManager.GetRegistrationInfo("embytvrecordingconversion").ConfigureAwait(false);if (regInfo.IsValid){@@ -1171,8 +1169,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTVprivate async Task UpdateTimersForSeriesTimer(List<ProgramInfo> epgData, SeriesTimerInfo seriesTimer, bool deleteInvalidTimers){var newTimers = GetTimersForSeries(seriesTimer, epgData, true).ToList();-- var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);++ var registration = await _liveTvManager.GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);if (registration.IsValid){@@ -1349,20 +1347,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV}}- public Task<MBRegistrationRecord> GetRegistrationInfo(string feature)- {- if (string.Equals(feature, "seriesrecordings", StringComparison.OrdinalIgnoreCase))- {- return _security.GetRegistrationStatus("embytvseriesrecordings");- }-- return Task.FromResult(new MBRegistrationRecord- {- IsValid = true,- IsRegistered = true- });- }-public List<VirtualFolderInfo> GetRecordingFolders(){var list = new List<VirtualFolderInfo>();diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex 3d9a0f80ed..72d1dc120b 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs@@ -31,6 +31,7 @@ using CommonIO;using IniParser;using IniParser.Model;using MediaBrowser.Common.Events;+using MediaBrowser.Common.Security;using MediaBrowser.Controller.Entities.Movies;using MediaBrowser.Controller.Entities.TV;using MediaBrowser.Model.Events;@@ -51,6 +52,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvprivate readonly ITaskManager _taskManager;private readonly IJsonSerializer _jsonSerializer;private readonly IProviderManager _providerManager;+ private readonly ISecurityManager _security;private readonly IDtoService _dtoService;private readonly ILocalizationManager _localization;@@ -73,7 +75,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvpublic event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCreated;public event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCreated;- public LiveTvManager(IApplicationHost appHost, IServerConfigurationManager config, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager, ILocalizationManager localization, IJsonSerializer jsonSerializer, IProviderManager providerManager, IFileSystem fileSystem)+ public LiveTvManager(IApplicationHost appHost, IServerConfigurationManager config, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager, ILocalizationManager localization, IJsonSerializer jsonSerializer, IProviderManager providerManager, IFileSystem fileSystem, ISecurityManager security){_config = config;_logger = logger;@@ -85,6 +87,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv_jsonSerializer = jsonSerializer;_providerManager = providerManager;_fileSystem = fileSystem;+ _security = security;_dtoService = dtoService;_userDataManager = userDataManager;@@ -2133,6 +2136,14 @@ namespace MediaBrowser.Server.Implementations.LiveTvpublic async Task CreateSeriesTimer(SeriesTimerInfoDto timer, CancellationToken cancellationToken){+ var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);++ if (!registration.IsValid)+ {+ _logger.Info("Creating series recordings requires an active Emby Premiere subscription.");+ return;+ }+var service = GetService(timer.ServiceName);var info = await _tvDtoService.GetSeriesTimerInfo(timer, true, this, cancellationToken).ConfigureAwait(false);@@ -2695,33 +2706,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv}}- public Task<MBRegistrationRecord> GetRegistrationInfo(string channelId, string programId, string feature)+ public Task<MBRegistrationRecord> GetRegistrationInfo(string feature){- ILiveTvService service;-- if (string.IsNullOrWhiteSpace(programId))+ if (string.Equals(feature, "seriesrecordings", StringComparison.OrdinalIgnoreCase)){- var channel = GetInternalChannel(channelId);- service = GetService(channel);+ feature = "embytvseriesrecordings";}- else- {- var program = GetInternalProgram(programId);- service = GetService(program);- }-- var hasRegistration = service as IHasRegistrationInfo;- if (hasRegistration != null)- {- return hasRegistration.GetRegistrationInfo(feature);- }-- return Task.FromResult(new MBRegistrationRecord- {- IsValid = true,- IsRegistered = true- });+ return _security.GetRegistrationStatus(feature);}public List<NameValuePair> GetSatIniMappings()diff --git a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mono/Native/BaseMonoApp.csindex 2185f48047..48f6a2a48b 100644--- a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs+++ b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs@@ -283,6 +283,11 @@ namespace MediaBrowser.Server.Mono.Native{}++ public bool PortsRequireAuthorization(string applicationPath)+ {+ return false;+ }}public class NullPowerManagement : IPowerManagementdiff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.csindex 86c5c06bc2..2417c5b11d 100644--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs@@ -520,7 +520,7 @@ namespace MediaBrowser.Server.Startup.CommonPlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("PlaylistManager"), UserManager, ProviderManager);RegisterSingleInstance<IPlaylistManager>(PlaylistManager);- LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, ProviderManager, FileSystemManager);+ LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, ProviderManager, FileSystemManager, SecurityManager);RegisterSingleInstance(LiveTvManager);UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager);@@ -773,7 +773,19 @@ namespace MediaBrowser.Server.Startup.Common/// </summary>protected override void FindParts(){- if (!ServerConfigurationManager.Configuration.IsPortAuthorized)+ var isAuthorized = ServerConfigurationManager.Configuration.IsPortAuthorized;+ if (isAuthorized)+ {+ try+ {+ isAuthorized = !NativeApp.PortsRequireAuthorization(ConfigurationManager.CommonApplicationPaths.ApplicationPath);+ }+ catch+ {++ }+ }+ if (!isAuthorized){RegisterServerWithAdministratorAccess();ServerConfigurationManager.Configuration.IsPortAuthorized = true;diff --git a/MediaBrowser.Server.Startup.Common/INativeApp.cs b/MediaBrowser.Server.Startup.Common/INativeApp.csindex d2e278a3bb..9297a6d372 100644--- a/MediaBrowser.Server.Startup.Common/INativeApp.cs+++ b/MediaBrowser.Server.Startup.Common/INativeApp.cs@@ -25,6 +25,8 @@ namespace MediaBrowser.Server.Startup.Common/// <param name="tempDirectory">The temporary directory.</param>void AuthorizeServer(int udpPort, int httpServerPort, int httpsServerPort, string applicationPath, string tempDirectory);+ bool PortsRequireAuthorization(string applicationPath);+/// <summary>/// Gets the environment./// </summary>diff --git a/MediaBrowser.ServerApplication/Native/RegisterServer.bat b/MediaBrowser.ServerApplication/Native/RegisterServer.batindex 27f863d581..85baa0d03a 100644--- a/MediaBrowser.ServerApplication/Native/RegisterServer.bat+++ b/MediaBrowser.ServerApplication/Native/RegisterServer.bat@@ -20,7 +20,9 @@ netsh advfirewall firewall add rule name="Port %3" dir=in action=allow protocol=if [%4]==[] GOTO DONE+netsh advfirewall firewall delete rule name="mediabrowser.serverapplication.exe"netsh advfirewall firewall delete rule name="Emby Server"+netsh advfirewall firewall add rule name="Emby Server" dir=in action=allow protocol=TCP program=%4 enable=yesnetsh advfirewall firewall add rule name="Emby Server" dir=in action=allow protocol=UDP program=%4 enable=yesdiff --git a/MediaBrowser.ServerApplication/Native/WindowsApp.cs b/MediaBrowser.ServerApplication/Native/WindowsApp.csindex 139471f11b..f7b19162d7 100644--- a/MediaBrowser.ServerApplication/Native/WindowsApp.cs+++ b/MediaBrowser.ServerApplication/Native/WindowsApp.cs@@ -208,5 +208,60 @@ namespace MediaBrowser.ServerApplication.Native{LoopUtil.Run(appName);}++ public bool PortsRequireAuthorization(string applicationPath)+ {+ var appNameSrch = Path.GetFileName(applicationPath);++ var startInfo = new ProcessStartInfo+ {+ FileName = "netsh",++ Arguments = "advfirewall firewall show rule \"" + appNameSrch + "\"",++ CreateNoWindow = true,+ UseShellExecute = false,+ WindowStyle = ProcessWindowStyle.Hidden,+ ErrorDialog = false,+ RedirectStandardOutput = true+ };++ using (var process = Process.Start(startInfo))+ {+ process.Start();++ try+ {+ var data = process.StandardOutput.ReadToEnd() ?? string.Empty;++ //_logger.Debug("Found windows firewall rule: " + data);+ if (data.IndexOf("Block", StringComparison.OrdinalIgnoreCase) != -1)+ {+ return true;+ }++ //var parts = data.Split('\n');++ //return parts.Length > 4;+ return false;+ }+ catch (Exception ex)+ {+ _logger.ErrorException("Error querying windows firewall", ex);++ // Hate having to do this+ try+ {+ process.Kill();+ }+ catch (Exception ex1)+ {+ _logger.ErrorException("Error killing process", ex1);+ }++ throw;+ }+ }+ }}}\ No newline at end of file