aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs2
-rw-r--r--MediaBrowser.Controller/LiveTv/ILiveTvManager.cs7
-rw-r--r--src/Jellyfin.LiveTv/EmbyTV/EmbyTV.cs29
-rw-r--r--src/Jellyfin.LiveTv/Extensions/LiveTvServiceCollectionExtensions.cs4
-rw-r--r--src/Jellyfin.LiveTv/LiveTvManager.cs48
5 files changed, 34 insertions, 56 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 5870fed76..d268a6ba8 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -695,8 +695,6 @@ namespace Emby.Server.Implementations
GetExports<IMetadataSaver>(),
GetExports<IExternalId>());
- Resolve<ILiveTvManager>().AddParts(GetExports<ILiveTvService>(), GetExports<IListingsProvider>());
-
Resolve<IMediaSourceManager>().AddParts(GetExports<IMediaSourceProvider>());
}
diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
index 2dbc2cf82..7da455b8d 100644
--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
@@ -68,13 +68,6 @@ namespace MediaBrowser.Controller.LiveTv
Task CancelSeriesTimer(string id);
/// <summary>
- /// Adds the parts.
- /// </summary>
- /// <param name="services">The services.</param>
- /// <param name="listingProviders">The listing providers.</param>
- void AddParts(IEnumerable<ILiveTvService> services, IEnumerable<IListingsProvider> listingProviders);
-
- /// <summary>
/// Gets the timer.
/// </summary>
/// <param name="id">The identifier.</param>
diff --git a/src/Jellyfin.LiveTv/EmbyTV/EmbyTV.cs b/src/Jellyfin.LiveTv/EmbyTV/EmbyTV.cs
index a9a0db057..a9642bb60 100644
--- a/src/Jellyfin.LiveTv/EmbyTV/EmbyTV.cs
+++ b/src/Jellyfin.LiveTv/EmbyTV/EmbyTV.cs
@@ -52,7 +52,6 @@ namespace Jellyfin.LiveTv.EmbyTV
private readonly ItemDataProvider<SeriesTimerInfo> _seriesTimerProvider;
private readonly TimerManager _timerProvider;
- private readonly LiveTvManager _liveTvManager;
private readonly ITunerHostManager _tunerHostManager;
private readonly IFileSystem _fileSystem;
@@ -62,6 +61,8 @@ namespace Jellyfin.LiveTv.EmbyTV
private readonly IMediaEncoder _mediaEncoder;
private readonly IMediaSourceManager _mediaSourceManager;
private readonly IStreamHelper _streamHelper;
+ private readonly LiveTvDtoService _tvDtoService;
+ private readonly IListingsProvider[] _listingsProviders;
private readonly ConcurrentDictionary<string, ActiveRecordingInfo> _activeRecordings =
new ConcurrentDictionary<string, ActiveRecordingInfo>(StringComparer.OrdinalIgnoreCase);
@@ -79,13 +80,14 @@ namespace Jellyfin.LiveTv.EmbyTV
ILogger<EmbyTV> logger,
IHttpClientFactory httpClientFactory,
IServerConfigurationManager config,
- ILiveTvManager liveTvManager,
ITunerHostManager tunerHostManager,
IFileSystem fileSystem,
ILibraryManager libraryManager,
ILibraryMonitor libraryMonitor,
IProviderManager providerManager,
- IMediaEncoder mediaEncoder)
+ IMediaEncoder mediaEncoder,
+ LiveTvDtoService tvDtoService,
+ IEnumerable<IListingsProvider> listingsProviders)
{
Current = this;
@@ -97,10 +99,11 @@ namespace Jellyfin.LiveTv.EmbyTV
_libraryMonitor = libraryMonitor;
_providerManager = providerManager;
_mediaEncoder = mediaEncoder;
- _liveTvManager = (LiveTvManager)liveTvManager;
+ _tvDtoService = tvDtoService;
_tunerHostManager = tunerHostManager;
_mediaSourceManager = mediaSourceManager;
_streamHelper = streamHelper;
+ _listingsProviders = listingsProviders.ToArray();
_seriesTimerProvider = new SeriesTimerManager(_logger, Path.Combine(DataPath, "seriestimers.json"));
_timerProvider = new TimerManager(_logger, Path.Combine(DataPath, "timers.json"));
@@ -938,7 +941,7 @@ namespace Jellyfin.LiveTv.EmbyTV
return _config.GetLiveTvConfiguration().ListingProviders
.Select(i =>
{
- var provider = _liveTvManager.ListingProviders.FirstOrDefault(l => string.Equals(l.Type, i.Type, StringComparison.OrdinalIgnoreCase));
+ var provider = _listingsProviders.FirstOrDefault(l => string.Equals(l.Type, i.Type, StringComparison.OrdinalIgnoreCase));
return provider is null ? null : new Tuple<IListingsProvider, ListingsProviderInfo>(provider, i);
})
@@ -1182,6 +1185,12 @@ namespace Jellyfin.LiveTv.EmbyTV
return Path.Combine(recordPath, recordingFileName);
}
+ private BaseItem GetLiveTvChannel(TimerInfo timer)
+ {
+ var internalChannelId = _tvDtoService.GetInternalChannelId(Name, timer.ChannelId);
+ return _libraryManager.GetItemById(internalChannelId);
+ }
+
private async Task RecordStream(TimerInfo timer, DateTime recordingEndDate, ActiveRecordingInfo activeRecordingInfo)
{
ArgumentNullException.ThrowIfNull(timer);
@@ -1207,7 +1216,7 @@ namespace Jellyfin.LiveTv.EmbyTV
var remoteMetadata = await FetchInternetMetadata(timer, CancellationToken.None).ConfigureAwait(false);
var recordPath = GetRecordingPath(timer, remoteMetadata, out string seriesPath);
- var channelItem = _liveTvManager.GetLiveTvChannel(timer, this);
+ var channelItem = GetLiveTvChannel(timer);
string liveStreamId = null;
RecordingStatus recordingStatus;
@@ -2084,7 +2093,7 @@ namespace Jellyfin.LiveTv.EmbyTV
{
var query = new InternalItemsQuery
{
- ItemIds = new[] { _liveTvManager.GetInternalProgramId(programId) },
+ ItemIds = [_tvDtoService.GetInternalProgramId(programId)],
Limit = 1,
DtoOptions = new DtoOptions()
};
@@ -2114,7 +2123,7 @@ namespace Jellyfin.LiveTv.EmbyTV
if (!string.IsNullOrWhiteSpace(channelId))
{
- query.ChannelIds = new[] { _liveTvManager.GetInternalChannelId(Name, channelId) };
+ query.ChannelIds = [_tvDtoService.GetInternalChannelId(Name, channelId)];
}
return _libraryManager.GetItemList(query).Cast<LiveTvProgram>().FirstOrDefault();
@@ -2150,7 +2159,7 @@ namespace Jellyfin.LiveTv.EmbyTV
private void HandleDuplicateShowIds(List<TimerInfo> timers)
{
// sort showings by HD channels first, then by startDate, record earliest showing possible
- foreach (var timer in timers.OrderByDescending(t => _liveTvManager.GetLiveTvChannel(t, this).IsHD).ThenBy(t => t.StartDate).Skip(1))
+ foreach (var timer in timers.OrderByDescending(t => GetLiveTvChannel(t).IsHD).ThenBy(t => t.StartDate).Skip(1))
{
timer.Status = RecordingStatus.Cancelled;
_timerProvider.Update(timer);
@@ -2300,7 +2309,7 @@ namespace Jellyfin.LiveTv.EmbyTV
if (!seriesTimer.RecordAnyChannel)
{
- query.ChannelIds = new[] { _liveTvManager.GetInternalChannelId(Name, seriesTimer.ChannelId) };
+ query.ChannelIds = [_tvDtoService.GetInternalChannelId(Name, seriesTimer.ChannelId)];
}
var tempChannelCache = new Dictionary<Guid, LiveTvChannel>();
diff --git a/src/Jellyfin.LiveTv/Extensions/LiveTvServiceCollectionExtensions.cs b/src/Jellyfin.LiveTv/Extensions/LiveTvServiceCollectionExtensions.cs
index 21dab69e0..a07325ad1 100644
--- a/src/Jellyfin.LiveTv/Extensions/LiveTvServiceCollectionExtensions.cs
+++ b/src/Jellyfin.LiveTv/Extensions/LiveTvServiceCollectionExtensions.cs
@@ -1,5 +1,6 @@
using Jellyfin.LiveTv.Channels;
using Jellyfin.LiveTv.Guide;
+using Jellyfin.LiveTv.Listings;
using Jellyfin.LiveTv.TunerHosts;
using Jellyfin.LiveTv.TunerHosts.HdHomerun;
using MediaBrowser.Controller.Channels;
@@ -27,7 +28,10 @@ public static class LiveTvServiceCollectionExtensions
services.AddSingleton<ITunerHostManager, TunerHostManager>();
services.AddSingleton<IGuideManager, GuideManager>();
+ services.AddSingleton<ILiveTvService, EmbyTV.EmbyTV>();
services.AddSingleton<ITunerHost, HdHomerunHost>();
services.AddSingleton<ITunerHost, M3UTunerHost>();
+ services.AddSingleton<IListingsProvider, SchedulesDirect>();
+ services.AddSingleton<IListingsProvider, XmlTvListingsProvider>();
}
}
diff --git a/src/Jellyfin.LiveTv/LiveTvManager.cs b/src/Jellyfin.LiveTv/LiveTvManager.cs
index aa3be2048..ef5283b98 100644
--- a/src/Jellyfin.LiveTv/LiveTvManager.cs
+++ b/src/Jellyfin.LiveTv/LiveTvManager.cs
@@ -47,9 +47,8 @@ namespace Jellyfin.LiveTv
private readonly ILocalizationManager _localization;
private readonly IChannelManager _channelManager;
private readonly LiveTvDtoService _tvDtoService;
-
- private ILiveTvService[] _services = Array.Empty<ILiveTvService>();
- private IListingsProvider[] _listingProviders = Array.Empty<IListingsProvider>();
+ private readonly ILiveTvService[] _services;
+ private readonly IListingsProvider[] _listingProviders;
public LiveTvManager(
IServerConfigurationManager config,
@@ -61,7 +60,9 @@ namespace Jellyfin.LiveTv
ITaskManager taskManager,
ILocalizationManager localization,
IChannelManager channelManager,
- LiveTvDtoService liveTvDtoService)
+ LiveTvDtoService liveTvDtoService,
+ IEnumerable<ILiveTvService> services,
+ IEnumerable<IListingsProvider> listingProviders)
{
_config = config;
_logger = logger;
@@ -73,6 +74,12 @@ namespace Jellyfin.LiveTv
_userDataManager = userDataManager;
_channelManager = channelManager;
_tvDtoService = liveTvDtoService;
+ _services = services.ToArray();
+ _listingProviders = listingProviders.ToArray();
+
+ var defaultService = _services.OfType<EmbyTV.EmbyTV>().First();
+ defaultService.TimerCreated += OnEmbyTvTimerCreated;
+ defaultService.TimerCancelled += OnEmbyTvTimerCancelled;
}
public event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCancelled;
@@ -96,23 +103,6 @@ namespace Jellyfin.LiveTv
return EmbyTV.EmbyTV.Current.GetActiveRecordingPath(id);
}
- /// <inheritdoc />
- public void AddParts(IEnumerable<ILiveTvService> services, IEnumerable<IListingsProvider> listingProviders)
- {
- _services = services.ToArray();
-
- _listingProviders = listingProviders.ToArray();
-
- foreach (var service in _services)
- {
- if (service is EmbyTV.EmbyTV embyTv)
- {
- embyTv.TimerCreated += OnEmbyTvTimerCreated;
- embyTv.TimerCancelled += OnEmbyTvTimerCancelled;
- }
- }
- }
-
private void OnEmbyTvTimerCancelled(object sender, GenericEventArgs<string> e)
{
var timerId = e.Argument;
@@ -1165,12 +1155,6 @@ namespace Jellyfin.LiveTv
return new QueryResult<SeriesTimerInfoDto>(returnArray);
}
- public BaseItem GetLiveTvChannel(TimerInfo timer, ILiveTvService service)
- {
- var internalChannelId = _tvDtoService.GetInternalChannelId(service.Name, timer.ChannelId);
- return _libraryManager.GetItemById(internalChannelId);
- }
-
public void AddChannelInfo(IReadOnlyCollection<(BaseItemDto ItemDto, LiveTvChannel Channel)> items, DtoOptions options, User user)
{
var now = DateTime.UtcNow;
@@ -1636,16 +1620,6 @@ namespace Jellyfin.LiveTv
return provider.GetChannels(info, cancellationToken);
}
- public Guid GetInternalChannelId(string serviceName, string externalId)
- {
- return _tvDtoService.GetInternalChannelId(serviceName, externalId);
- }
-
- public Guid GetInternalProgramId(string externalId)
- {
- return _tvDtoService.GetInternalProgramId(externalId);
- }
-
/// <inheritdoc />
public Task<BaseItem[]> GetRecordingFoldersAsync(User user)
=> GetRecordingFoldersAsync(user, false);