aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/LiveTv
diff options
context:
space:
mode:
authorLogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com>2019-01-23 00:31:35 -0800
committerGitHub <noreply@github.com>2019-01-23 00:31:35 -0800
commit404bd04cbc17dc8c8bf4a5c9aa3ca9c5cd85aa68 (patch)
tree3d267c6ceef9439a034c113095e10e4d619e7c70 /Emby.Server.Implementations/LiveTv
parent8ff89fdc0c30f595a171ffc550f907ef22b6212a (diff)
parente05e002b8bb4d13eb2b80b56a0aad8903ddb701e (diff)
Merge pull request #8 from jellyfin/master
rebase to latest master
Diffstat (limited to 'Emby.Server.Implementations/LiveTv')
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs7
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs221
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs42
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs1
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs12
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs6
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs41
-rw-r--r--Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs67
-rw-r--r--Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs28
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvConfigurationFactory.cs4
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs34
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvManager.cs158
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs19
-rw-r--r--Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs46
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs37
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs58
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs44
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs73
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs19
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs33
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs48
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs16
24 files changed, 403 insertions, 615 deletions
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
index 327b0181a..7d7ef21e3 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
@@ -1,13 +1,10 @@
-using System;
-using System.IO;
+using System;
using System.Threading;
using System.Threading.Tasks;
-using MediaBrowser.Model.IO;
-
using MediaBrowser.Common.Net;
-using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
+using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.EmbyTV
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index 59f9fe86f..64e5affd7 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
@@ -8,36 +8,36 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
+using Emby.Server.Implementations.Library;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
+using MediaBrowser.Common.Progress;
+using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Dto;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Providers;
+using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.Diagnostics;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Events;
+using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.IO;
using MediaBrowser.Model.LiveTv;
-using Microsoft.Extensions.Logging;
+using MediaBrowser.Model.MediaInfo;
+using MediaBrowser.Model.Providers;
+using MediaBrowser.Model.Querying;
+using MediaBrowser.Model.Reflection;
using MediaBrowser.Model.Serialization;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Common.Progress;
-using MediaBrowser.Controller;
-using MediaBrowser.Controller.Dto;
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Entities.TV;
-using MediaBrowser.Model.Configuration;
-using MediaBrowser.Model.Diagnostics;
using MediaBrowser.Model.System;
using MediaBrowser.Model.Threading;
-using MediaBrowser.Model.Extensions;
-using MediaBrowser.Model.Querying;
-using MediaBrowser.Model.Reflection;
-using MediaBrowser.Model.Providers;
-using MediaBrowser.Model.MediaInfo;
-using Emby.Server.Implementations.Library;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
@@ -75,7 +75,23 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private readonly IStreamHelper _streamHelper;
- public EmbyTV(IServerApplicationHost appHost, IStreamHelper streamHelper, IMediaSourceManager mediaSourceManager, IAssemblyInfo assemblyInfo, ILogger logger, IJsonSerializer jsonSerializer, IPowerManagement powerManagement, IHttpClient httpClient, IServerConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IProviderManager providerManager, IMediaEncoder mediaEncoder, ITimerFactory timerFactory, IProcessFactory processFactory, ISystemEvents systemEvents)
+ public EmbyTV(IServerApplicationHost appHost,
+ IStreamHelper streamHelper,
+ IMediaSourceManager mediaSourceManager,
+ IAssemblyInfo assemblyInfo,
+ ILogger logger,
+ IJsonSerializer jsonSerializer,
+ IHttpClient httpClient,
+ IServerConfigurationManager config,
+ ILiveTvManager liveTvManager,
+ IFileSystem fileSystem,
+ ILibraryManager libraryManager,
+ ILibraryMonitor libraryMonitor,
+ IProviderManager providerManager,
+ IMediaEncoder mediaEncoder,
+ ITimerFactory timerFactory,
+ IProcessFactory processFactory,
+ ISystemEvents systemEvents)
{
Current = this;
@@ -97,7 +113,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_streamHelper = streamHelper;
_seriesTimerProvider = new SeriesTimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "seriestimers"));
- _timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger, timerFactory, powerManagement);
+ _timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger, timerFactory);
_timerProvider.TimerFired += _timerProvider_TimerFired;
_config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;
@@ -238,27 +254,15 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (requiresRefresh)
{
- await _libraryManager.ValidateMediaLibrary(new SimpleProgress<Double>(), CancellationToken.None);
+ await _libraryManager.ValidateMediaLibrary(new SimpleProgress<double>(), CancellationToken.None);
}
}
- public string Name
- {
- get { return "Emby"; }
- }
+ public string Name => "Emby";
- public string DataPath
- {
- get { return Path.Combine(_config.CommonApplicationPaths.DataPath, "livetv"); }
- }
+ public string DataPath => Path.Combine(_config.CommonApplicationPaths.DataPath, "livetv");
- private string DefaultRecordingPath
- {
- get
- {
- return Path.Combine(DataPath, "recordings");
- }
- }
+ private string DefaultRecordingPath => Path.Combine(DataPath, "recordings");
private string RecordingPath
{
@@ -272,10 +276,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
}
- public string HomePageUrl
- {
- get { return "https://github.com/jellyfin/jellyfin"; }
- }
+ public string HomePageUrl => "https://github.com/jellyfin/jellyfin";
public async Task RefreshSeriesTimers(CancellationToken cancellationToken, IProgress<double> progress)
{
@@ -394,8 +395,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private async Task<EpgChannelData> GetEpgChannels(IListingsProvider provider, ListingsProviderInfo info, bool enableCache, CancellationToken cancellationToken)
{
- EpgChannelData result;
- if (!enableCache || !_epgChannels.TryGetValue(info.Id, out result))
+ if (!enableCache || !_epgChannels.TryGetValue(info.Id, out var result))
{
var channels = await provider.GetChannels(info, cancellationToken).ConfigureAwait(false);
@@ -451,18 +451,14 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public ChannelInfo GetChannelByNumber(string number)
{
- ChannelInfo result = null;
-
- ChannelsByNumber.TryGetValue(number, out result);
+ ChannelsByNumber.TryGetValue(number, out var result);
return result;
}
public ChannelInfo GetChannelByName(string name)
{
- ChannelInfo result = null;
-
- ChannelsByName.TryGetValue(name, out result);
+ ChannelsByName.TryGetValue(name, out var result);
return result;
}
@@ -475,7 +471,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
return GetEpgChannelFromTunerChannel(info, tunerChannel, epgChannels);
}
- private string GetMappedChannel(string channelId, NameValuePair[] mappings)
+ private static string GetMappedChannel(string channelId, NameValuePair[] mappings)
{
foreach (NameValuePair mapping in mappings)
{
@@ -651,9 +647,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
TimerCancelled(this, new GenericEventArgs<string>(timerId));
}
}
- ActiveRecordingInfo activeRecordingInfo;
- if (_activeRecordings.TryGetValue(timerId, out activeRecordingInfo))
+ if (_activeRecordings.TryGetValue(timerId, out var activeRecordingInfo))
{
activeRecordingInfo.Timer = timer;
activeRecordingInfo.CancellationTokenSource.Cancel();
@@ -820,8 +815,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
// Only update if not currently active
- ActiveRecordingInfo activeRecordingInfo;
- if (!_activeRecordings.TryGetValue(updatedTimer.Id, out activeRecordingInfo))
+ if (!_activeRecordings.TryGetValue(updatedTimer.Id, out var activeRecordingInfo))
{
existingTimer.PrePaddingSeconds = updatedTimer.PrePaddingSeconds;
existingTimer.PostPaddingSeconds = updatedTimer.PostPaddingSeconds;
@@ -834,7 +828,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
return Task.CompletedTask;
}
- private void UpdateExistingTimerWithNewMetadata(TimerInfo existingTimer, TimerInfo updatedTimer)
+ private static void UpdateExistingTimerWithNewMetadata(TimerInfo existingTimer, TimerInfo updatedTimer)
{
// Update the program info but retain the status
existingTimer.ChannelId = updatedTimer.ChannelId;
@@ -863,9 +857,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public string GetActiveRecordingPath(string id)
{
- ActiveRecordingInfo info;
-
- if (_activeRecordings.TryGetValue(id, out info))
+ if (_activeRecordings.TryGetValue(id, out var info))
{
return info.Path;
}
@@ -964,7 +956,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (string.IsNullOrWhiteSpace(tunerHostId))
{
- throw new ArgumentNullException("tunerHostId");
+ throw new ArgumentNullException(nameof(tunerHostId));
}
return info.EnabledTuners.Contains(tunerHostId, StringComparer.OrdinalIgnoreCase);
@@ -1039,7 +1031,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
_logger.LogInformation("Streaming Channel " + channelId);
- var result = string.IsNullOrEmpty(streamId) ?
+ var result = string.IsNullOrEmpty(streamId) ?
null :
currentLiveStreams.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase));
@@ -1098,7 +1090,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
if (string.IsNullOrWhiteSpace(channelId))
{
- throw new ArgumentNullException("channelId");
+ throw new ArgumentNullException(nameof(channelId));
}
foreach (var hostInstance in _liveTvManager.TunerHosts)
@@ -1182,14 +1174,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
return;
}
- var registration = await _liveTvManager.GetRegistrationInfo("dvr").ConfigureAwait(false);
- if (!registration.IsValid)
- {
- _logger.LogWarning("Emby Premiere required to use Emby DVR.");
- OnTimerOutOfDate(timer);
- return;
- }
-
var activeRecordingInfo = new ActiveRecordingInfo
{
CancellationTokenSource = new CancellationTokenSource(),
@@ -1326,7 +1310,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
if (timer == null)
{
- throw new ArgumentNullException("timer");
+ throw new ArgumentNullException(nameof(timer));
}
LiveTvProgram programInfo = null;
@@ -1439,8 +1423,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
TriggerRefresh(recordPath);
_libraryMonitor.ReportFileSystemChangeComplete(recordPath, false);
- ActiveRecordingInfo removed;
- _activeRecordings.TryRemove(timer.Id, out removed);
+ _activeRecordings.TryRemove(timer.Id, out var removed);
if (recordingStatus != RecordingStatus.Completed && DateTime.UtcNow < timer.EndDate && timer.RetryCount < 10)
{
@@ -1779,7 +1762,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
}
- private string GetPostProcessArguments(string path, string arguments)
+ private static string GetPostProcessArguments(string path, string arguments)
{
return arguments.Replace("{path}", path, StringComparison.OrdinalIgnoreCase);
}
@@ -2001,11 +1984,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
CloseOutput = false
};
- using (XmlWriter writer = XmlWriter.Create(stream, settings))
+ using (var writer = XmlWriter.Create(stream, settings))
{
writer.WriteStartDocument(true);
writer.WriteStartElement("tvshow");
-
string id;
if (timer.SeriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id))
{
@@ -2068,7 +2050,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var isSeriesEpisode = timer.IsProgramSeries;
- using (XmlWriter writer = XmlWriter.Create(stream, settings))
+ using (var writer = XmlWriter.Create(stream, settings))
{
writer.WriteStartDocument(true);
@@ -2378,46 +2360,61 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var allTimers = GetTimersForSeries(seriesTimer)
.ToList();
- var registration = await _liveTvManager.GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);
var enabledTimersForSeries = new List<TimerInfo>();
-
- if (registration.IsValid)
+ foreach (var timer in allTimers)
{
- foreach (var timer in allTimers)
+ var existingTimer = _timerProvider.GetTimer(timer.Id);
+
+ if (existingTimer == null)
{
- var existingTimer = _timerProvider.GetTimer(timer.Id);
+ existingTimer = string.IsNullOrWhiteSpace(timer.ProgramId)
+ ? null
+ : _timerProvider.GetTimerByProgramId(timer.ProgramId);
+ }
- if (existingTimer == null)
+ if (existingTimer == null)
+ {
+ if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer))
{
- existingTimer = string.IsNullOrWhiteSpace(timer.ProgramId)
- ? null
- : _timerProvider.GetTimerByProgramId(timer.ProgramId);
+ timer.Status = RecordingStatus.Cancelled;
}
+ else
+ {
+ enabledTimersForSeries.Add(timer);
+ }
+ _timerProvider.Add(timer);
- if (existingTimer == null)
+ TimerCreated?.Invoke(this, new GenericEventArgs<TimerInfo>(timer));
+ }
+ // Only update if not currently active - test both new timer and existing in case Id's are different
+ // Id's could be different if the timer was created manually prior to series timer creation
+ else if (!_activeRecordings.TryGetValue(timer.Id, out _) && !_activeRecordings.TryGetValue(existingTimer.Id, out _))
+ {
+ UpdateExistingTimerWithNewMetadata(existingTimer, timer);
+
+ // Needed by ShouldCancelTimerForSeriesTimer
+ timer.IsManual = existingTimer.IsManual;
+
+ if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer))
{
- if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer))
- {
- timer.Status = RecordingStatus.Cancelled;
- }
- else
- {
- enabledTimersForSeries.Add(timer);
- }
- _timerProvider.Add(timer);
+ existingTimer.Status = RecordingStatus.Cancelled;
+ }
+ else if (!existingTimer.IsManual)
+ {
+ existingTimer.Status = RecordingStatus.New;
+ }
- if (TimerCreated != null)
- {
- TimerCreated(this, new GenericEventArgs<TimerInfo>(timer));
- }
+ if (existingTimer.Status != RecordingStatus.Cancelled)
+ {
+ enabledTimersForSeries.Add(existingTimer);
}
- else
+
+ if (updateTimerSettings)
{
// Only update if not currently active - test both new timer and existing in case Id's are different
// Id's could be different if the timer was created manually prior to series timer creation
- ActiveRecordingInfo activeRecordingInfo;
- if (!_activeRecordings.TryGetValue(timer.Id, out activeRecordingInfo) && !_activeRecordings.TryGetValue(existingTimer.Id, out activeRecordingInfo))
+ if (!_activeRecordings.TryGetValue(timer.Id, out var activeRecordingInfo) && !_activeRecordings.TryGetValue(existingTimer.Id, out activeRecordingInfo))
{
UpdateExistingTimerWithNewMetadata(existingTimer, timer);
@@ -2452,6 +2449,9 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_timerProvider.Update(existingTimer);
}
}
+
+ existingTimer.SeriesTimerId = seriesTimer.Id;
+ _timerProvider.Update(existingTimer);
}
}
@@ -2485,7 +2485,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
if (seriesTimer == null)
{
- throw new ArgumentNullException("seriesTimer");
+ throw new ArgumentNullException(nameof(seriesTimer));
}
var query = new InternalItemsQuery
@@ -2520,9 +2520,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (string.IsNullOrWhiteSpace(channelId) && !parent.ChannelId.Equals(Guid.Empty))
{
- LiveTvChannel channel;
-
- if (!tempChannelCache.TryGetValue(parent.ChannelId, out channel))
+ if (!tempChannelCache.TryGetValue(parent.ChannelId, out LiveTvChannel channel))
{
channel = _libraryManager.GetItemList(new InternalItemsQuery
{
@@ -2581,9 +2579,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (!programInfo.ChannelId.Equals(Guid.Empty))
{
- LiveTvChannel channel;
-
- if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out channel))
+ if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out LiveTvChannel channel))
{
channel = _libraryManager.GetItemList(new InternalItemsQuery
{
@@ -2781,15 +2777,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var configuredDevice = configuredDevices.FirstOrDefault(i => string.Equals(i.DeviceId, device.DeviceId, StringComparison.OrdinalIgnoreCase));
- if (configuredDevice != null)
+ if (configuredDevice != null && !string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase))
{
- if (!string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase))
- {
- _logger.LogInformation("Tuner url has changed from {0} to {1}", configuredDevice.Url, device.Url);
+ _logger.LogInformation("Tuner url has changed from {PreviousUrl} to {NewUrl}", configuredDevice.Url, device.Url);
- configuredDevice.Url = device.Url;
- await _liveTvManager.SaveTunerHost(configuredDevice).ConfigureAwait(false);
- }
+ configuredDevice.Url = device.Url;
+ await _liveTvManager.SaveTunerHost(configuredDevice).ConfigureAwait(false);
}
}
}
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
index 4ea83b7ac..c09ee9348 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
@@ -1,27 +1,25 @@
-using System;
+using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using MediaBrowser.Model.IO;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Diagnostics;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.LiveTv;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.Serialization;
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Controller.Library;
+using MediaBrowser.Model.IO;
using MediaBrowser.Model.Reflection;
+using MediaBrowser.Model.Serialization;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
@@ -55,14 +53,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_assemblyInfo = assemblyInfo;
}
- private bool CopySubtitles
- {
- get
- {
- return false;
- //return string.Equals(OutputFormat, "mkv", StringComparison.OrdinalIgnoreCase);
- }
- }
+ private static bool CopySubtitles => false;
public string GetOutputPath(MediaSourceInfo mediaSource, string targetFile)
{
@@ -214,19 +205,19 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var outputParam = string.Empty;
- var commandLineArgs = string.Format("-i \"{0}\"{5} {2} -map_metadata -1 -threads 0 {3}{4}{6} -y \"{1}\"",
- inputTempFile,
- targetFile,
- videoArgs,
- GetAudioArgs(mediaSource),
- subtitleArgs,
- durationParam,
+ var commandLineArgs = string.Format("-i \"{0}\"{5} {2} -map_metadata -1 -threads 0 {3}{4}{6} -y \"{1}\"",
+ inputTempFile,
+ targetFile,
+ videoArgs,
+ GetAudioArgs(mediaSource),
+ subtitleArgs,
+ durationParam,
outputParam);
return inputModifier + " " + commandLineArgs;
}
- private string GetAudioArgs(MediaSourceInfo mediaSource)
+ private static string GetAudioArgs(MediaSourceInfo mediaSource)
{
var mediaStreams = mediaSource.MediaStreams ?? new List<MediaStream>();
var inputAudioCodec = mediaStreams.Where(i => i.Type == MediaStreamType.Audio).Select(i => i.Codec).FirstOrDefault() ?? string.Empty;
@@ -242,7 +233,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
//return "-codec:a:0 aac -strict experimental -ab 320000";
}
- private bool EncodeVideo(MediaSourceInfo mediaSource)
+ private static bool EncodeVideo(MediaSourceInfo mediaSource)
{
return false;
}
@@ -383,6 +374,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
catch (ObjectDisposedException)
{
+ // TODO Investigate and properly fix.
// Don't spam the log. This doesn't seem to throw in windows, but sometimes under linux
}
catch (Exception ex)
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs
index cc9e80a82..982a54b68 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs
@@ -1,4 +1,3 @@
-using System;
using MediaBrowser.Controller.Plugins;
namespace Emby.Server.Implementations.LiveTv.EmbyTV
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs
index e639a312c..6eced3050 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Library;
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
index 9f179dc2c..1b8287ed1 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
@@ -1,12 +1,10 @@
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-
-using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Serialization;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
@@ -68,7 +66,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
if (newList == null)
{
- throw new ArgumentNullException("newList");
+ throw new ArgumentNullException(nameof(newList));
}
var file = _dataPath + ".json";
@@ -85,7 +83,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
var list = GetAll().ToList();
@@ -106,7 +104,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
if (item == null)
{
- throw new ArgumentNullException("item");
+ throw new ArgumentNullException(nameof(item));
}
var list = GetAll().ToList();
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
index e694a8281..ded3c7607 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
@@ -1,6 +1,6 @@
-using MediaBrowser.Controller.LiveTv;
using System;
using System.Globalization;
+using MediaBrowser.Controller.LiveTv;
namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs
index 620ba7650..d2ad65a1e 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs
@@ -1,8 +1,8 @@
-using MediaBrowser.Controller.LiveTv;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.Serialization;
using System;
+using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Serialization;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
index 76a044c02..7f67d70a9 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
@@ -1,15 +1,14 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Globalization;
using System.Linq;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.Events;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.LiveTv;
+using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Threading;
-using MediaBrowser.Model.System;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
@@ -20,14 +19,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public event EventHandler<GenericEventArgs<TimerInfo>> TimerFired;
private readonly ITimerFactory _timerFactory;
- private readonly IPowerManagement _powerManagement;
- public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1, ITimerFactory timerFactory, IPowerManagement powerManagement)
+ public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1, ITimerFactory timerFactory)
: base(fileSystem, jsonSerializer, logger, dataPath, (r1, r2) => string.Equals(r1.Id, r2.Id, StringComparison.OrdinalIgnoreCase))
{
_logger = logger1;
_timerFactory = timerFactory;
- _powerManagement = powerManagement;
}
public void RestartTimers()
@@ -36,7 +33,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
foreach (var item in GetAll().ToList())
{
- AddOrUpdateSystemTimer(item, false);
+ AddOrUpdateSystemTimer(item);
}
}
@@ -59,7 +56,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public override void Update(TimerInfo item)
{
base.Update(item);
- AddOrUpdateSystemTimer(item, false);
+ AddOrUpdateSystemTimer(item);
}
public void AddOrUpdate(TimerInfo item, bool resetTimer)
@@ -90,10 +87,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
base.Add(item);
- AddOrUpdateSystemTimer(item, true);
+ AddOrUpdateSystemTimer(item);
}
- private bool ShouldStartTimer(TimerInfo item)
+ private static bool ShouldStartTimer(TimerInfo item)
{
if (item.Status == RecordingStatus.Completed ||
item.Status == RecordingStatus.Cancelled)
@@ -104,7 +101,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
return true;
}
- private void AddOrUpdateSystemTimer(TimerInfo item, bool scheduleSystemWakeTimer)
+ private void AddOrUpdateSystemTimer(TimerInfo item)
{
StopTimer(item);
@@ -124,23 +121,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var dueTime = startDate - now;
StartTimer(item, dueTime);
-
- if (scheduleSystemWakeTimer && dueTime >= TimeSpan.FromMinutes(15))
- {
- ScheduleSystemWakeTimer(startDate, item.Name);
- }
- }
-
- private void ScheduleSystemWakeTimer(DateTime startDate, string displayName)
- {
- try
- {
- _powerManagement.ScheduleWake(startDate.AddMinutes(-5), displayName);
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error scheduling wake timer");
- }
}
private void StartTimer(TimerInfo item, TimeSpan dueTime)
@@ -160,8 +140,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private void StopTimer(TimerInfo item)
{
- ITimer timer;
- if (_timers.TryRemove(item.Id, out timer))
+ if (_timers.TryRemove(item.Id, out var timer))
{
timer.Dispose();
}
diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
index e8ffd0caa..0bbffb824 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
@@ -1,22 +1,22 @@
-using System.Net;
-using MediaBrowser.Common;
-using MediaBrowser.Common.Net;
-using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.LiveTv;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.Net;
-using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Net;
using System.Threading;
using System.Threading.Tasks;
-using MediaBrowser.Model.Extensions;
+using MediaBrowser.Common;
+using MediaBrowser.Common.Net;
+using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.LiveTv;
+using MediaBrowser.Model.Net;
+using MediaBrowser.Model.Serialization;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.Listings
{
@@ -38,14 +38,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings
_appHost = appHost;
}
- private string UserAgent
- {
- get { return "Emby/" + _appHost.ApplicationVersion; }
- }
+ private string UserAgent => _appHost.ApplicationUserAgent;
- private List<string> GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc)
+ private static List<string> GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc)
{
- List<string> dates = new List<string>();
+ var dates = new List<string>();
var start = new List<DateTime> { startDateUtc, startDateUtc.ToLocalTime() }.Min().Date;
var end = new List<DateTime> { endDateUtc, endDateUtc.ToLocalTime() }.Max().Date;
@@ -63,7 +60,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
if (string.IsNullOrEmpty(channelId))
{
- throw new ArgumentNullException("channelId");
+ throw new ArgumentNullException(nameof(channelId));
}
// Normalize incoming input
@@ -107,7 +104,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
httpOptions.RequestHeaders["token"] = token;
using (var response = await Post(httpOptions, true, info).ConfigureAwait(false))
- using (StreamReader reader = new StreamReader(response.Content))
+ using (var reader = new StreamReader(response.Content))
{
var dailySchedules = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.Day>>(response.Content).ConfigureAwait(false);
_logger.LogDebug("Found {ScheduleCount} programs on {ChannelID} ScheduleDirect", dailySchedules.Count, channelId);
@@ -128,7 +125,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
httpOptions.RequestContent = "[\"" + string.Join("\", \"", programsID) + "\"]";
using (var innerResponse = await Post(httpOptions, true, info).ConfigureAwait(false))
- using (StreamReader innerReader = new StreamReader(innerResponse.Content))
+ using (var innerReader = new StreamReader(innerResponse.Content))
{
var programDetails = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.ProgramDetails>>(innerResponse.Content).ConfigureAwait(false);
var programDict = programDetails.ToDictionary(p => p.programID, y => y);
@@ -139,7 +136,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
var images = await GetImageForPrograms(info, programIdsWithImages, cancellationToken).ConfigureAwait(false);
- List<ProgramInfo> programsInfo = new List<ProgramInfo>();
+ var programsInfo = new List<ProgramInfo>();
foreach (ScheduleDirect.Program schedule in dailySchedules.SelectMany(d => d.programs))
{
//_logger.LogDebug("Proccesing Schedule for statio ID " + stationID +
@@ -189,7 +186,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- private int GetSizeOrder(ScheduleDirect.ImageData image)
+ private static int GetSizeOrder(ScheduleDirect.ImageData image)
{
if (!string.IsNullOrWhiteSpace(image.height))
{
@@ -202,7 +199,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
return 0;
}
- private string GetChannelNumber(ScheduleDirect.Map map)
+ private static string GetChannelNumber(ScheduleDirect.Map map)
{
var channelNumber = map.logicalChannelNumber;
@@ -218,16 +215,16 @@ namespace Emby.Server.Implementations.LiveTv.Listings
return channelNumber.TrimStart('0');
}
- private bool IsMovie(ScheduleDirect.ProgramDetails programInfo)
+ private static bool IsMovie(ScheduleDirect.ProgramDetails programInfo)
{
return string.Equals(programInfo.entityType, "movie", StringComparison.OrdinalIgnoreCase);
}
private ProgramInfo GetProgram(string channelId, ScheduleDirect.Program programInfo, ScheduleDirect.ProgramDetails details)
{
- DateTime startAt = GetDate(programInfo.airDateTime);
- DateTime endAt = startAt.AddSeconds(programInfo.duration);
- ProgramAudio audioType = ProgramAudio.Stereo;
+ var startAt = GetDate(programInfo.airDateTime);
+ var endAt = startAt.AddSeconds(programInfo.duration);
+ var audioType = ProgramAudio.Stereo;
var programId = programInfo.programID ?? string.Empty;
@@ -390,7 +387,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
return info;
}
- private DateTime GetDate(string value)
+ private static DateTime GetDate(string value)
{
var date = DateTime.ParseExact(value, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", CultureInfo.InvariantCulture);
@@ -429,7 +426,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- private double GetAspectRatio(ScheduleDirect.ImageData i)
+ private static double GetAspectRatio(ScheduleDirect.ImageData i)
{
int width = 0;
int height = 0;
@@ -664,7 +661,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- options.RequestHeaders["token"] = await GetToken(providerInfo, options.CancellationToken).ConfigureAwait(false);;
+ options.RequestHeaders["token"] = await GetToken(providerInfo, options.CancellationToken).ConfigureAwait(false);
return await Post(options, false, providerInfo).ConfigureAwait(false);
}
@@ -765,16 +762,10 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- public string Name
- {
- get { return "Schedules Direct"; }
- }
+ public string Name => "Schedules Direct";
public static string TypeName = "SchedulesDirect";
- public string Type
- {
- get { return TypeName; }
- }
+ public string Type => TypeName;
private async Task<bool> HasLineup(ListingsProviderInfo info, CancellationToken cancellationToken)
{
@@ -951,7 +942,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
return null;
}
- private string NormalizeName(string value)
+ private static string NormalizeName(string value)
{
return value.Replace(" ", string.Empty).Replace("-", string.Empty);
}
diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
index 4d7c7fef4..e7a3d748d 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
@@ -36,15 +36,9 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
_zipClient = zipClient;
}
- public string Name
- {
- get { return "XmlTV"; }
- }
+ public string Name => "XmlTV";
- public string Type
- {
- get { return "xmltv"; }
- }
+ public string Type => "xmltv";
private string GetLanguage(ListingsProviderInfo info)
{
@@ -78,7 +72,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
{
CancellationToken = cancellationToken,
Url = path,
- Progress = new SimpleProgress<Double>(),
+ Progress = new SimpleProgress<double>(),
DecompressionMethod = CompressionMethod.Gzip,
// It's going to come back gzipped regardless of this value
@@ -164,7 +158,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
{
if (string.IsNullOrWhiteSpace(channelId))
{
- throw new ArgumentNullException("channelId");
+ throw new ArgumentNullException(nameof(channelId));
}
/*
@@ -187,7 +181,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
.Select(p => GetProgramInfo(p, info));
}
- private ProgramInfo GetProgramInfo(XmlTvProgram program, ListingsProviderInfo info)
+ private static ProgramInfo GetProgramInfo(XmlTvProgram program, ListingsProviderInfo info)
{
string episodeTitle = program.Episode?.Title;
@@ -210,9 +204,9 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
IsMovie = program.Categories.Any(c => info.MovieCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
IsNews = program.Categories.Any(c => info.NewsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
IsSports = program.Categories.Any(c => info.SportsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)),
- ImageUrl = program.Icon != null && !String.IsNullOrEmpty(program.Icon.Source) ? program.Icon.Source : null,
- HasImage = program.Icon != null && !String.IsNullOrEmpty(program.Icon.Source),
- OfficialRating = program.Rating != null && !String.IsNullOrEmpty(program.Rating.Value) ? program.Rating.Value : null,
+ ImageUrl = program.Icon != null && !string.IsNullOrEmpty(program.Icon.Source) ? program.Icon.Source : null,
+ HasImage = program.Icon != null && !string.IsNullOrEmpty(program.Icon.Source),
+ OfficialRating = program.Rating != null && !string.IsNullOrEmpty(program.Rating.Value) ? program.Rating.Value : null,
CommunityRating = program.StarRating,
SeriesId = program.Episode == null ? null : program.Title.GetMD5().ToString("N")
};
@@ -246,7 +240,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
}
// Construct an id from the channel and start date
- programInfo.Id = String.Format("{0}_{1:O}", program.ChannelId, program.StartDate);
+ programInfo.Id = string.Format("{0}_{1:O}", program.ChannelId, program.StartDate);
if (programInfo.IsMovie)
{
@@ -287,14 +281,14 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings
string path = await GetXml(info.Path, cancellationToken).ConfigureAwait(false);
_logger.LogDebug("Opening XmlTvReader for {path}", path);
var reader = new XmlTvReader(path, GetLanguage(info));
- IEnumerable<XmlTvChannel> results = reader.GetChannels();
+ var results = reader.GetChannels();
// Should this method be async?
return results.Select(c => new ChannelInfo
{
Id = c.Id,
Name = c.DisplayName,
- ImageUrl = c.Icon != null && !String.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null,
+ ImageUrl = c.Icon != null && !string.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null,
Number = string.IsNullOrWhiteSpace(c.Number) ? c.Id : c.Number
}).ToList();
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvConfigurationFactory.cs b/Emby.Server.Implementations/LiveTv/LiveTvConfigurationFactory.cs
index 205a767eb..f9b274acb 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvConfigurationFactory.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvConfigurationFactory.cs
@@ -1,6 +1,6 @@
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Model.LiveTv;
using System.Collections.Generic;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Model.LiveTv;
namespace Emby.Server.Implementations.LiveTv
{
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
index 6fe578715..724e8afdf 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
@@ -1,21 +1,19 @@
-using MediaBrowser.Common;
+using System;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MediaBrowser.Common;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.LiveTv;
using Microsoft.Extensions.Logging;
-using System;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using MediaBrowser.Controller.Entities.TV;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Extensions;
-using System.Collections.Generic;
namespace Emby.Server.Implementations.LiveTv
{
@@ -28,11 +26,16 @@ namespace Emby.Server.Implementations.LiveTv
private readonly IApplicationHost _appHost;
private readonly ILibraryManager _libraryManager;
- public LiveTvDtoService(IDtoService dtoService, IImageProcessor imageProcessor, ILogger logger, IApplicationHost appHost, ILibraryManager libraryManager)
+ public LiveTvDtoService(
+ IDtoService dtoService,
+ IImageProcessor imageProcessor,
+ ILoggerFactory loggerFactory,
+ IApplicationHost appHost,
+ ILibraryManager libraryManager)
{
_dtoService = dtoService;
_imageProcessor = imageProcessor;
- _logger = logger;
+ _logger = loggerFactory.CreateLogger(nameof(LiveTvDtoService));
_appHost = appHost;
_libraryManager = libraryManager;
}
@@ -321,6 +324,7 @@ namespace Emby.Server.Implementations.LiveTv
}
catch (Exception ex)
{
+ _logger.LogDebug(ex, "GetImageCacheTag raised an exception in LiveTvDtoService.FillImages.");
}
}
@@ -331,10 +335,10 @@ namespace Emby.Server.Implementations.LiveTv
{
try
{
- dto.ParentBackdropImageTags = new string[]
- {
- _imageProcessor.GetImageCacheTag(program, image)
- };
+ dto.ParentBackdropImageTags = new[]
+ {
+ _imageProcessor.GetImageCacheTag(program, image)
+ };
dto.ParentBackdropItemId = program.Id.ToString("N");
}
catch (Exception ex)
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
index b597a935a..575cb1c77 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -1,10 +1,21 @@
-using MediaBrowser.Common.Configuration;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Emby.Server.Implementations.Library;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Net;
using MediaBrowser.Common.Progress;
+using MediaBrowser.Controller;
+using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.Movies;
+using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Persistence;
@@ -12,28 +23,15 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.LiveTv;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.Querying;
-using MediaBrowser.Model.Serialization;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Common.Security;
-using MediaBrowser.Controller.Entities.Movies;
-using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Globalization;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.LiveTv;
+using MediaBrowser.Model.Querying;
+using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Tasks;
-using Emby.Server.Implementations.LiveTv.Listings;
-using MediaBrowser.Controller.Channels;
-using Emby.Server.Implementations.Library;
-using MediaBrowser.Controller;
-using MediaBrowser.Common.Net;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv
{
@@ -51,7 +49,6 @@ namespace Emby.Server.Implementations.LiveTv
private readonly ITaskManager _taskManager;
private readonly IJsonSerializer _jsonSerializer;
private readonly IProviderManager _providerManager;
- private readonly ISecurityManager _security;
private readonly Func<IChannelManager> _channelManager;
private readonly IDtoService _dtoService;
@@ -75,14 +72,25 @@ namespace Emby.Server.Implementations.LiveTv
return EmbyTV.EmbyTV.Current.GetActiveRecordingPath(id);
}
- private IServerApplicationHost _appHost;
- private IHttpClient _httpClient;
-
- public LiveTvManager(IServerApplicationHost appHost, IHttpClient httpClient, 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, Func<IChannelManager> channelManager)
+ public LiveTvManager(
+ IServerApplicationHost appHost,
+ IServerConfigurationManager config,
+ ILoggerFactory loggerFactory,
+ IItemRepository itemRepo,
+ IImageProcessor imageProcessor,
+ IUserDataManager userDataManager,
+ IDtoService dtoService,
+ IUserManager userManager,
+ ILibraryManager libraryManager,
+ ITaskManager taskManager,
+ ILocalizationManager localization,
+ IJsonSerializer jsonSerializer,
+ IProviderManager providerManager,
+ IFileSystem fileSystem,
+ Func<IChannelManager> channelManager)
{
- _appHost = appHost;
_config = config;
- _logger = logger;
+ _logger = loggerFactory.CreateLogger(nameof(LiveTvManager));
_itemRepo = itemRepo;
_userManager = userManager;
_libraryManager = libraryManager;
@@ -91,23 +99,18 @@ namespace Emby.Server.Implementations.LiveTv
_jsonSerializer = jsonSerializer;
_providerManager = providerManager;
_fileSystem = fileSystem;
- _security = security;
_dtoService = dtoService;
_userDataManager = userDataManager;
_channelManager = channelManager;
- _httpClient = httpClient;
- _tvDtoService = new LiveTvDtoService(dtoService, imageProcessor, logger, appHost, _libraryManager);
+ _tvDtoService = new LiveTvDtoService(dtoService, imageProcessor, loggerFactory, appHost, _libraryManager);
}
/// <summary>
/// Gets the services.
/// </summary>
/// <value>The services.</value>
- public IReadOnlyList<ILiveTvService> Services
- {
- get { return _services; }
- }
+ public IReadOnlyList<ILiveTvService> Services => _services;
private LiveTvOptions GetConfiguration()
{
@@ -167,15 +170,9 @@ namespace Emby.Server.Implementations.LiveTv
});
}
- public ITunerHost[] TunerHosts
- {
- get { return _tunerHosts; }
- }
+ public ITunerHost[] TunerHosts => _tunerHosts;
- public IListingsProvider[] ListingProviders
- {
- get { return _listingProviders; }
- }
+ public IListingsProvider[] ListingProviders => _listingProviders;
public List<NameIdPair> GetTunerHostTypes()
{
@@ -251,7 +248,7 @@ namespace Emby.Server.Implementations.LiveTv
var channel = (LiveTvChannel)_libraryManager.GetItemById(id);
bool isVideo = channel.ChannelType == ChannelType.TV;
- ILiveTvService service = GetService(channel);
+ var service = GetService(channel);
_logger.LogInformation("Opening channel stream from {0}, external channel Id: {1}", service.Name, channel.ExternalId);
MediaSourceInfo info;
@@ -323,7 +320,7 @@ namespace Emby.Server.Implementations.LiveTv
return _services.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
}
- private void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo)
+ private static void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo)
{
// Not all of the plugins are setting this
mediaSource.IsInfiniteStream = true;
@@ -537,8 +534,7 @@ namespace Emby.Server.Implementations.LiveTv
var isNew = false;
var forceUpdate = false;
- LiveTvProgram item;
- if (!allExistingPrograms.TryGetValue(id, out item))
+ if (!allExistingPrograms.TryGetValue(id, out LiveTvProgram item))
{
isNew = true;
item = new LiveTvProgram
@@ -901,7 +897,7 @@ namespace Emby.Server.Implementations.LiveTv
var programList = _libraryManager.QueryItems(internalQuery).Items;
var totalCount = programList.Length;
- IOrderedEnumerable<LiveTvProgram> orderedPrograms = programList.Cast<LiveTvProgram>().OrderBy(i => i.StartDate.Date);
+ var orderedPrograms = programList.Cast<LiveTvProgram>().OrderBy(i => i.StartDate.Date);
if (query.IsAiring ?? false)
{
@@ -917,10 +913,10 @@ namespace Emby.Server.Implementations.LiveTv
}
return new QueryResult<BaseItem>
- {
- Items = programs.ToArray(),
- TotalRecordCount = totalCount
- };
+ {
+ Items = programs.ToArray(),
+ TotalRecordCount = totalCount
+ };
}
public QueryResult<BaseItemDto> GetRecommendedPrograms(InternalItemsQuery query, DtoOptions options, CancellationToken cancellationToken)
@@ -935,10 +931,10 @@ namespace Emby.Server.Implementations.LiveTv
var internalResult = GetRecommendedProgramsInternal(query, options, cancellationToken);
return new QueryResult<BaseItemDto>
- {
- Items = _dtoService.GetBaseItemDtos(internalResult.Items, options, query.User),
- TotalRecordCount = internalResult.TotalRecordCount
- };
+ {
+ Items = _dtoService.GetBaseItemDtos(internalResult.Items, options, query.User),
+ TotalRecordCount = internalResult.TotalRecordCount
+ };
}
private int GetRecommendationScore(LiveTvProgram program, User user, bool factorChannelWatchCount)
@@ -1056,7 +1052,7 @@ namespace Emby.Server.Implementations.LiveTv
var numComplete = 0;
double progressPerService = _services.Length == 0
? 0
- : 1 / _services.Length;
+ : 1.0 / _services.Length;
var newChannelIdList = new List<Guid>();
var newProgramIdList = new List<Guid>();
@@ -1262,7 +1258,7 @@ namespace Emby.Server.Implementations.LiveTv
}
numComplete++;
- double percent = numComplete / allChannelsList.Count;
+ double percent = numComplete / (double)allChannelsList.Count;
progress.Report(85 * percent + 15);
}
@@ -1307,7 +1303,7 @@ namespace Emby.Server.Implementations.LiveTv
}
numComplete++;
- double percent = numComplete / list.Count;
+ double percent = numComplete / (double)list.Count;
progress.Report(100 * percent);
}
@@ -1418,6 +1414,7 @@ namespace Emby.Server.Implementations.LiveTv
if (query.IsInProgress ?? false)
{
+ //TODO Fix The co-variant conversion between Video[] and BaseItem[], this can generate runtime issues.
result.Items = result
.Items
.OfType<Video>()
@@ -1948,8 +1945,7 @@ namespace Emby.Server.Implementations.LiveTv
foreach (var programDto in currentProgramDtos)
{
- BaseItemDto channelDto;
- if (currentChannelsDict.TryGetValue(programDto.ChannelId, out channelDto))
+ if (currentChannelsDict.TryGetValue(programDto.ChannelId, out BaseItemDto channelDto))
{
channelDto.CurrentProgram = programDto;
}
@@ -1962,7 +1958,7 @@ namespace Emby.Server.Implementations.LiveTv
ILiveTvService service = null;
ProgramInfo programInfo = null;
- if(program != null)
+ if (program != null)
{
service = GetService(program);
@@ -1993,7 +1989,7 @@ namespace Emby.Server.Implementations.LiveTv
Name = program.Name,
OfficialRating = program.OfficialRating
};
- }
+ }
if (service == null)
{
@@ -2095,14 +2091,6 @@ namespace Emby.Server.Implementations.LiveTv
public async Task CreateSeriesTimer(SeriesTimerInfoDto timer, CancellationToken cancellationToken)
{
- var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);
-
- if (!registration.IsValid)
- {
- _logger.LogInformation("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);
@@ -2188,7 +2176,7 @@ namespace Emby.Server.Implementations.LiveTv
return Services.Select(GetServiceInfo).ToArray();
}
- private LiveTvServiceInfo GetServiceInfo(ILiveTvService service)
+ private static LiveTvServiceInfo GetServiceInfo(ILiveTvService service)
{
return new LiveTvServiceInfo
{
@@ -2245,7 +2233,7 @@ namespace Emby.Server.Implementations.LiveTv
return service.ResetTuner(parts[1], cancellationToken);
}
- private void RemoveFields(DtoOptions options)
+ private static void RemoveFields(DtoOptions options)
{
var fields = options.Fields.ToList();
@@ -2310,7 +2298,7 @@ namespace Emby.Server.Implementations.LiveTv
// ServerConfiguration.SaveConfiguration crashes during xml serialization for AddListingProvider
info = _jsonSerializer.DeserializeFromString<ListingsProviderInfo>(_jsonSerializer.SerializeToString(info));
- IListingsProvider provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));
+ var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));
if (provider == null)
{
@@ -2323,7 +2311,7 @@ namespace Emby.Server.Implementations.LiveTv
LiveTvOptions config = GetConfiguration();
- List<ListingsProviderInfo> list = config.ListingProviders.ToList();
+ var list = config.ListingProviders.ToList();
int index = list.FindIndex(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase));
if (index == -1 || string.IsNullOrWhiteSpace(info.Id))
@@ -2444,30 +2432,6 @@ namespace Emby.Server.Implementations.LiveTv
}
}
- public Task<MBRegistrationRecord> GetRegistrationInfo(string feature)
- {
- if (string.Equals(feature, "seriesrecordings", StringComparison.OrdinalIgnoreCase))
- {
- feature = "embytvseriesrecordings";
- }
-
- if (string.Equals(feature, "dvr-l", StringComparison.OrdinalIgnoreCase))
- {
- var config = GetConfiguration();
- if (config.TunerHosts.Length > 0 &&
- config.ListingProviders.Count(i => (i.EnableAllTuners || i.EnabledTuners.Length > 0) && string.Equals(i.Type, SchedulesDirect.TypeName, StringComparison.OrdinalIgnoreCase)) > 0)
- {
- return Task.FromResult(new MBRegistrationRecord
- {
- IsRegistered = true,
- IsValid = true
- });
- }
- }
-
- return _security.GetRegistrationStatus(feature);
- }
-
public Task<List<ChannelInfo>> GetChannelsForListingsProvider(string id, CancellationToken cancellationToken)
{
var info = GetConfiguration().ListingProviders.First(i => string.Equals(i.Id, id, StringComparison.OrdinalIgnoreCase));
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs
index d13f08b1b..cd1731de5 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs
@@ -1,21 +1,18 @@
-using MediaBrowser.Controller;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Dto;
-using Microsoft.Extensions.Logging;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Serialization;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using MediaBrowser.Model.Dlna;
-using MediaBrowser.Model.Extensions;
-using MediaBrowser.Common.Configuration;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv
{
diff --git a/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs b/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs
index 225360159..542951de4 100644
--- a/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs
+++ b/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs
@@ -1,10 +1,9 @@
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Model.LiveTv;
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Threading.Tasks;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Tasks;
namespace Emby.Server.Implementations.LiveTv
@@ -20,20 +19,11 @@ namespace Emby.Server.Implementations.LiveTv
_config = config;
}
- public string Name
- {
- get { return "Refresh Guide"; }
- }
+ public string Name => "Refresh Guide";
- public string Description
- {
- get { return "Downloads channel information from live tv services."; }
- }
+ public string Description => "Downloads channel information from live tv services.";
- public string Category
- {
- get { return "Live TV"; }
- }
+ public string Category => "Live TV";
public Task Execute(System.Threading.CancellationToken cancellationToken, IProgress<double> progress)
{
@@ -48,8 +38,8 @@ namespace Emby.Server.Implementations.LiveTv
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
- return new[] {
-
+ return new[] {
+
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}
};
@@ -60,24 +50,12 @@ namespace Emby.Server.Implementations.LiveTv
return _config.GetConfiguration<LiveTvOptions>("livetv");
}
- public bool IsHidden
- {
- get { return _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Length == 0; }
- }
+ public bool IsHidden => _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Length == 0;
- public bool IsEnabled
- {
- get { return true; }
- }
+ public bool IsEnabled => true;
- public bool IsLogged
- {
- get { return true; }
- }
+ public bool IsLogged => true;
- public string Key
- {
- get { return "RefreshGuide"; }
- }
+ public string Key => "RefreshGuide";
}
}
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
index ef2010ba6..ee86f66e6 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
@@ -1,8 +1,3 @@
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.LiveTv;
-using Microsoft.Extensions.Logging;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -10,13 +5,16 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.MediaEncoding;
-using MediaBrowser.Model.Dlna;
+using MediaBrowser.Model.Dto;
using MediaBrowser.Model.IO;
+using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Serialization;
-using MediaBrowser.Controller.Library;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
@@ -40,13 +38,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
FileSystem = fileSystem;
}
- public virtual bool IsSupported
- {
- get
- {
- return true;
- }
- }
+ public virtual bool IsSupported => true;
protected abstract Task<List<ChannelInfo>> GetChannelsInternal(TunerHostInfo tuner, CancellationToken cancellationToken);
public abstract string Type { get; }
@@ -140,7 +132,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
if (string.IsNullOrEmpty(channelId))
{
- throw new ArgumentNullException("channelId");
+ throw new ArgumentNullException(nameof(channelId));
}
if (IsValidChannelId(channelId))
@@ -175,7 +167,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
if (string.IsNullOrEmpty(channelId))
{
- throw new ArgumentNullException("channelId");
+ throw new ArgumentNullException(nameof(channelId));
}
if (!IsValidChannelId(channelId))
@@ -228,18 +220,13 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
throw new LiveTvConflictException();
}
- protected virtual string ChannelIdPrefix
- {
- get
- {
- return Type + "_";
- }
- }
+ protected virtual string ChannelIdPrefix => Type + "_";
+
protected virtual bool IsValidChannelId(string channelId)
{
if (string.IsNullOrEmpty(channelId))
{
- throw new ArgumentNullException("channelId");
+ throw new ArgumentNullException(nameof(channelId));
}
return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase);
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
index be090df0c..e8e4bc723 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
@@ -1,27 +1,27 @@
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Common.Net;
-using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.LiveTv;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.MediaInfo;
-using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using MediaBrowser.Model.IO;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.Dto;
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.LiveTv;
+using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Net;
+using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.System;
-using MediaBrowser.Controller.Library;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
@@ -42,28 +42,13 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
_environment = environment;
}
- public string Name
- {
- get { return "HD Homerun"; }
- }
+ public string Name => "HD Homerun";
- public override string Type
- {
- get { return DeviceType; }
- }
+ public override string Type => DeviceType;
- public static string DeviceType
- {
- get { return "hdhomerun"; }
- }
+ public static string DeviceType => "hdhomerun";
- protected override string ChannelIdPrefix
- {
- get
- {
- return "hdhr_";
- }
- }
+ protected override string ChannelIdPrefix => "hdhr_";
private string GetChannelId(TunerHostInfo info, Channels i)
{
@@ -133,8 +118,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
if (!string.IsNullOrEmpty(cacheKey))
{
- DiscoverResponse response;
- if (_modelCache.TryGetValue(cacheKey, out response))
+ if (_modelCache.TryGetValue(cacheKey, out DiscoverResponse response))
{
return response;
}
@@ -274,10 +258,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
for (int i = 0; i < model.TunerCount; ++i)
{
- var name = String.Format("Tuner {0}", i + 1);
- var currentChannel = "none"; /// @todo Get current channel and map back to Station Id
+ var name = string.Format("Tuner {0}", i + 1);
+ var currentChannel = "none"; /// @todo Get current channel and map back to Station Id
var isAvailable = await manager.CheckTunerAvailability(ipInfo, i, cancellationToken).ConfigureAwait(false);
- LiveTvTunerStatus status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv;
+ var status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv;
tuners.Add(new LiveTvTunerInfo
{
Name = name,
@@ -325,7 +309,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
return await GetTunerInfosHttp(info, cancellationToken).ConfigureAwait(false);
}
- private string GetApiUrl(TunerHostInfo info)
+ private static string GetApiUrl(TunerHostInfo info)
{
var url = info.Url;
@@ -359,7 +343,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
return Config.GetConfiguration<EncodingOptions>("encoding");
}
- private string GetHdHrIdFromChannelId(string channelId)
+ private static string GetHdHrIdFromChannelId(string channelId)
{
return channelId.Split('_')[1];
}
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
index 0e84622bd..2205c0ecc 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
@@ -1,14 +1,13 @@
-using System;
+using System;
using System.Collections.Generic;
-using System.Linq;
+using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.Net;
using Microsoft.Extensions.Logging;
-using MediaBrowser.Controller.LiveTv;
-using System.Net;
namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
@@ -37,10 +36,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
var commands = new List<Tuple<string, string>>();
- if (!String.IsNullOrEmpty(_channel))
+ if (!string.IsNullOrEmpty(_channel))
commands.Add(Tuple.Create("channel", _channel));
- if (!String.IsNullOrEmpty(_program))
+ if (!string.IsNullOrEmpty(_program))
commands.Add(Tuple.Create("program", _program));
return commands;
}
@@ -61,11 +60,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
var commands = new List<Tuple<string, string>>();
- if (!String.IsNullOrEmpty(_channel))
+ if (!string.IsNullOrEmpty(_channel))
{
if (!string.IsNullOrEmpty(_profile) && !string.Equals(_profile, "native", StringComparison.OrdinalIgnoreCase))
{
- commands.Add(Tuple.Create("vchannel", String.Format("{0} transcode={1}", _channel, _profile)));
+ commands.Add(Tuple.Create("vchannel", string.Format("{0} transcode={1}", _channel, _profile)));
}
else
{
@@ -123,7 +122,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
}
}
- private async Task<bool> CheckTunerAvailability(ISocket socket, IpAddressInfo remoteIp, int tuner, CancellationToken cancellationToken)
+ private static async Task<bool> CheckTunerAvailability(ISocket socket, IpAddressInfo remoteIp, int tuner, CancellationToken cancellationToken)
{
var ipEndPoint = new IpEndPointInfo(remoteIp, HdHomeRunPort);
@@ -133,8 +132,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
var receiveBuffer = new byte[8192];
var response = await socket.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false);
- string returnVal;
- ParseReturnMessage(response.Buffer, response.ReceivedBytes, out returnVal);
+ ParseReturnMessage(response.Buffer, response.ReceivedBytes, out string returnVal);
return string.Equals(returnVal, "none", StringComparison.OrdinalIgnoreCase);
}
@@ -164,13 +162,12 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
continue;
_activeTuner = i;
- var lockKeyString = String.Format("{0:d}", lockKeyValue);
+ var lockKeyString = string.Format("{0:d}", lockKeyValue);
var lockkeyMsg = CreateSetMessage(i, "lockkey", lockKeyString, null);
await tcpClient.SendToAsync(lockkeyMsg, 0, lockkeyMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false);
var response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false);
- string returnVal;
// parse response to make sure it worked
- if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out returnVal))
+ if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out var returnVal))
continue;
var commandList = commands.GetCommands();
@@ -188,7 +185,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
}
- var targetValue = String.Format("rtp://{0}:{1}", localIp, localPort);
+ var targetValue = string.Format("rtp://{0}:{1}", localIp, localPort);
var targetMsg = CreateSetMessage(i, "target", targetValue, lockKeyValue);
await tcpClient.SendToAsync(targetMsg, 0, targetMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false);
@@ -223,8 +220,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
await tcpClient.SendToAsync(channelMsg, 0, channelMsg.Length, new IpEndPointInfo(_remoteIp, HdHomeRunPort), cancellationToken).ConfigureAwait(false);
var response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false);
// parse response to make sure it worked
- string returnVal;
- if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out returnVal))
+ if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out string returnVal))
{
return;
}
@@ -262,7 +258,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
private static byte[] CreateGetMessage(int tuner, string name)
{
- var byteName = Encoding.UTF8.GetBytes(String.Format("/tuner{0}/{1}\0", tuner, name));
+ var byteName = Encoding.UTF8.GetBytes(string.Format("/tuner{0}/{1}\0", tuner, name));
int messageLength = byteName.Length + 10; // 4 bytes for header + 4 bytes for crc + 2 bytes for tag name and length
var message = new byte[messageLength];
@@ -280,10 +276,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
return message;
}
- private static byte[] CreateSetMessage(int tuner, String name, String value, uint? lockkey)
+ private static byte[] CreateSetMessage(int tuner, string name, string value, uint? lockkey)
{
- var byteName = Encoding.UTF8.GetBytes(String.Format("/tuner{0}/{1}\0", tuner, name));
- var byteValue = Encoding.UTF8.GetBytes(String.Format("{0}\0", value));
+ var byteName = Encoding.UTF8.GetBytes(string.Format("/tuner{0}/{1}\0", tuner, name));
+ var byteValue = Encoding.UTF8.GetBytes(string.Format("{0}\0", value));
int messageLength = byteName.Length + byteValue.Length + 12;
if (lockkey.HasValue)
@@ -360,7 +356,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
private static bool ParseReturnMessage(byte[] buf, int numBytes, out string returnVal)
{
- returnVal = String.Empty;
+ returnVal = string.Empty;
if (numBytes < 4)
return false;
@@ -411,7 +407,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
private class HdHomerunCrc
{
- private static UInt32[] crc_table = {
+ private static uint[] crc_table = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
@@ -477,7 +473,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d };
- public static UInt32 GetCrc32(byte[] bytes, int numBytes)
+ public static uint GetCrc32(byte[] bytes, int numBytes)
{
var hash = 0xffffffff;
for (var i = 0; i < numBytes; i++)
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs
index c781bccbb..2542ddd2a 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs
@@ -1,5 +1,8 @@
-using System;
+using System;
+using System.Collections.Generic;
using System.IO;
+using System.Net;
+using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
@@ -7,13 +10,9 @@ using MediaBrowser.Controller;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.IO;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.MediaInfo;
-using MediaBrowser.Model.System;
using MediaBrowser.Model.LiveTv;
-using System.Collections.Generic;
-using System.Net.Sockets;
-using System.Net;
+using MediaBrowser.Model.MediaInfo;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
@@ -38,7 +37,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
EnableStreamSharing = true;
}
- private Socket CreateSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
+ private static Socket CreateSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
{
var socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp);
@@ -144,7 +143,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
});
}
- private void Resolve(TaskCompletionSource<bool> openTaskCompletionSource)
+ private static void Resolve(TaskCompletionSource<bool> openTaskCompletionSource)
{
Task.Run(() =>
{
@@ -204,16 +203,16 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
if (buffer == null)
- throw new ArgumentNullException("buffer");
+ throw new ArgumentNullException(nameof(buffer));
if (offset + count < 0)
- throw new ArgumentOutOfRangeException("offset + count must not be negative", "offset+count");
+ throw new ArgumentOutOfRangeException(nameof(offset), "offset + count must not be negative");
if (offset + count > buffer.Length)
- throw new ArgumentException("offset + count must not be greater than the length of buffer", "offset+count");
+ throw new ArgumentException("offset + count must not be greater than the length of buffer");
if (disposed)
- throw new ObjectDisposedException(typeof(UdpClientStream).ToString());
+ throw new ObjectDisposedException(nameof(UdpClientStream));
// This will always receive a 1328 packet size (PacketSize + RtpHeaderSize)
// The RTP header will be stripped so see how many reads we need to make to fill the buffer.
@@ -238,16 +237,16 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
public override int Read(byte[] buffer, int offset, int count)
{
if (buffer == null)
- throw new ArgumentNullException("buffer");
+ throw new ArgumentNullException(nameof(buffer));
if (offset + count < 0)
throw new ArgumentOutOfRangeException("offset + count must not be negative", "offset+count");
if (offset + count > buffer.Length)
- throw new ArgumentException("offset + count must not be greater than the length of buffer", "offset+count");
+ throw new ArgumentException("offset + count must not be greater than the length of buffer");
if (disposed)
- throw new ObjectDisposedException(typeof(UdpClientStream).ToString());
+ throw new ObjectDisposedException(nameof(UdpClientStream));
// This will always receive a 1328 packet size (PacketSize + RtpHeaderSize)
// The RTP header will be stripped so see how many reads we need to make to fill the buffer.
@@ -274,49 +273,19 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
disposed = true;
}
- public override bool CanRead
- {
- get
- {
- throw new NotImplementedException();
- }
- }
+ public override bool CanRead => throw new NotImplementedException();
- public override bool CanSeek
- {
- get
- {
- throw new NotImplementedException();
- }
- }
+ public override bool CanSeek => throw new NotImplementedException();
- public override bool CanWrite
- {
- get
- {
- throw new NotImplementedException();
- }
- }
+ public override bool CanWrite => throw new NotImplementedException();
- public override long Length
- {
- get
- {
- throw new NotImplementedException();
- }
- }
+ public override long Length => throw new NotImplementedException();
public override long Position
{
- get
- {
- throw new NotImplementedException();
- }
+ get => throw new NotImplementedException();
- set
- {
- throw new NotImplementedException();
- }
+ set => throw new NotImplementedException();
}
public override void Flush()
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs
index 4a2b4ebb2..1f8ca276e 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs
@@ -1,18 +1,15 @@
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller;
-using MediaBrowser.Controller.IO;
-using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.IO;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.System;
using MediaBrowser.Model.LiveTv;
-using System.Linq;
-using MediaBrowser.Controller.Library;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
@@ -217,13 +214,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
}
}
- protected virtual int EmptyReadLimit
- {
- get
- {
- return 1000;
- }
- }
+ protected virtual int EmptyReadLimit => 1000;
private void TrySeek(FileStream stream, long offset)
{
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs
index a54bd1613..638796e2e 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs
@@ -1,24 +1,24 @@
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.LiveTv;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.MediaInfo;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using MediaBrowser.Model.IO;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.MediaEncoding;
+using MediaBrowser.Model.Dto;
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.LiveTv;
+using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.System;
-using System.IO;
-using MediaBrowser.Controller.Library;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
@@ -39,15 +39,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
_mediaSourceManager = mediaSourceManager;
}
- public override string Type
- {
- get { return "m3u"; }
- }
+ public override string Type => "m3u";
- public virtual string Name
- {
- get { return "M3U Tuner"; }
- }
+ public virtual string Name => "M3U Tuner";
private string GetFullChannelIdPrefix(TunerHostInfo info)
{
@@ -141,9 +135,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var protocol = _mediaSourceManager.GetPathProtocol(path);
- Uri uri;
var isRemote = true;
- if (Uri.TryCreate(path, UriKind.Absolute, out uri))
+ if (Uri.TryCreate(path, UriKind.Absolute, out var uri))
{
isRemote = !_networkManager.IsInLocalNetwork(uri.Host);
}
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
index 208225c1e..a54a53b25 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -6,14 +6,13 @@ using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
-using MediaBrowser.Model.IO;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
-using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.LiveTv;
-using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.IO;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
@@ -59,7 +58,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
Url = url,
CancellationToken = cancellationToken,
// Some data providers will require a user agent
- UserAgent = _appHost.FriendlyName + "/" + _appHost.ApplicationVersion
+ UserAgent = _appHost.ApplicationUserAgent
});
}
return Task.FromResult(_fileSystem.OpenRead(url));
@@ -118,12 +117,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
extInf = extInf.Trim();
- string remaining;
- var attributes = ParseExtInf(extInf, out remaining);
+ var attributes = ParseExtInf(extInf, out string remaining);
extInf = remaining;
- string value;
- if (attributes.TryGetValue("tvg-logo", out value))
+ if (attributes.TryGetValue("tvg-logo", out string value))
{
channel.ImageUrl = value;
}
@@ -131,11 +128,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
channel.Name = GetChannelName(extInf, attributes);
channel.Number = GetChannelNumber(extInf, attributes, mediaUrl);
- string tvgId;
- attributes.TryGetValue("tvg-id", out tvgId);
+ attributes.TryGetValue("tvg-id", out string tvgId);
- string channelId;
- attributes.TryGetValue("channel-id", out channelId);
+ attributes.TryGetValue("channel-id", out string channelId);
channel.TunerChannelId = string.IsNullOrWhiteSpace(tvgId) ? channelId : tvgId;
@@ -173,8 +168,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
- double number;
- if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out number))
+ if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out var number))
{
numberString = numberPart;
}
@@ -188,11 +182,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
if (!IsValidChannelNumber(numberString))
{
- string value;
- if (attributes.TryGetValue("tvg-id", out value))
+ if (attributes.TryGetValue("tvg-id", out string value))
{
- double doubleValue;
- if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue))
+ if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var doubleValue))
{
numberString = value;
}
@@ -206,8 +198,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
if (!IsValidChannelNumber(numberString))
{
- string value;
- if (attributes.TryGetValue("channel-id", out value))
+ if (attributes.TryGetValue("channel-id", out string value))
{
numberString = value;
}
@@ -251,7 +242,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
return numberString;
}
- private bool IsValidChannelNumber(string numberString)
+ private static bool IsValidChannelNumber(string numberString)
{
if (string.IsNullOrWhiteSpace(numberString) ||
string.Equals(numberString, "-1", StringComparison.OrdinalIgnoreCase) ||
@@ -260,8 +251,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
return false;
}
- double value;
- if (!double.TryParse(numberString, NumberStyles.Any, CultureInfo.InvariantCulture, out value))
+ if (!double.TryParse(numberString, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
{
return false;
}
@@ -269,7 +259,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
return true;
}
- private string GetChannelName(string extInf, Dictionary<string, string> attributes)
+ private static string GetChannelName(string extInf, Dictionary<string, string> attributes)
{
var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null;
@@ -284,8 +274,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
- double number;
- if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out number))
+ if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out var number))
{
//channel.Number = number.ToString();
nameInExtInf = nameInExtInf.Substring(numberIndex + 1).Trim(new[] { ' ', '-' });
@@ -293,8 +282,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
}
}
- string name;
- attributes.TryGetValue("tvg-name", out name);
+ attributes.TryGetValue("tvg-name", out string name);
if (string.IsNullOrWhiteSpace(name))
{
@@ -314,7 +302,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
return name;
}
- private Dictionary<string, string> ParseExtInf(string line, out string remaining)
+ private static Dictionary<string, string> ParseExtInf(string line, out string remaining)
{
var dict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs
index 9b10daba0..b39a9f679 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs
@@ -1,21 +1,15 @@
-using System;
-using System.IO;
+using System;
+using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
-using Emby.Server.Implementations.IO;
-using MediaBrowser.Model.IO;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
-using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Model.MediaInfo;
-using MediaBrowser.Model.System;
-using System.Globalization;
-using MediaBrowser.Controller.IO;
+using MediaBrowser.Model.IO;
using MediaBrowser.Model.LiveTv;
-using System.Collections.Generic;
+using MediaBrowser.Model.MediaInfo;
+using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.LiveTv.TunerHosts
{