mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 19:37:55 +02:00
commit
9644064f12
4 changed files with 43 additions and 15 deletions
|
@ -8,6 +8,8 @@ using MediaBrowser.Model.Tasks;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using MediaBrowser.Controller.LiveTv;
|
||||||
|
using MediaBrowser.Model.LiveTv;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.EntryPoints
|
namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||||
{
|
{
|
||||||
|
@ -18,16 +20,18 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||||
private readonly ITaskManager _iTaskManager;
|
private readonly ITaskManager _iTaskManager;
|
||||||
private readonly ISessionManager _sessionManager;
|
private readonly ISessionManager _sessionManager;
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
|
private readonly ILiveTvManager _liveTvManager;
|
||||||
|
|
||||||
private Timer _timer;
|
private Timer _timer;
|
||||||
|
|
||||||
public AutomaticRestartEntryPoint(IServerApplicationHost appHost, ILogger logger, ITaskManager iTaskManager, ISessionManager sessionManager, IServerConfigurationManager config)
|
public AutomaticRestartEntryPoint(IServerApplicationHost appHost, ILogger logger, ITaskManager iTaskManager, ISessionManager sessionManager, IServerConfigurationManager config, ILiveTvManager liveTvManager)
|
||||||
{
|
{
|
||||||
_appHost = appHost;
|
_appHost = appHost;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_iTaskManager = iTaskManager;
|
_iTaskManager = iTaskManager;
|
||||||
_sessionManager = sessionManager;
|
_sessionManager = sessionManager;
|
||||||
_config = config;
|
_config = config;
|
||||||
|
_liveTvManager = liveTvManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
|
@ -44,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||||
|
|
||||||
if (_appHost.HasPendingRestart)
|
if (_appHost.HasPendingRestart)
|
||||||
{
|
{
|
||||||
_timer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5));
|
_timer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +76,22 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_liveTvManager.Services.Count == 1)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var timers = _liveTvManager.GetTimers(new TimerQuery(), CancellationToken.None).Result;
|
||||||
|
if (timers.Items.Any(i => i.Status == RecordingStatus.InProgress))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error getting timers", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
|
|
||||||
return !_sessionManager.Sessions.Any(i => (now - i.LastActivityDate).TotalMinutes < 30);
|
return !_sessionManager.Sessions.Any(i => (now - i.LastActivityDate).TotalMinutes < 30);
|
||||||
|
|
|
@ -145,7 +145,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
videoArgs = "-codec:v:0 copy";
|
videoArgs = "-codec:v:0 copy";
|
||||||
}
|
}
|
||||||
|
|
||||||
var commandLineArgs = "-fflags +genpts -async 1 -vsync -1 -i \"{0}\" -t {4} -sn {2} -map_metadata -1 -threads 0 {3} -y \"{1}\"";
|
var commandLineArgs = "-fflags +genpts -async 1 -vsync -1 -re -i \"{0}\" -t {4} -sn {2} -map_metadata -1 -threads 0 {3} -y \"{1}\"";
|
||||||
|
|
||||||
if (mediaSource.ReadAtNativeFramerate)
|
if (mediaSource.ReadAtNativeFramerate)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,10 +8,10 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Emby.XmlTv.Classes;
|
using Emby.XmlTv.Classes;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
||||||
{
|
{
|
||||||
|
@ -19,11 +19,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
||||||
{
|
{
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly IHttpClient _httpClient;
|
private readonly IHttpClient _httpClient;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public XmlTvListingsProvider(IServerConfigurationManager config, IHttpClient httpClient)
|
public XmlTvListingsProvider(IServerConfigurationManager config, IHttpClient httpClient, ILogger logger)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
|
@ -55,10 +57,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
||||||
return cacheFile;
|
return cacheFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.Info("Downloading xmltv listings from {0}", path);
|
||||||
|
|
||||||
var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions
|
var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions
|
||||||
{
|
{
|
||||||
CancellationToken = cancellationToken,
|
CancellationToken = cancellationToken,
|
||||||
Url = path
|
Url = path,
|
||||||
|
Progress = new Progress<Double>()
|
||||||
|
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
File.Copy(tempFile, cacheFile, true);
|
File.Copy(tempFile, cacheFile, true);
|
||||||
|
@ -100,10 +105,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task AddMetadata(ListingsProviderInfo info, List<ChannelInfo> channels, CancellationToken cancellationToken)
|
public async Task AddMetadata(ListingsProviderInfo info, List<ChannelInfo> channels, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// Add the channel image url
|
// Add the channel image url
|
||||||
var reader = new XmlTvReader(info.Path, GetLanguage(), null);
|
var path = await GetXml(info.Path, cancellationToken).ConfigureAwait(false);
|
||||||
|
var reader = new XmlTvReader(path, GetLanguage(), null);
|
||||||
var results = reader.GetChannels().ToList();
|
var results = reader.GetChannels().ToList();
|
||||||
|
|
||||||
if (channels != null)
|
if (channels != null)
|
||||||
|
@ -119,8 +125,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.FromResult(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings)
|
public Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings)
|
||||||
|
@ -134,20 +138,22 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<List<NameIdPair>> GetLineups(ListingsProviderInfo info, string country, string location)
|
public async Task<List<NameIdPair>> GetLineups(ListingsProviderInfo info, string country, string location)
|
||||||
{
|
{
|
||||||
// In theory this should never be called because there is always only one lineup
|
// In theory this should never be called because there is always only one lineup
|
||||||
var reader = new XmlTvReader(info.Path, GetLanguage(), null);
|
var path = await GetXml(info.Path, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
var reader = new XmlTvReader(path, GetLanguage(), null);
|
||||||
var results = reader.GetChannels();
|
var results = reader.GetChannels();
|
||||||
|
|
||||||
// Should this method be async?
|
// Should this method be async?
|
||||||
return Task.FromResult(results.Select(c => new NameIdPair() { Id = c.Id, Name = c.DisplayName }).ToList());
|
return results.Select(c => new NameIdPair() { Id = c.Id, Name = c.DisplayName }).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<ChannelInfo>> GetChannels(ListingsProviderInfo info, CancellationToken cancellationToken)
|
public async Task<List<ChannelInfo>> GetChannels(ListingsProviderInfo info, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// In theory this should never be called because there is always only one lineup
|
// In theory this should never be called because there is always only one lineup
|
||||||
var reader = new XmlTvReader(info.Path, GetLanguage(), null);
|
var path = await GetXml(info.Path, cancellationToken).ConfigureAwait(false);
|
||||||
|
var reader = new XmlTvReader(path, GetLanguage(), null);
|
||||||
var results = reader.GetChannels();
|
var results = reader.GetChannels();
|
||||||
|
|
||||||
// Should this method be async?
|
// Should this method be async?
|
||||||
|
|
|
@ -33,7 +33,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
SyncMode = SynchronizationModes.Normal,
|
SyncMode = SynchronizationModes.Normal,
|
||||||
DataSource = dbPath,
|
DataSource = dbPath,
|
||||||
JournalMode = SQLiteJournalModeEnum.Wal,
|
JournalMode = SQLiteJournalModeEnum.Wal,
|
||||||
Pooling = enablePooling,
|
|
||||||
|
// This is causing crashing under linux
|
||||||
|
Pooling = Environment.OSVersion.Platform == PlatformID.Win32NT,
|
||||||
ReadOnly = isReadOnly
|
ReadOnly = isReadOnly
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue