aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/LiveTv
diff options
context:
space:
mode:
authorDominik <git@secnd.me>2023-06-15 19:38:42 +0200
committerGitHub <noreply@github.com>2023-06-15 19:38:42 +0200
commit17f1e8d19b1fd693893d66d2275ed8ae2476344e (patch)
tree7f48be975faa92042769870957587b3c7864f631 /Emby.Server.Implementations/LiveTv
parente8ae7e5c38e28f13fa8de295e26c930cb46d9b79 (diff)
parent6771b5cabe96b4b3cbd1cd0c998d564f3dd17ed4 (diff)
Merge branch 'master' into segment-deletion
Diffstat (limited to 'Emby.Server.Implementations/LiveTv')
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs176
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs4
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs5
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs30
-rw-r--r--Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs117
-rw-r--r--Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs25
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs46
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvManager.cs81
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs4
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs19
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs12
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs4
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/LegacyHdHomerunChannelCommands.cs3
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs47
18 files changed, 258 insertions, 323 deletions
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
index b2d25fdaeb..49833de737 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
@@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public Task Record(IDirectStreamProvider? directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
{
- if (directStreamProvider != null)
+ if (directStreamProvider is not null)
{
return RecordFromDirectStreamProvider(directStreamProvider, targetFile, duration, onStarted, cancellationToken);
}
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index 74321a256e..b9d0f170ac 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -295,7 +295,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
var program = GetProgramInfoFromCache(timer);
- if (program == null)
+ if (program is null)
{
OnTimerOutOfDate(timer);
continue;
@@ -367,7 +367,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var epgChannel = GetEpgChannelFromTunerChannel(info, tunerChannel, epgChannels);
- if (epgChannel != null)
+ if (epgChannel is not null)
{
if (!string.IsNullOrWhiteSpace(epgChannel.Name))
{
@@ -450,7 +450,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var channel = epgChannelData.GetChannelById(mappedTunerChannelId);
- if (channel != null)
+ if (channel is not null)
{
return channel;
}
@@ -473,7 +473,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var channel = epgChannelData.GetChannelById(mappedTunerChannelId);
- if (channel != null)
+ if (channel is not null)
{
return channel;
}
@@ -490,7 +490,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var channel = epgChannelData.GetChannelByNumber(tunerChannelNumber);
- if (channel != null)
+ if (channel is not null)
{
return channel;
}
@@ -502,7 +502,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var channel = epgChannelData.GetChannelByName(normalizedName);
- if (channel != null)
+ if (channel is not null)
{
return channel;
}
@@ -552,7 +552,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
var remove = _seriesTimerProvider.GetAll().FirstOrDefault(r => string.Equals(r.Id, timerId, StringComparison.OrdinalIgnoreCase));
- if (remove != null)
+ if (remove is not null)
{
_seriesTimerProvider.Delete(remove);
}
@@ -563,7 +563,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private void CancelTimerInternal(string timerId, bool isSeriesCancelled, bool isManualCancellation)
{
var timer = _timerProvider.GetTimer(timerId);
- if (timer != null)
+ if (timer is not null)
{
var statusChanging = timer.Status != RecordingStatus.Cancelled;
timer.Status = RecordingStatus.Cancelled;
@@ -582,7 +582,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_timerProvider.AddOrUpdate(timer, false);
}
- if (statusChanging && TimerCancelled != null)
+ if (statusChanging && TimerCancelled is not null)
{
TimerCancelled(this, new GenericEventArgs<string>(timerId));
}
@@ -617,7 +617,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
null :
_timerProvider.GetTimerByProgramId(info.ProgramId);
- if (existingTimer != null)
+ if (existingTimer is not null)
{
if (existingTimer.Status == RecordingStatus.Cancelled
|| existingTimer.Status == RecordingStatus.Completed)
@@ -627,10 +627,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_timerProvider.Update(existingTimer);
return Task.FromResult(existingTimer.Id);
}
- else
- {
- throw new ArgumentException("A scheduled recording already exists for this program.");
- }
+
+ throw new ArgumentException("A scheduled recording already exists for this program.");
}
info.Id = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
@@ -642,13 +640,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
programInfo = GetProgramInfoFromCache(info);
}
- if (programInfo == null)
+ if (programInfo is null)
{
_logger.LogInformation("Unable to find program with Id {0}. Will search using start date", info.ProgramId);
programInfo = GetProgramInfoFromCache(info.ChannelId, info.StartDate);
}
- if (programInfo != null)
+ if (programInfo is not null)
{
CopyProgramInfoToTimerInfo(programInfo, info);
}
@@ -668,7 +666,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
// populate info.seriesID
var program = GetProgramInfoFromCache(info.ProgramId);
- if (program != null)
+ if (program is not null)
{
info.SeriesId = program.ExternalSeriesId;
}
@@ -714,7 +712,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var instance = _seriesTimerProvider.GetAll().FirstOrDefault(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase));
- if (instance != null)
+ if (instance is not null)
{
instance.ChannelId = info.ChannelId;
instance.Days = info.Days;
@@ -744,7 +742,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var existingTimer = _timerProvider.GetTimer(updatedTimer.Id);
- if (existingTimer == null)
+ if (existingTimer is null)
{
throw new ResourceNotFoundException();
}
@@ -861,7 +859,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
};
- if (program != null)
+ if (program is not null)
{
defaults.SeriesId = program.SeriesId;
defaults.ProgramId = program.Id;
@@ -912,7 +910,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var epgChannel = await GetEpgChannelFromTunerChannel(provider.Item1, provider.Item2, channel, cancellationToken).ConfigureAwait(false);
- if (epgChannel == null)
+ if (epgChannel is null)
{
_logger.LogDebug("EPG channel not found for tuner channel {0}-{1} from {2}-{3}", channel.Number, channel.Name, provider.Item1.Name, provider.Item2.ListingsId ?? string.Empty);
continue;
@@ -945,9 +943,9 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var provider = _liveTvManager.ListingProviders.FirstOrDefault(l => string.Equals(l.Type, i.Type, StringComparison.OrdinalIgnoreCase));
- return provider == null ? null : new Tuple<IListingsProvider, ListingsProviderInfo>(provider, i);
+ return provider is null ? null : new Tuple<IListingsProvider, ListingsProviderInfo>(provider, i);
})
- .Where(i => i != null)
+ .Where(i => i is not null)
.ToList();
}
@@ -964,7 +962,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
null :
currentLiveStreams.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase));
- if (result != null && result.EnableStreamSharing)
+ if (result is not null && result.EnableStreamSharing)
{
result.ConsumerCount++;
@@ -1134,7 +1132,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
// trim trailing period from the folder name
var folderName = _fileSystem.GetValidFilename(timer.Name).Trim().TrimEnd('.').Trim();
- if (metadata != null && metadata.ProductionYear.HasValue)
+ if (metadata is not null && metadata.ProductionYear.HasValue)
{
folderName += " (" + metadata.ProductionYear.Value.ToString(CultureInfo.InvariantCulture) + ")";
}
@@ -1232,13 +1230,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
programInfo = GetProgramInfoFromCache(timer);
}
- if (programInfo == null)
+ if (programInfo is null)
{
_logger.LogInformation("Unable to find program with Id {0}. Will search using start date", timer.ProgramId);
programInfo = GetProgramInfoFromCache(timer.ChannelId, timer.StartDate);
}
- if (programInfo != null)
+ if (programInfo is not null)
{
CopyProgramInfoToTimerInfo(programInfo, timer);
}
@@ -1412,7 +1410,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var item = GetAffectedBaseItem(Path.GetDirectoryName(path));
- if (item != null)
+ if (item is not null)
{
_logger.LogInformation("Refreshing recording parent {Path}", item.Path);
@@ -1437,19 +1435,19 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var parentPath = Path.GetDirectoryName(path);
- while (item == null && !string.IsNullOrEmpty(path))
+ while (item is null && !string.IsNullOrEmpty(path))
{
item = _libraryManager.FindByPath(path, null);
path = Path.GetDirectoryName(path);
}
- if (item != null)
+ if (item is not null)
{
if (item.GetType() == typeof(Folder) && string.Equals(item.Path, parentPath, StringComparison.OrdinalIgnoreCase))
{
var parentItem = item.GetParent();
- if (parentItem != null && parentItem is not AggregateFolder)
+ if (parentItem is not null && parentItem is not AggregateFolder)
{
item = parentItem;
}
@@ -1474,7 +1472,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var seriesTimerId = timer.SeriesTimerId;
var seriesTimer = _seriesTimerProvider.GetAll().FirstOrDefault(i => string.Equals(i.Id, seriesTimerId, StringComparison.OrdinalIgnoreCase));
- if (seriesTimer == null || seriesTimer.KeepUpTo <= 0)
+ if (seriesTimer is null || seriesTimer.KeepUpTo <= 0)
{
return;
}
@@ -1569,7 +1567,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var libraryItem = _libraryManager.FindByPath(timer.RecordingPath, false);
- if (libraryItem != null)
+ if (libraryItem is not null)
{
_libraryManager.DeleteItem(
libraryItem,
@@ -1695,7 +1693,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_ => null
};
- if (imageSaveFilenameWithoutExtension == null)
+ if (imageSaveFilenameWithoutExtension is null)
{
return;
}
@@ -1714,7 +1712,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
(program.GetImageInfo(ImageType.Thumb, 0) ?? program.GetImageInfo(ImageType.Primary, 0)) :
(program.GetImageInfo(ImageType.Primary, 0) ?? program.GetImageInfo(ImageType.Thumb, 0));
- if (image != null)
+ if (image is not null)
{
try
{
@@ -1729,7 +1727,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (!program.IsSeries)
{
image = program.GetImageInfo(ImageType.Backdrop, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -1742,7 +1740,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
image = program.GetImageInfo(ImageType.Thumb, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -1755,7 +1753,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
image = program.GetImageInfo(ImageType.Logo, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -1782,7 +1780,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}).FirstOrDefault() as LiveTvProgram;
// dummy this up
- if (program == null)
+ if (program is null)
{
program = new LiveTvProgram
{
@@ -1814,21 +1812,29 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
program.AddGenre("News");
}
- if (timer.IsProgramSeries)
- {
- await SaveSeriesNfoAsync(timer, seriesPath).ConfigureAwait(false);
- await SaveVideoNfoAsync(timer, recordingPath, program, false).ConfigureAwait(false);
- }
- else if (!timer.IsMovie || timer.IsSports || timer.IsNews)
+ var config = GetConfiguration();
+
+ if (config.SaveRecordingNFO)
{
- await SaveVideoNfoAsync(timer, recordingPath, program, true).ConfigureAwait(false);
+ if (timer.IsProgramSeries)
+ {
+ await SaveSeriesNfoAsync(timer, seriesPath).ConfigureAwait(false);
+ await SaveVideoNfoAsync(timer, recordingPath, program, false).ConfigureAwait(false);
+ }
+ else if (!timer.IsMovie || timer.IsSports || timer.IsNews)
+ {
+ await SaveVideoNfoAsync(timer, recordingPath, program, true).ConfigureAwait(false);
+ }
+ else
+ {
+ await SaveVideoNfoAsync(timer, recordingPath, program, false).ConfigureAwait(false);
+ }
}
- else
+
+ if (config.SaveRecordingImages)
{
- await SaveVideoNfoAsync(timer, recordingPath, program, false).ConfigureAwait(false);
+ await SaveRecordingImages(recordingPath, program).ConfigureAwait(false);
}
-
- await SaveRecordingImages(recordingPath, program).ConfigureAwait(false);
}
catch (Exception ex)
{
@@ -1858,8 +1864,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
await writer.WriteStartDocumentAsync(true).ConfigureAwait(false);
await writer.WriteStartElementAsync(null, "tvshow", null).ConfigureAwait(false);
- string id;
- if (timer.SeriesProviderIds.TryGetValue(MetadataProvider.Tvdb.ToString(), out id))
+ if (timer.SeriesProviderIds.TryGetValue(MetadataProvider.Tvdb.ToString(), out var id))
{
await writer.WriteElementStringAsync(null, "id", null, id).ConfigureAwait(false);
}
@@ -2024,7 +2029,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var people = item.Id.Equals(default) ? new List<PersonInfo>() : _libraryManager.GetPeople(item);
var directors = people
- .Where(i => IsPersonType(i, PersonType.Director))
+ .Where(i => i.IsType(PersonKind.Director))
.Select(i => i.Name)
.ToList();
@@ -2034,7 +2039,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
var writers = people
- .Where(i => IsPersonType(i, PersonType.Writer))
+ .Where(i => i.IsType(PersonKind.Writer))
.Select(i => i.Name)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
@@ -2114,10 +2119,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
}
- private static bool IsPersonType(PersonInfo person, string type)
- => string.Equals(person.Type, type, StringComparison.OrdinalIgnoreCase)
- || string.Equals(person.Role, type, StringComparison.OrdinalIgnoreCase);
-
private LiveTvProgram GetProgramInfoFromCache(string programId)
{
var query = new InternalItemsQuery
@@ -2192,16 +2193,15 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private void HandleDuplicateShowIds(List<TimerInfo> timers)
{
- foreach (var timer in timers.Skip(1))
+ // 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))
{
- // TODO: Get smarter, prefer HD, etc
-
timer.Status = RecordingStatus.Cancelled;
_timerProvider.Update(timer);
}
}
- private void SearchForDuplicateShowIds(List<TimerInfo> timers)
+ private void SearchForDuplicateShowIds(IEnumerable<TimerInfo> timers)
{
var groups = timers.ToLookup(i => i.ShowId ?? string.Empty).ToList();
@@ -2241,7 +2241,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
? null
: _timerProvider.GetTimerByProgramId(timer.ProgramId));
- if (existingTimer == null)
+ if (existingTimer is null)
{
if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer))
{
@@ -2282,39 +2282,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
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
- 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))
- {
- existingTimer.Status = RecordingStatus.Cancelled;
- }
- else if (!existingTimer.IsManual)
- {
- existingTimer.Status = RecordingStatus.New;
- }
-
- if (existingTimer.Status != RecordingStatus.Cancelled)
- {
- enabledTimersForSeries.Add(existingTimer);
- }
-
- existingTimer.KeepUntil = seriesTimer.KeepUntil;
- existingTimer.IsPostPaddingRequired = seriesTimer.IsPostPaddingRequired;
- existingTimer.IsPrePaddingRequired = seriesTimer.IsPrePaddingRequired;
- existingTimer.PostPaddingSeconds = seriesTimer.PostPaddingSeconds;
- existingTimer.PrePaddingSeconds = seriesTimer.PrePaddingSeconds;
- existingTimer.Priority = seriesTimer.Priority;
- existingTimer.SeriesTimerId = seriesTimer.Id;
-
- _timerProvider.Update(existingTimer);
- }
+ existingTimer.KeepUntil = seriesTimer.KeepUntil;
+ existingTimer.IsPostPaddingRequired = seriesTimer.IsPostPaddingRequired;
+ existingTimer.IsPrePaddingRequired = seriesTimer.IsPrePaddingRequired;
+ existingTimer.PostPaddingSeconds = seriesTimer.PostPaddingSeconds;
+ existingTimer.PrePaddingSeconds = seriesTimer.PrePaddingSeconds;
+ existingTimer.Priority = seriesTimer.Priority;
+ existingTimer.SeriesTimerId = seriesTimer.Id;
}
existingTimer.SeriesTimerId = seriesTimer.Id;
@@ -2394,13 +2368,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
DtoOptions = new DtoOptions()
}).FirstOrDefault() as LiveTvChannel;
- if (channel != null && !string.IsNullOrWhiteSpace(channel.ExternalId))
+ if (channel is not null && !string.IsNullOrWhiteSpace(channel.ExternalId))
{
tempChannelCache[parent.ChannelId] = channel;
}
}
- if (channel != null || tempChannelCache.TryGetValue(parent.ChannelId, out channel))
+ if (channel is not null || tempChannelCache.TryGetValue(parent.ChannelId, out channel))
{
channelId = channel.ExternalId;
}
@@ -2453,13 +2427,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
DtoOptions = new DtoOptions()
}).FirstOrDefault() as LiveTvChannel;
- if (channel != null && !string.IsNullOrWhiteSpace(channel.ExternalId))
+ if (channel is not null && !string.IsNullOrWhiteSpace(channel.ExternalId))
{
tempChannelCache[programInfo.ChannelId] = channel;
}
}
- if (channel != null || tempChannelCache.TryGetValue(programInfo.ChannelId, out channel))
+ if (channel is not null || tempChannelCache.TryGetValue(programInfo.ChannelId, out channel))
{
channelId = channel.ExternalId;
}
@@ -2653,7 +2627,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var configuredDevice = configuredDevices.FirstOrDefault(i => string.Equals(i.DeviceId, device.DeviceId, StringComparison.OrdinalIgnoreCase));
- if (configuredDevice != null && !string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase))
+ if (configuredDevice is not null && !string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase))
{
_logger.LogInformation("Tuner url has changed from {PreviousUrl} to {NewUrl}", configuredDevice.Url, device.Url);
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
index 08534de59d..5369c9b3d1 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
@@ -208,7 +208,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
// var audioChannels = 2;
// var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
- // if (audioStream != null)
+ // if (audioStream is not null)
// {
// audioChannels = audioStream.Channels ?? audioChannels;
// }
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
index 58b798ce67..d5a6feb470 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
@@ -36,7 +36,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
[MemberNotNull(nameof(_items))]
private void EnsureLoaded()
{
- if (_items != null)
+ if (_items is not null)
{
return;
}
@@ -49,7 +49,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
var bytes = File.ReadAllBytes(_dataPath);
_items = JsonSerializer.Deserialize<T[]>(bytes, _jsonOptions);
- if (_items == null)
+ if (_items is null)
{
Logger.LogError("Error deserializing {Path}, data was null", _dataPath);
_items = Array.Empty<T>();
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
index 40dcca94f6..7bbeae866a 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
@@ -63,7 +63,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
}
}
- else if (info.IsMovie && info.ProductionYear != null)
+ else if (info.IsMovie && info.ProductionYear is not null)
{
name += " (" + info.ProductionYear + ")";
}
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs
index b1259de232..bf28f3b67d 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/SeriesTimerManager.cs
@@ -16,10 +16,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
/// <inheritdoc />
public override void Add(SeriesTimerInfo item)
{
- if (string.IsNullOrEmpty(item.Id))
- {
- throw new ArgumentException("SeriesTimerInfo.Id cannot be null or empty.");
- }
+ ArgumentException.ThrowIfNullOrEmpty(item.Id);
base.Add(item);
}
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
index a861e6ae44..9f8441fa48 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs
@@ -74,10 +74,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public override void Add(TimerInfo item)
{
- if (string.IsNullOrEmpty(item.Id))
- {
- throw new ArgumentException("TimerInfo.Id cannot be null or empty.");
- }
+ ArgumentException.ThrowIfNullOrEmpty(item.Id);
base.Add(item);
AddOrUpdateSystemTimer(item);
@@ -122,11 +119,28 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (_timers.TryAdd(item.Id, timer))
{
- Logger.LogInformation(
- "Creating recording timer for {Id}, {Name}. Timer will fire in {Minutes} minutes",
+ if (item.IsSeries)
+ {
+ Logger.LogInformation(
+ "Creating recording timer for {Id}, {Name} {SeasonNumber}x{EpisodeNumber:D2} on channel {ChannelId}. Timer will fire in {Minutes} minutes at {StartDate}",
+ item.Id,
+ item.Name,
+ item.SeasonNumber,
+ item.EpisodeNumber,
+ item.ChannelId,
+ dueTime.TotalMinutes.ToString(CultureInfo.InvariantCulture),
+ item.StartDate);
+ }
+ else
+ {
+ Logger.LogInformation(
+ "Creating recording timer for {Id}, {Name} on channel {ChannelId}. Timer will fire in {Minutes} minutes at {StartDate}",
item.Id,
item.Name,
- dueTime.TotalMinutes.ToString(CultureInfo.InvariantCulture));
+ item.ChannelId,
+ dueTime.TotalMinutes.ToString(CultureInfo.InvariantCulture),
+ item.StartDate);
+ }
}
else
{
@@ -148,7 +162,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var timerId = (string?)state ?? throw new ArgumentNullException(nameof(state));
var timer = GetAll().FirstOrDefault(i => string.Equals(i.Id, timerId, StringComparison.OrdinalIgnoreCase));
- if (timer != null)
+ if (timer is not null)
{
TimerFired?.Invoke(this, new GenericEventArgs<TimerInfo>(timer));
}
diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
index b981ad81a7..7645c6c52d 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
@@ -74,10 +74,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(channelId))
- {
- throw new ArgumentNullException(nameof(channelId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(channelId);
// Normalize incoming input
channelId = channelId.Replace(".json.schedulesdirect.org", string.Empty, StringComparison.OrdinalIgnoreCase).TrimStart('I');
@@ -111,7 +108,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
using var response = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
var dailySchedules = await JsonSerializer.DeserializeAsync<IReadOnlyList<DayDto>>(responseStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (dailySchedules == null)
+ if (dailySchedules is null)
{
return Array.Empty<ProgramInfo>();
}
@@ -127,7 +124,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
using var innerResponse = await Send(programRequestOptions, true, info, cancellationToken).ConfigureAwait(false);
await using var innerResponseStream = await innerResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
var programDetails = await JsonSerializer.DeserializeAsync<IReadOnlyList<ProgramDetailsDto>>(innerResponseStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (programDetails == null)
+ if (programDetails is null)
{
return Array.Empty<ProgramInfo>();
}
@@ -153,7 +150,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
continue;
}
- if (images != null)
+ if (images is not null)
{
var imageIndex = images.FindIndex(i => i.ProgramId == schedule.ProgramId[..10]);
if (imageIndex > -1)
@@ -228,7 +225,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private ProgramInfo GetProgram(string channelId, ProgramDto programInfo, ProgramDetailsDto details)
{
- if (programInfo.AirDateTime == null)
+ if (programInfo.AirDateTime is null)
{
return null;
}
@@ -266,7 +263,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
string episodeTitle = null;
- if (details.EpisodeTitle150 != null)
+ if (details.EpisodeTitle150 is not null)
{
episodeTitle = details.EpisodeTitle150;
}
@@ -283,7 +280,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
EpisodeTitle = episodeTitle,
Audio = audioType,
// IsNew = programInfo.@new ?? false,
- IsRepeat = programInfo.New == null,
+ IsRepeat = programInfo.New is null,
IsSeries = string.Equals(details.EntityType, "episode", StringComparison.OrdinalIgnoreCase),
ImageUrl = details.PrimaryImage,
ThumbImageUrl = details.ThumbImage,
@@ -315,13 +312,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
info.ShowId = showId;
- if (programInfo.VideoProperties != null)
+ if (programInfo.VideoProperties is not null)
{
info.IsHD = programInfo.VideoProperties.Contains("hdtv", StringComparison.OrdinalIgnoreCase);
info.Is3D = programInfo.VideoProperties.Contains("3d", StringComparison.OrdinalIgnoreCase);
}
- if (details.ContentRating != null && details.ContentRating.Count > 0)
+ if (details.ContentRating is not null && details.ContentRating.Count > 0)
{
info.OfficialRating = details.ContentRating[0].Code.Replace("TV", "TV-", StringComparison.Ordinal)
.Replace("--", "-", StringComparison.Ordinal);
@@ -333,13 +330,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- if (details.Descriptions != null)
+ if (details.Descriptions is not null)
{
- if (details.Descriptions.Description1000 != null && details.Descriptions.Description1000.Count > 0)
+ if (details.Descriptions.Description1000 is not null && details.Descriptions.Description1000.Count > 0)
{
info.Overview = details.Descriptions.Description1000[0].Description;
}
- else if (details.Descriptions.Description100 != null && details.Descriptions.Description100.Count > 0)
+ else if (details.Descriptions.Description100 is not null && details.Descriptions.Description100.Count > 0)
{
info.Overview = details.Descriptions.Description100[0].Description;
}
@@ -351,12 +348,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings
info.SeriesProviderIds[MetadataProvider.Zap2It.ToString()] = info.SeriesId;
- if (details.Metadata != null)
+ if (details.Metadata is not null)
{
foreach (var metadataProgram in details.Metadata)
{
var gracenote = metadataProgram.Gracenote;
- if (gracenote != null)
+ if (gracenote is not null)
{
info.SeasonNumber = gracenote.Season;
@@ -371,13 +368,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- if (details.OriginalAirDate != null)
+ if (details.OriginalAirDate is not null)
{
info.OriginalAirDate = details.OriginalAirDate;
info.ProductionYear = info.OriginalAirDate.Value.Year;
}
- if (details.Movie != null)
+ if (details.Movie is not null)
{
if (!string.IsNullOrEmpty(details.Movie.Year)
&& int.TryParse(details.Movie.Year, out int year))
@@ -386,7 +383,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
- if (details.Genres != null)
+ if (details.Genres is not null)
{
info.Genres = details.Genres.Where(g => !string.IsNullOrWhiteSpace(g)).ToList();
info.IsNews = details.Genres.Contains("news", StringComparison.OrdinalIgnoreCase);
@@ -407,7 +404,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
.ThenByDescending(i => GetSizeOrder(i))
.FirstOrDefault();
- if (match == null)
+ if (match is null)
{
return null;
}
@@ -418,14 +415,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
return null;
}
- else if (uri.IndexOf("http", StringComparison.OrdinalIgnoreCase) != -1)
+
+ if (uri.IndexOf("http", StringComparison.OrdinalIgnoreCase) != -1)
{
return uri;
}
- else
- {
- return apiUrl + "/image/" + uri + "?token=" + token;
- }
+
+ return apiUrl + "/image/" + uri + "?token=" + token;
}
private static double GetAspectRatio(ImageDataDto i)
@@ -466,10 +462,10 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
StringBuilder str = new StringBuilder("[", 1 + (programIds.Count * 13));
- foreach (ReadOnlySpan<char> i in programIds)
+ foreach (var i in programIds)
{
str.Append('"')
- .Append(i.Slice(0, 10))
+ .Append(i[..10])
.Append("\",");
}
@@ -518,7 +514,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
var root = await JsonSerializer.DeserializeAsync<IReadOnlyList<HeadendsDto>>(response, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (root != null)
+ if (root is not null)
{
foreach (HeadendsDto headend in root)
{
@@ -573,15 +569,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
_tokens.TryAdd(username, savedToken);
}
- if (!string.IsNullOrEmpty(savedToken.Name) && !string.IsNullOrEmpty(savedToken.Value))
+ if (!string.IsNullOrEmpty(savedToken.Name)
+ && long.TryParse(savedToken.Value, CultureInfo.InvariantCulture, out long ticks))
{
- if (long.TryParse(savedToken.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out long ticks))
+ // If it's under 24 hours old we can still use it
+ if (DateTime.UtcNow.Ticks - ticks < TimeSpan.FromHours(20).Ticks)
{
- // If it's under 24 hours old we can still use it
- if (DateTime.UtcNow.Ticks - ticks < TimeSpan.FromHours(20).Ticks)
- {
- return savedToken.Name;
- }
+ return savedToken.Name;
}
}
@@ -670,15 +664,8 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
- if (string.IsNullOrEmpty(token))
- {
- throw new ArgumentException("Authentication required.");
- }
-
- if (string.IsNullOrEmpty(info.ListingsId))
- {
- throw new ArgumentException("Listings Id required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(token);
+ ArgumentException.ThrowIfNullOrEmpty(info.ListingsId);
_logger.LogInformation("Adding new LineUp ");
@@ -689,17 +676,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private async Task<bool> HasLineup(ListingsProviderInfo info, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(info.ListingsId))
- {
- throw new ArgumentException("Listings Id required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(info.ListingsId);
var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
- if (string.IsNullOrEmpty(token))
- {
- throw new ArgumentException("token required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(token);
_logger.LogInformation("Headends on account ");
@@ -732,23 +713,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
if (validateLogin)
{
- if (string.IsNullOrEmpty(info.Username))
- {
- throw new ArgumentException("Username is required");
- }
-
- if (string.IsNullOrEmpty(info.Password))
- {
- throw new ArgumentException("Password is required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(info.Username);
+ ArgumentException.ThrowIfNullOrEmpty(info.Password);
}
if (validateListings)
{
- if (string.IsNullOrEmpty(info.ListingsId))
- {
- throw new ArgumentException("Listings Id required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(info.ListingsId);
var hasLineup = await HasLineup(info, CancellationToken.None).ConfigureAwait(false);
@@ -767,17 +738,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings
public async Task<List<ChannelInfo>> GetChannels(ListingsProviderInfo info, CancellationToken cancellationToken)
{
var listingsId = info.ListingsId;
- if (string.IsNullOrEmpty(listingsId))
- {
- throw new ArgumentException("ListingsId required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(listingsId);
var token = await GetToken(info, cancellationToken).ConfigureAwait(false);
- if (string.IsNullOrEmpty(token))
- {
- throw new ArgumentException("token required");
- }
+ ArgumentException.ThrowIfNullOrEmpty(token);
using var options = new HttpRequestMessage(HttpMethod.Get, ApiUrl + "/lineups/" + listingsId);
options.Headers.TryAddWithoutValidation("token", token);
@@ -785,7 +750,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
using var httpResponse = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
await using var stream = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
var root = await JsonSerializer.DeserializeAsync<ChannelDto>(stream, _jsonOptions, cancellationToken).ConfigureAwait(false);
- if (root == null)
+ if (root is null)
{
return new List<ChannelInfo>();
}
@@ -814,7 +779,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
Name = string.IsNullOrWhiteSpace(station.Name) ? channelNumber : station.Name
};
- if (station.Logo != null)
+ if (station.Logo is not null)
{
channelInfo.ImageUrl = station.Logo.Url;
}
diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
index 82f0baf32e..066afb956b 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
@@ -137,32 +137,33 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private static ProgramInfo GetProgramInfo(XmlTvProgram program, ListingsProviderInfo info)
{
- string episodeTitle = program.Episode?.Title;
+ string episodeTitle = program.Episode.Title;
+ var programCategories = program.Categories.Where(c => !string.IsNullOrWhiteSpace(c)).ToList();
var programInfo = new ProgramInfo
{
ChannelId = program.ChannelId,
EndDate = program.EndDate.UtcDateTime,
- EpisodeNumber = program.Episode?.Episode,
+ EpisodeNumber = program.Episode.Episode,
EpisodeTitle = episodeTitle,
- Genres = program.Categories,
+ Genres = programCategories,
StartDate = program.StartDate.UtcDateTime,
Name = program.Title,
Overview = program.Description,
ProductionYear = program.CopyrightDate?.Year,
- SeasonNumber = program.Episode?.Series,
- IsSeries = program.Episode != null,
+ SeasonNumber = program.Episode.Series,
+ IsSeries = program.Episode.Series is not null,
IsRepeat = program.IsPreviouslyShown && !program.IsNew,
- IsPremiere = program.Premiere != null,
- IsKids = program.Categories.Any(c => info.KidsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
- IsMovie = program.Categories.Any(c => info.MovieCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
- IsNews = program.Categories.Any(c => info.NewsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
- IsSports = program.Categories.Any(c => info.SportsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
+ IsPremiere = program.Premiere is not null,
+ IsKids = programCategories.Any(c => info.KidsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
+ IsMovie = programCategories.Any(c => info.MovieCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
+ IsNews = programCategories.Any(c => info.NewsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
+ IsSports = programCategories.Any(c => info.SportsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
ImageUrl = string.IsNullOrEmpty(program.Icon?.Source) ? null : program.Icon.Source,
HasImage = !string.IsNullOrEmpty(program.Icon?.Source),
OfficialRating = string.IsNullOrEmpty(program.Rating?.Value) ? null : program.Rating.Value,
CommunityRating = program.StarRating,
- SeriesId = program.Episode == null ? null : program.Title?.GetMD5().ToString("N", CultureInfo.InvariantCulture)
+ SeriesId = program.Episode.Episode is null ? null : program.Title?.GetMD5().ToString("N", CultureInfo.InvariantCulture)
};
if (string.IsNullOrWhiteSpace(program.ProgramId))
@@ -243,7 +244,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
Id = c.Id,
Name = c.DisplayName,
- ImageUrl = c.Icon != null && !string.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null,
+ ImageUrl = string.IsNullOrEmpty(c.Icon?.Source) ? null : c.Icon.Source,
Number = string.IsNullOrWhiteSpace(c.Number) ? c.Id : c.Number
}).ToList();
}
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
index c09f9cf8d0..9326fbd5c7 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs
@@ -80,7 +80,7 @@ namespace Emby.Server.Implementations.LiveTv
dto.ProgramId = GetInternalProgramId(info.ProgramId).ToString("N", CultureInfo.InvariantCulture);
}
- if (program != null)
+ if (program is not null)
{
dto.ProgramInfo = _dtoService.GetBaseItemDto(program, new DtoOptions());
@@ -98,7 +98,7 @@ namespace Emby.Server.Implementations.LiveTv
}
}
- if (channel != null)
+ if (channel is not null)
{
dto.ChannelName = channel.Name;
@@ -150,7 +150,7 @@ namespace Emby.Server.Implementations.LiveTv
dto.ProgramId = GetInternalProgramId(info.ProgramId).ToString("N", CultureInfo.InvariantCulture);
}
- dto.DayPattern = info.Days == null ? null : GetDayPattern(info.Days.ToArray());
+ dto.DayPattern = info.Days is null ? null : GetDayPattern(info.Days.ToArray());
FillImages(dto, info.Name, info.SeriesId);
@@ -168,10 +168,10 @@ namespace Emby.Server.Implementations.LiveTv
DtoOptions = new DtoOptions(false)
}).FirstOrDefault();
- if (librarySeries != null)
+ if (librarySeries is not null)
{
var image = librarySeries.GetImageInfo(ImageType.Thumb, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.LiveTv
}
image = librarySeries.GetImageInfo(ImageType.Backdrop, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -212,10 +212,10 @@ namespace Emby.Server.Implementations.LiveTv
Name = string.IsNullOrEmpty(programSeriesId) ? seriesName : null
}).FirstOrDefault();
- if (program != null)
+ if (program is not null)
{
var image = program.GetImageInfo(ImageType.Primary, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -228,10 +228,10 @@ namespace Emby.Server.Implementations.LiveTv
}
}
- if (dto.ParentBackdropImageTags == null || dto.ParentBackdropImageTags.Length == 0)
+ if (dto.ParentBackdropImageTags is null || dto.ParentBackdropImageTags.Length == 0)
{
image = program.GetImageInfo(ImageType.Backdrop, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -262,10 +262,10 @@ namespace Emby.Server.Implementations.LiveTv
DtoOptions = new DtoOptions(false)
}).FirstOrDefault();
- if (librarySeries != null)
+ if (librarySeries is not null)
{
var image = librarySeries.GetImageInfo(ImageType.Thumb, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -279,7 +279,7 @@ namespace Emby.Server.Implementations.LiveTv
}
image = librarySeries.GetImageInfo(ImageType.Backdrop, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -305,7 +305,7 @@ namespace Emby.Server.Implementations.LiveTv
DtoOptions = new DtoOptions(false)
}).FirstOrDefault();
- if (program == null)
+ if (program is null)
{
program = _libraryManager.GetItemList(new InternalItemsQuery
{
@@ -318,10 +318,10 @@ namespace Emby.Server.Implementations.LiveTv
}).FirstOrDefault();
}
- if (program != null)
+ if (program is not null)
{
var image = program.GetImageInfo(ImageType.Primary, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -334,10 +334,10 @@ namespace Emby.Server.Implementations.LiveTv
}
}
- if (dto.ParentBackdropImageTags == null || dto.ParentBackdropImageTags.Length == 0)
+ if (dto.ParentBackdropImageTags is null || dto.ParentBackdropImageTags.Length == 0)
{
image = program.GetImageInfo(ImageType.Backdrop, 0);
- if (image != null)
+ if (image is not null)
{
try
{
@@ -460,7 +460,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var channel = _libraryManager.GetItemById(dto.ChannelId);
- if (channel != null)
+ if (channel is not null)
{
info.ChannelId = channel.ExternalId;
}
@@ -470,7 +470,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var program = _libraryManager.GetItemById(dto.ProgramId);
- if (program != null)
+ if (program is not null)
{
info.ProgramId = program.ExternalId;
}
@@ -480,7 +480,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var timer = await liveTv.GetSeriesTimer(dto.SeriesTimerId, cancellationToken).ConfigureAwait(false);
- if (timer != null)
+ if (timer is not null)
{
info.SeriesTimerId = timer.ExternalId;
}
@@ -526,7 +526,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var channel = _libraryManager.GetItemById(dto.ChannelId);
- if (channel != null)
+ if (channel is not null)
{
info.ChannelId = channel.ExternalId;
}
@@ -536,7 +536,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var program = _libraryManager.GetItemById(dto.ProgramId);
- if (program != null)
+ if (program is not null)
{
info.ProgramId = program.ExternalId;
}
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
index 97c2e6e306..ee039ff0f7 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -434,7 +434,7 @@ namespace Emby.Server.Implementations.LiveTv
var item = _libraryManager.GetItemById(id) as LiveTvChannel;
- if (item == null)
+ if (item is null)
{
item = new LiveTvChannel
{
@@ -446,7 +446,7 @@ namespace Emby.Server.Implementations.LiveTv
isNew = true;
}
- if (channelInfo.Tags != null)
+ if (channelInfo.Tags is not null)
{
if (!channelInfo.Tags.SequenceEqual(item.Tags, StringComparer.OrdinalIgnoreCase))
{
@@ -836,7 +836,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var seriesTimers = await GetSeriesTimersInternal(new SeriesTimerQuery(), cancellationToken).ConfigureAwait(false);
var seriesTimer = seriesTimers.Items.FirstOrDefault(i => string.Equals(_tvDtoService.GetInternalSeriesTimerId(i.Id).ToString("N", CultureInfo.InvariantCulture), query.SeriesTimerId, StringComparison.OrdinalIgnoreCase));
- if (seriesTimer != null)
+ if (seriesTimer is not null)
{
internalQuery.ExternalSeriesId = seriesTimer.SeriesId;
@@ -948,7 +948,7 @@ namespace Emby.Server.Implementations.LiveTv
var channel = _libraryManager.GetItemById(program.ChannelId);
- if (channel == null)
+ if (channel is null)
{
return score;
}
@@ -989,7 +989,7 @@ namespace Emby.Server.Implementations.LiveTv
var timer = timerList.FirstOrDefault(i => string.Equals(i.ProgramId, externalProgramId, StringComparison.OrdinalIgnoreCase));
var foundSeriesTimer = false;
- if (timer != null)
+ if (timer is not null)
{
if (timer.Status != RecordingStatus.Cancelled && timer.Status != RecordingStatus.Error)
{
@@ -1016,7 +1016,7 @@ namespace Emby.Server.Implementations.LiveTv
var seriesTimer = seriesTimerList.FirstOrDefault(i => string.Equals(i.SeriesId, externalSeriesId, StringComparison.OrdinalIgnoreCase));
- if (seriesTimer != null)
+ if (seriesTimer is not null)
{
program.SeriesTimerId = _tvDtoService.GetInternalSeriesTimerId(seriesTimer.Id)
.ToString("N", CultureInfo.InvariantCulture);
@@ -1086,7 +1086,7 @@ namespace Emby.Server.Implementations.LiveTv
var coreService = _services.OfType<EmbyTV.EmbyTV>().FirstOrDefault();
- if (coreService != null)
+ if (coreService is not null)
{
await coreService.RefreshSeriesTimers(cancellationToken).ConfigureAwait(false);
await coreService.RefreshTimers(cancellationToken).ConfigureAwait(false);
@@ -1280,7 +1280,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var item = _libraryManager.GetItemById(itemId);
- if (item != null)
+ if (item is not null)
{
_libraryManager.DeleteItem(
item,
@@ -1312,20 +1312,19 @@ namespace Emby.Server.Implementations.LiveTv
return 7;
}
- private QueryResult<BaseItem> GetEmbyRecordings(RecordingQuery query, DtoOptions dtoOptions, User user)
+ private async Task<QueryResult<BaseItem>> GetEmbyRecordingsAsync(RecordingQuery query, DtoOptions dtoOptions, User user)
{
- if (user == null)
+ if (user is null)
{
return new QueryResult<BaseItem>();
}
- var folderIds = GetRecordingFolders(user, true)
- .Select(i => i.Id)
- .ToList();
+ var folders = await GetRecordingFoldersAsync(user, true).ConfigureAwait(false);
+ var folderIds = Array.ConvertAll(folders, x => x.Id);
var excludeItemTypes = new List<BaseItemKind>();
- if (folderIds.Count == 0)
+ if (folderIds.Length == 0)
{
return new QueryResult<BaseItem>();
}
@@ -1377,7 +1376,7 @@ namespace Emby.Server.Implementations.LiveTv
limit = null;
// var allActivePaths = EmbyTV.EmbyTV.Current.GetAllActiveRecordings().Select(i => i.Path).ToArray();
- // var items = allActivePaths.Select(i => _libraryManager.FindByPath(i, false)).Where(i => i != null).ToArray();
+ // var items = allActivePaths.Select(i => _libraryManager.FindByPath(i, false)).Where(i => i is not null).ToArray();
// return new QueryResult<BaseItem>
// {
@@ -1392,7 +1391,7 @@ namespace Emby.Server.Implementations.LiveTv
{
MediaTypes = new[] { MediaType.Video },
Recursive = true,
- AncestorIds = folderIds.ToArray(),
+ AncestorIds = folderIds,
IsFolder = false,
IsVirtualItem = false,
Limit = limit,
@@ -1517,7 +1516,7 @@ namespace Emby.Server.Implementations.LiveTv
dto.CompletionPercentage = pct;
}
- if (channel != null)
+ if (channel is not null)
{
dto.ChannelName = channel.Name;
@@ -1528,7 +1527,7 @@ namespace Emby.Server.Implementations.LiveTv
}
}
- public QueryResult<BaseItemDto> GetRecordings(RecordingQuery query, DtoOptions options)
+ public async Task<QueryResult<BaseItemDto>> GetRecordingsAsync(RecordingQuery query, DtoOptions options)
{
var user = query.UserId.Equals(default)
? null
@@ -1536,7 +1535,7 @@ namespace Emby.Server.Implementations.LiveTv
RemoveFields(options);
- var internalResult = GetEmbyRecordings(query, options, user);
+ var internalResult = await GetEmbyRecordingsAsync(query, options, user).ConfigureAwait(false);
var returnArray = _dtoService.GetBaseItemDtos(internalResult.Items, options, user);
@@ -1702,7 +1701,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var timer = await GetTimer(id, CancellationToken.None).ConfigureAwait(false);
- if (timer == null)
+ if (timer is null)
{
throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, "Timer with Id {0} not found", id));
}
@@ -1721,7 +1720,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var timer = await GetSeriesTimer(id, CancellationToken.None).ConfigureAwait(false);
- if (timer == null)
+ if (timer is null)
{
throw new ResourceNotFoundException(string.Format(CultureInfo.InvariantCulture, "SeriesTimer with Id {0} not found", id));
}
@@ -1834,7 +1833,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var internalChannelId = _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId);
var channel = _libraryManager.GetItemById(internalChannelId);
- channelName = channel == null ? null : channel.Name;
+ channelName = channel is null ? null : channel.Name;
}
return _tvDtoService.GetSeriesTimerInfoDto(i.Item1, i.Item2, channelName);
@@ -1887,7 +1886,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var currentProgram = programs.FirstOrDefault(i => channel.Id.Equals(i.ChannelId));
- if (currentProgram != null)
+ if (currentProgram is not null)
{
currentProgramsList.Add(currentProgram);
}
@@ -1913,7 +1912,7 @@ namespace Emby.Server.Implementations.LiveTv
ILiveTvService service = null;
ProgramInfo programInfo = null;
- if (program != null)
+ if (program is not null)
{
service = GetService(program);
@@ -2147,7 +2146,7 @@ namespace Emby.Server.Implementations.LiveTv
var service = _services.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture), parts[0], StringComparison.OrdinalIgnoreCase));
- if (service == null)
+ if (service is null)
{
throw new ArgumentException("Service not found.");
}
@@ -2178,7 +2177,7 @@ namespace Emby.Server.Implementations.LiveTv
var provider = _tunerHosts.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));
- if (provider == null)
+ if (provider is null)
{
throw new ResourceNotFoundException();
}
@@ -2222,7 +2221,7 @@ namespace Emby.Server.Implementations.LiveTv
var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));
- if (provider == null)
+ if (provider is null)
{
throw new ResourceNotFoundException(
string.Format(
@@ -2317,7 +2316,7 @@ namespace Emby.Server.Implementations.LiveTv
var providerChannel = EmbyTV.EmbyTV.Current.GetEpgChannelFromTunerChannel(mappings, tunerChannel, providerChannels);
- if (providerChannel != null)
+ if (providerChannel is not null)
{
result.ProviderChannelName = providerChannel.Name;
result.ProviderChannelId = providerChannel.Id;
@@ -2334,7 +2333,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var provider = _listingProviders.FirstOrDefault(i => string.Equals(providerType, i.Type, StringComparison.OrdinalIgnoreCase));
- if (provider == null)
+ if (provider is null)
{
throw new ResourceNotFoundException();
}
@@ -2347,7 +2346,7 @@ namespace Emby.Server.Implementations.LiveTv
var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase));
- if (provider == null)
+ if (provider is null)
{
throw new ResourceNotFoundException();
}
@@ -2379,32 +2378,32 @@ namespace Emby.Server.Implementations.LiveTv
return _tvDtoService.GetInternalProgramId(externalId);
}
- public List<BaseItem> GetRecordingFolders(User user)
- {
- return GetRecordingFolders(user, false);
- }
+ /// <inheritdoc />
+ public Task<BaseItem[]> GetRecordingFoldersAsync(User user)
+ => GetRecordingFoldersAsync(user, false);
- private List<BaseItem> GetRecordingFolders(User user, bool refreshChannels)
+ private async Task<BaseItem[]> GetRecordingFoldersAsync(User user, bool refreshChannels)
{
var folders = EmbyTV.EmbyTV.Current.GetRecordingFolders()
.SelectMany(i => i.Locations)
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(i => _libraryManager.FindByPath(i, true))
- .Where(i => i != null && i.IsVisibleStandalone(user))
+ .Where(i => i is not null && i.IsVisibleStandalone(user))
.SelectMany(i => _libraryManager.GetCollectionFolders(i))
- .GroupBy(x => x.Id)
- .Select(x => x.First())
+ .DistinctBy(x => x.Id)
.OrderBy(i => i.SortName)
.ToList();
- folders.AddRange(_channelManager.GetChannelsInternal(new MediaBrowser.Model.Channels.ChannelQuery
+ var channels = await _channelManager.GetChannelsInternalAsync(new MediaBrowser.Model.Channels.ChannelQuery
{
UserId = user.Id,
IsRecordingsFolder = true,
RefreshLatestChannelItems = refreshChannels
- }).Items);
+ }).ConfigureAwait(false);
+
+ folders.AddRange(channels.Items);
- return folders.Cast<BaseItem>().ToList();
+ return folders.Cast<BaseItem>().ToArray();
}
}
}
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs
index 4b7584af34..6a92fc5997 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs
@@ -42,7 +42,7 @@ namespace Emby.Server.Implementations.LiveTv
{
var activeRecordingInfo = _liveTvManager.GetActiveRecordingInfo(item.Path);
- if (string.IsNullOrEmpty(item.Path) || activeRecordingInfo != null)
+ if (string.IsNullOrEmpty(item.Path) || activeRecordingInfo is not null)
{
return GetMediaSourcesInternal(item, activeRecordingInfo, cancellationToken);
}
@@ -59,7 +59,7 @@ namespace Emby.Server.Implementations.LiveTv
try
{
- if (activeRecordingInfo != null)
+ if (activeRecordingInfo is not null)
{
sources = await EmbyTV.EmbyTV.Current.GetRecordingStreamMediaSources(activeRecordingInfo, cancellationToken)
.ConfigureAwait(false);
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
index 2b82f24623..7b6c8b80aa 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs
@@ -131,10 +131,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
public async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(string channelId, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(channelId))
- {
- throw new ArgumentNullException(nameof(channelId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(channelId);
if (IsValidChannelId(channelId))
{
@@ -147,7 +144,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var channels = await GetChannels(host, true, cancellationToken).ConfigureAwait(false);
var channelInfo = channels.FirstOrDefault(i => string.Equals(i.Id, channelId, StringComparison.OrdinalIgnoreCase));
- if (channelInfo != null)
+ if (channelInfo is not null)
{
return await GetChannelStreamMediaSources(host, channelInfo, cancellationToken).ConfigureAwait(false);
}
@@ -166,10 +163,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
public async Task<ILiveStream> GetChannelStream(string channelId, string streamId, List<ILiveStream> currentLiveStreams, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(channelId))
- {
- throw new ArgumentNullException(nameof(channelId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(channelId);
if (!IsValidChannelId(channelId))
{
@@ -187,7 +181,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var channels = await GetChannels(host, true, cancellationToken).ConfigureAwait(false);
var channelInfo = channels.FirstOrDefault(i => string.Equals(i.Id, channelId, StringComparison.OrdinalIgnoreCase));
- if (channelInfo != null)
+ if (channelInfo is not null)
{
hostsWithChannel.Add(new Tuple<TunerHostInfo, ChannelInfo>(host, channelInfo));
}
@@ -223,10 +217,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
protected virtual bool IsValidChannelId(string channelId)
{
- if (string.IsNullOrEmpty(channelId))
- {
- throw new ArgumentNullException(nameof(channelId));
- }
+ ArgumentException.ThrowIfNullOrEmpty(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 e0eaa8e585..98bbc15406 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs
@@ -14,6 +14,7 @@ using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Extensions;
using Jellyfin.Extensions.Json;
+using Jellyfin.Extensions.Json.Converters;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
@@ -58,7 +59,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
_socketFactory = socketFactory;
_streamHelper = streamHelper;
- _jsonOptions = JsonDefaults.Options;
+ _jsonOptions = new JsonSerializerOptions(JsonDefaults.Options);
+ _jsonOptions.Converters.Add(new JsonBoolNumberConverter());
}
public string Name => "HD Homerun";
@@ -302,7 +304,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
var hdHomerunChannelInfo = channels.FirstOrDefault() as HdHomerunChannelInfo;
- if (hdHomerunChannelInfo == null || hdHomerunChannelInfo.IsLegacyTuner)
+ if (hdHomerunChannelInfo is null || hdHomerunChannelInfo.IsLegacyTuner)
{
return await GetTunerInfosUdp(info, cancellationToken).ConfigureAwait(false);
}
@@ -503,7 +505,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
var modelInfo = await GetModelInfo(tuner, false, cancellationToken).ConfigureAwait(false);
- if (modelInfo != null && modelInfo.SupportsTranscoding)
+ if (modelInfo is not null && modelInfo.SupportsTranscoding)
{
if (tuner.AllowHWTranscoding)
{
@@ -560,7 +562,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
var mediaSource = GetMediaSource(tunerHost, hdhrId, channel, profile);
- if (hdhomerunChannel != null && hdhomerunChannel.IsLegacyTuner)
+ if (hdhomerunChannel is not null && hdhomerunChannel.IsLegacyTuner)
{
return new HdHomerunUdpStream(
mediaSource,
@@ -674,7 +676,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
var info = await TryGetTunerHostInfo(deviceAddress, cancellationToken).ConfigureAwait(false);
- if (info != null)
+ if (info is not null)
{
list.Add(info);
}
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
index e67b5846aa..7bc209d6bd 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs
@@ -37,7 +37,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{
using (var socket = _tcpClient)
{
- if (socket != null)
+ if (socket is not null)
{
_tcpClient = null;
@@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
public async Task<bool> CheckTunerAvailability(IPAddress remoteIp, int tuner, CancellationToken cancellationToken)
{
using var client = new TcpClient();
- await client.ConnectAsync(remoteIp, HdHomeRunPort).ConfigureAwait(false);
+ await client.ConnectAsync(remoteIp, HdHomeRunPort, cancellationToken).ConfigureAwait(false);
using var stream = client.GetStream();
return await CheckTunerAvailability(stream, tuner, cancellationToken).ConfigureAwait(false);
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/LegacyHdHomerunChannelCommands.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/LegacyHdHomerunChannelCommands.cs
index 80d9d07247..3450f971fc 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/LegacyHdHomerunChannelCommands.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/LegacyHdHomerunChannelCommands.cs
@@ -13,8 +13,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
public LegacyHdHomerunChannelCommands(string url)
{
// parse url for channel and program
- var regExp = new Regex(@"\/ch([0-9]+)-?([0-9]*)");
- var match = regExp.Match(url);
+ var match = Regex.Match(url, @"\/ch([0-9]+)-?([0-9]*)");
if (match.Success)
{
_channel = match.Groups[1].Value;
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs
index 2748794b38..3ae9e256b2 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs
@@ -35,7 +35,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
EnableStreamSharing = true;
UniqueId = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
- if (tuner != null)
+ if (tuner is not null)
{
TunerHostId = tuner.Id;
}
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
index a423ec8f48..b418162304 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs
@@ -122,9 +122,13 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var attributes = ParseExtInf(extInf, out string remaining);
extInf = remaining;
- if (attributes.TryGetValue("tvg-logo", out string value))
+ if (attributes.TryGetValue("tvg-logo", out string tvgLogo))
{
- channel.ImageUrl = value;
+ channel.ImageUrl = tvgLogo;
+ }
+ else if (attributes.TryGetValue("logo", out string logo))
+ {
+ channel.ImageUrl = logo;
}
if (attributes.TryGetValue("group-title", out string groupTitle))
@@ -166,30 +170,25 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var nameInExtInf = nameParts.Length > 1 ? nameParts[^1].AsSpan().Trim() : ReadOnlySpan<char>.Empty;
string numberString = null;
- string attributeValue;
- if (attributes.TryGetValue("tvg-chno", out attributeValue))
+ if (attributes.TryGetValue("tvg-chno", out var attributeValue)
+ && double.TryParse(attributeValue, CultureInfo.InvariantCulture, out _))
{
- if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
- {
- numberString = attributeValue;
- }
+ numberString = attributeValue;
}
if (!IsValidChannelNumber(numberString))
{
if (attributes.TryGetValue("tvg-id", out attributeValue))
{
- if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
+ if (double.TryParse(attributeValue, CultureInfo.InvariantCulture, out _))
{
numberString = attributeValue;
}
- else if (attributes.TryGetValue("channel-id", out attributeValue))
+ else if (attributes.TryGetValue("channel-id", out attributeValue)
+ && double.TryParse(attributeValue, CultureInfo.InvariantCulture, out _))
{
- if (double.TryParse(attributeValue, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
- {
- numberString = attributeValue;
- }
+ numberString = attributeValue;
}
}
@@ -207,7 +206,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
var numberPart = nameInExtInf.Slice(0, numberIndex).Trim(new[] { ' ', '.' });
- if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
+ if (double.TryParse(numberPart, CultureInfo.InvariantCulture, out _))
{
numberString = numberPart.ToString();
}
@@ -255,19 +254,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
private static bool IsValidChannelNumber(string numberString)
{
- if (string.IsNullOrWhiteSpace(numberString) ||
- string.Equals(numberString, "-1", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(numberString, "0", StringComparison.OrdinalIgnoreCase))
- {
- return false;
- }
-
- if (!double.TryParse(numberString, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
+ if (string.IsNullOrWhiteSpace(numberString)
+ || string.Equals(numberString, "-1", StringComparison.Ordinal)
+ || string.Equals(numberString, "0", StringComparison.Ordinal))
{
return false;
}
- return true;
+ return double.TryParse(numberString, CultureInfo.InvariantCulture, out _);
}
private static string GetChannelName(string extInf, Dictionary<string, string> attributes)
@@ -285,7 +279,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
- if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out _))
+ if (double.TryParse(numberPart, CultureInfo.InvariantCulture, out _))
{
// channel.Number = number.ToString();
nameInExtInf = nameInExtInf.Substring(numberIndex + 1).Trim(new[] { ' ', '-' });
@@ -317,8 +311,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{
var dict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
- var reg = new Regex(@"([a-z0-9\-_]+)=\""([^""]+)\""", RegexOptions.IgnoreCase);
- var matches = reg.Matches(line);
+ var matches = Regex.Matches(line, @"([a-z0-9\-_]+)=\""([^""]+)\""", RegexOptions.IgnoreCase);
remaining = line;