Merge pull request #2143 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-09-06 02:51:56 -04:00 committed by GitHub
commit 65c52fc32a
15 changed files with 133 additions and 77 deletions

View File

@ -538,12 +538,6 @@ namespace MediaBrowser.Api.LiveTv
[Authenticated] [Authenticated]
public class GetLiveTvRegistrationInfo : IReturn<MBRegistrationRecord> 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")] [ApiMember(Name = "Feature", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string Feature { get; set; } public string Feature { get; set; }
} }
@ -595,7 +589,7 @@ namespace MediaBrowser.Api.LiveTv
public async Task<object> Get(GetLiveTvRegistrationInfo request) public 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); return ToOptimizedResult(result);
} }

View File

@ -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) public int Compare(string x, string y)
{ {
@ -63,7 +63,7 @@ namespace MediaBrowser.Controller.Library
return 0; return 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) public bool Equals(string x, string y)

View File

@ -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&lt;MBRegistrationRecord&gt;.</returns>
Task<MBRegistrationRecord> GetRegistrationInfo(string feature);
}
}

View File

@ -364,11 +364,9 @@ namespace MediaBrowser.Controller.LiveTv
/// <summary> /// <summary>
/// Gets the registration information. /// Gets the registration information.
/// </summary> /// </summary>
/// <param name="channelId">The channel identifier.</param>
/// <param name="programId">The program identifier.</param>
/// <param name="feature">The feature.</param> /// <param name="feature">The feature.</param>
/// <returns>Task&lt;MBRegistrationRecord&gt;.</returns> /// <returns>Task&lt;MBRegistrationRecord&gt;.</returns>
Task<MBRegistrationRecord> GetRegistrationInfo(string channelId, string programId, string feature); Task<MBRegistrationRecord> GetRegistrationInfo(string feature);
/// <summary> /// <summary>
/// Adds the channel information. /// Adds the channel information.

View File

@ -199,7 +199,6 @@
<Compile Include="Library\NameExtensions.cs" /> <Compile Include="Library\NameExtensions.cs" />
<Compile Include="Library\PlaybackStopEventArgs.cs" /> <Compile Include="Library\PlaybackStopEventArgs.cs" />
<Compile Include="Library\UserDataSaveEventArgs.cs" /> <Compile Include="Library\UserDataSaveEventArgs.cs" />
<Compile Include="LiveTv\IHasRegistrationInfo.cs" />
<Compile Include="LiveTv\IListingsProvider.cs" /> <Compile Include="LiveTv\IListingsProvider.cs" />
<Compile Include="LiveTv\ITunerHost.cs" /> <Compile Include="LiveTv\ITunerHost.cs" />
<Compile Include="LiveTv\RecordingGroup.cs" /> <Compile Include="LiveTv\RecordingGroup.cs" />

View File

@ -217,7 +217,7 @@ namespace MediaBrowser.Model.Configuration
Migrations = new string[] { }; Migrations = new string[] { };
CodecsUsed = new string[] { }; CodecsUsed = new string[] { };
SqliteCacheSize = 0; SqliteCacheSize = 0;
ImageExtractionTimeoutMs = 10000; ImageExtractionTimeoutMs = 14000;
EnableLocalizedGuids = true; EnableLocalizedGuids = true;
DisplaySpecialsWithinSeasons = true; DisplaySpecialsWithinSeasons = true;

View File

@ -6,6 +6,7 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Providers.Manager; using MediaBrowser.Providers.Manager;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using CommonIO; using CommonIO;
namespace MediaBrowser.Providers.Music namespace MediaBrowser.Providers.Music
@ -21,7 +22,7 @@ namespace MediaBrowser.Providers.Music
if (replaceData || targetItem.Artists.Count == 0) if (replaceData || targetItem.Artists.Count == 0)
{ {
targetItem.Artists = sourceItem.Artists; targetItem.Artists = sourceItem.Artists.ToList();
} }
if (replaceData || string.IsNullOrEmpty(targetItem.Album)) if (replaceData || string.IsNullOrEmpty(targetItem.Album))

View File

@ -1168,6 +1168,26 @@ namespace MediaBrowser.Server.Implementations.Dto
}; };
}) })
.ToList(); .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; var hasAlbumArtist = item as IHasAlbumArtist;

View File

@ -33,7 +33,7 @@ using Microsoft.Win32;
namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV 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 IApplicationHost _appHpst;
private readonly ILogger _logger; private readonly ILogger _logger;
@ -46,7 +46,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
private readonly LiveTvManager _liveTvManager; private readonly LiveTvManager _liveTvManager;
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
private readonly ISecurityManager _security;
private readonly ILibraryMonitor _libraryMonitor; private readonly ILibraryMonitor _libraryMonitor;
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
@ -62,7 +61,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
private readonly ConcurrentDictionary<string, ActiveRecordingInfo> _activeRecordings = private readonly ConcurrentDictionary<string, ActiveRecordingInfo> _activeRecordings =
new ConcurrentDictionary<string, ActiveRecordingInfo>(StringComparer.OrdinalIgnoreCase); 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; Current = this;
@ -71,7 +70,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
_httpClient = httpClient; _httpClient = httpClient;
_config = config; _config = config;
_fileSystem = fileSystem; _fileSystem = fileSystem;
_security = security;
_libraryManager = libraryManager; _libraryManager = libraryManager;
_libraryMonitor = libraryMonitor; _libraryMonitor = libraryMonitor;
_providerManager = providerManager; _providerManager = providerManager;
@ -1114,7 +1112,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
if (config.EnableRecordingEncoding) if (config.EnableRecordingEncoding)
{ {
var regInfo = await _security.GetRegistrationStatus("embytvrecordingconversion").ConfigureAwait(false); var regInfo = await _liveTvManager.GetRegistrationInfo("embytvrecordingconversion").ConfigureAwait(false);
if (regInfo.IsValid) if (regInfo.IsValid)
{ {
@ -1171,8 +1169,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
private async Task UpdateTimersForSeriesTimer(List<ProgramInfo> epgData, SeriesTimerInfo seriesTimer, bool deleteInvalidTimers) private async Task UpdateTimersForSeriesTimer(List<ProgramInfo> epgData, SeriesTimerInfo seriesTimer, bool deleteInvalidTimers)
{ {
var newTimers = GetTimersForSeries(seriesTimer, epgData, true).ToList(); 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) 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() public List<VirtualFolderInfo> GetRecordingFolders()
{ {
var list = new List<VirtualFolderInfo>(); var list = new List<VirtualFolderInfo>();

View File

@ -31,6 +31,7 @@ using CommonIO;
using IniParser; using IniParser;
using IniParser.Model; using IniParser.Model;
using MediaBrowser.Common.Events; using MediaBrowser.Common.Events;
using MediaBrowser.Common.Security;
using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Events; using MediaBrowser.Model.Events;
@ -51,6 +52,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
private readonly ITaskManager _taskManager; private readonly ITaskManager _taskManager;
private readonly IJsonSerializer _jsonSerializer; private readonly IJsonSerializer _jsonSerializer;
private readonly IProviderManager _providerManager; private readonly IProviderManager _providerManager;
private readonly ISecurityManager _security;
private readonly IDtoService _dtoService; private readonly IDtoService _dtoService;
private readonly ILocalizationManager _localization; private readonly ILocalizationManager _localization;
@ -73,7 +75,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
public event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCreated; public event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCreated;
public event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCreated; 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; _config = config;
_logger = logger; _logger = logger;
@ -85,6 +87,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
_jsonSerializer = jsonSerializer; _jsonSerializer = jsonSerializer;
_providerManager = providerManager; _providerManager = providerManager;
_fileSystem = fileSystem; _fileSystem = fileSystem;
_security = security;
_dtoService = dtoService; _dtoService = dtoService;
_userDataManager = userDataManager; _userDataManager = userDataManager;
@ -2133,6 +2136,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv
public async Task CreateSeriesTimer(SeriesTimerInfoDto timer, CancellationToken cancellationToken) public 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 service = GetService(timer.ServiceName);
var info = await _tvDtoService.GetSeriesTimerInfo(timer, true, this, cancellationToken).ConfigureAwait(false); 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.Equals(feature, "seriesrecordings", StringComparison.OrdinalIgnoreCase))
if (string.IsNullOrWhiteSpace(programId))
{ {
var channel = GetInternalChannel(channelId); feature = "embytvseriesrecordings";
service = GetService(channel);
}
else
{
var program = GetInternalProgram(programId);
service = GetService(program);
} }
var hasRegistration = service as IHasRegistrationInfo; return _security.GetRegistrationStatus(feature);
if (hasRegistration != null)
{
return hasRegistration.GetRegistrationInfo(feature);
}
return Task.FromResult(new MBRegistrationRecord
{
IsValid = true,
IsRegistered = true
});
} }
public List<NameValuePair> GetSatIniMappings() public List<NameValuePair> GetSatIniMappings()

View File

@ -283,6 +283,11 @@ namespace MediaBrowser.Server.Mono.Native
{ {
} }
public bool PortsRequireAuthorization(string applicationPath)
{
return false;
}
} }
public class NullPowerManagement : IPowerManagement public class NullPowerManagement : IPowerManagement

View File

@ -520,7 +520,7 @@ namespace MediaBrowser.Server.Startup.Common
PlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("PlaylistManager"), UserManager, ProviderManager); PlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("PlaylistManager"), UserManager, ProviderManager);
RegisterSingleInstance<IPlaylistManager>(PlaylistManager); 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); RegisterSingleInstance(LiveTvManager);
UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager); UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager);
@ -773,7 +773,19 @@ namespace MediaBrowser.Server.Startup.Common
/// </summary> /// </summary>
protected override void FindParts() 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(); RegisterServerWithAdministratorAccess();
ServerConfigurationManager.Configuration.IsPortAuthorized = true; ServerConfigurationManager.Configuration.IsPortAuthorized = true;

View File

@ -25,6 +25,8 @@ namespace MediaBrowser.Server.Startup.Common
/// <param name="tempDirectory">The temporary directory.</param> /// <param name="tempDirectory">The temporary directory.</param>
void AuthorizeServer(int udpPort, int httpServerPort, int httpsServerPort, string applicationPath, string tempDirectory); void AuthorizeServer(int udpPort, int httpServerPort, int httpsServerPort, string applicationPath, string tempDirectory);
bool PortsRequireAuthorization(string applicationPath);
/// <summary> /// <summary>
/// Gets the environment. /// Gets the environment.
/// </summary> /// </summary>

View File

@ -20,7 +20,9 @@ netsh advfirewall firewall add rule name="Port %3" dir=in action=allow protocol=
if [%4]==[] GOTO DONE if [%4]==[] GOTO DONE
netsh advfirewall firewall delete rule name="mediabrowser.serverapplication.exe"
netsh advfirewall firewall delete rule name="Emby Server" 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=yes netsh advfirewall firewall add rule name="Emby Server" dir=in action=allow protocol=TCP program=%4 enable=yes
netsh advfirewall firewall add rule name="Emby Server" dir=in action=allow protocol=UDP program=%4 enable=yes netsh advfirewall firewall add rule name="Emby Server" dir=in action=allow protocol=UDP program=%4 enable=yes

View File

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Windows.Forms;
using CommonIO; using CommonIO;
using MediaBrowser.Controller.Power; using MediaBrowser.Controller.Power;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
@ -208,5 +209,66 @@ namespace MediaBrowser.ServerApplication.Native
{ {
LoopUtil.Run(appName); LoopUtil.Run(appName);
} }
private bool Confirm()
{
return MessageBox.Show("Emby has detected that Windows Firewall has been configured in a way that may prevent your other devices from accessing Emby Server. Click OK to remove this rule, or cancel to proceed anyway.", "Windows Firewall", MessageBoxButtons.OKCancel) == DialogResult.OK;
}
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 Confirm();
}
//var parts = data.Split('\n');
//return parts.Length > 4;
//return Confirm();
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;
}
}
}
} }
} }