code analysis and cleanup (#1411)
* cleanup scanner project * cleanup infrastructure projects * cleanup ffmpeg project * cleanup core project * cleanup app project * cleanup main project * update dependencies * code cleanup
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using ErsatzTV.Core.Domain;
|
||||
using System.Globalization;
|
||||
using ErsatzTV.Core.Domain;
|
||||
|
||||
namespace ErsatzTV.Core.Scheduling;
|
||||
|
||||
@@ -121,7 +122,7 @@ internal class ChronologicalMediaComparer : IComparer<MediaItem>
|
||||
Song s => s.SongMetadata.HeadOrNone().Match(sm => sm.Track ?? string.Empty, () => string.Empty),
|
||||
MusicVideo mv => mv.MusicVideoMetadata.HeadOrNone()
|
||||
.Match(mvm => mvm.Track ?? int.MaxValue, () => int.MaxValue)
|
||||
.ToString("D10"),
|
||||
.ToString("D10", CultureInfo.InvariantCulture),
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
@@ -130,7 +131,7 @@ internal class ChronologicalMediaComparer : IComparer<MediaItem>
|
||||
Song s => s.SongMetadata.HeadOrNone().Match(sm => sm.Track ?? string.Empty, () => string.Empty),
|
||||
MusicVideo mv => mv.MusicVideoMetadata.HeadOrNone()
|
||||
.Match(mvm => mvm.Track ?? int.MaxValue, () => int.MaxValue)
|
||||
.ToString("D10"),
|
||||
.ToString("D10", CultureInfo.InvariantCulture),
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using ErsatzTV.Core.Domain;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ErsatzTV.Core.Domain;
|
||||
using ErsatzTV.Core.Interfaces.Repositories;
|
||||
|
||||
namespace ErsatzTV.Core.Scheduling;
|
||||
|
||||
[SuppressMessage("Naming", "CA1711:Identifiers should not have incorrect suffix")]
|
||||
public static class MediaItemsForCollection
|
||||
{
|
||||
public static async Task<List<MediaItem>> Collect(
|
||||
@@ -36,7 +38,7 @@ public static class MediaItemsForCollection
|
||||
await mediaCollectionRepository.GetSmartCollectionItems(collectionKey.SmartCollectionId ?? 0));
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
throw new ArgumentOutOfRangeException(nameof(collectionKey));
|
||||
}
|
||||
|
||||
return result.DistinctBy(x => x.Id).ToList();
|
||||
|
||||
@@ -487,7 +487,7 @@ public class PlayoutBuilder : IPlayoutBuilder
|
||||
"Failed to schedule beyond {Time}; aborting playout build - this is a bug",
|
||||
playoutBuilderState.CurrentTime);
|
||||
|
||||
throw new ApplicationException("Scheduling loop encountered");
|
||||
throw new InvalidOperationException("Scheduling loop encountered");
|
||||
}
|
||||
|
||||
// _logger.LogDebug("Playout time is {CurrentTime}", playoutBuilderState.CurrentTime);
|
||||
@@ -527,7 +527,7 @@ public class PlayoutBuilder : IPlayoutBuilder
|
||||
nextScheduleItem,
|
||||
playoutFinish,
|
||||
cancellationToken),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(scheduleItem))
|
||||
_ => throw new NotSupportedException(nameof(scheduleItem))
|
||||
};
|
||||
|
||||
(PlayoutBuilderState nextState, List<PlayoutItem> playoutItems) = result;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using ErsatzTV.Core.Domain;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ErsatzTV.Core.Domain;
|
||||
using ErsatzTV.Core.Domain.Filler;
|
||||
using ErsatzTV.Core.Extensions;
|
||||
using ErsatzTV.Core.Interfaces.Scheduling;
|
||||
@@ -7,11 +8,11 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace ErsatzTV.Core.Scheduling;
|
||||
|
||||
[SuppressMessage("Design", "CA1000:Do not declare static members on generic types")]
|
||||
public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> where T : ProgramScheduleItem
|
||||
{
|
||||
protected readonly ILogger _logger;
|
||||
|
||||
protected PlayoutModeSchedulerBase(ILogger logger) => _logger = logger;
|
||||
protected PlayoutModeSchedulerBase(ILogger logger) => Logger = logger;
|
||||
protected ILogger Logger { get; }
|
||||
|
||||
public abstract Tuple<PlayoutBuilderState, List<PlayoutItem>> Schedule(
|
||||
PlayoutBuilderState playoutBuilderState,
|
||||
@@ -93,7 +94,7 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe
|
||||
|
||||
if (nextState.CurrentTime + itemDuration > nextItemStart)
|
||||
{
|
||||
_logger.LogDebug(
|
||||
Logger.LogDebug(
|
||||
"Filler with duration {Duration:hh\\:mm\\:ss} will go past next item start {NextItemStart}",
|
||||
itemDuration,
|
||||
nextItemStart);
|
||||
@@ -187,7 +188,7 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe
|
||||
ProgramScheduleItem scheduleItem,
|
||||
MediaItem mediaItem,
|
||||
DateTimeOffset startTime) =>
|
||||
_logger.LogDebug(
|
||||
Logger.LogDebug(
|
||||
"Scheduling media item: {ScheduleItemNumber} / {CollectionType} / {MediaItemId} - {MediaItemTitle} / {StartTime}",
|
||||
scheduleItem.Index,
|
||||
scheduleItem.CollectionType,
|
||||
@@ -214,7 +215,7 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe
|
||||
// multiple pad-to-nearest-minute values are invalid; use no filler
|
||||
if (allFiller.Count(f => f.FillerMode == FillerMode.Pad && f.PadToNearestMinute.HasValue) > 1)
|
||||
{
|
||||
_logger.LogError("Multiple pad-to-nearest-minute values are invalid; no filler will be used");
|
||||
Logger.LogError("Multiple pad-to-nearest-minute values are invalid; no filler will be used");
|
||||
return new List<PlayoutItem> { playoutItem };
|
||||
}
|
||||
|
||||
@@ -594,7 +595,7 @@ public abstract class PlayoutModeSchedulerBase<T> : IPlayoutModeScheduler<T> whe
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
_logger.LogDebug(
|
||||
Logger.LogDebug(
|
||||
"Filler item is too long {FillerDuration:g} to fill {GapDuration:g}; skipping to next filler item",
|
||||
itemDuration,
|
||||
remainingToFill);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class PlayoutModeSchedulerDuration : PlayoutModeSchedulerBase<ProgramSche
|
||||
|
||||
if (itemDuration > scheduleItem.PlayoutDuration)
|
||||
{
|
||||
_logger.LogWarning(
|
||||
Logger.LogWarning(
|
||||
"Skipping playout item {Title} with duration {Duration:hh\\:mm\\:ss} that will never fit in schedule item duration {PlayoutDuration:hh\\:mm\\:ss}",
|
||||
PlayoutBuilder.DisplayTitle(mediaItem),
|
||||
itemDuration,
|
||||
@@ -86,7 +86,7 @@ public class PlayoutModeSchedulerDuration : PlayoutModeSchedulerBase<ProgramSche
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogDebug(
|
||||
Logger.LogDebug(
|
||||
"Skipping playout item {Title} with duration {Duration:hh\\:mm\\:ss} that is longer than remaining duration {RemainingDuration:hh\\:mm\\:ss}",
|
||||
PlayoutBuilder.DisplayTitle(mediaItem),
|
||||
itemDuration,
|
||||
@@ -169,7 +169,7 @@ public class PlayoutModeSchedulerDuration : PlayoutModeSchedulerBase<ProgramSche
|
||||
TimeSpan durationBlock = itemEndTimeWithFiller - itemStartTime;
|
||||
if (itemEndTimeWithFiller - itemStartTime > scheduleItem.PlayoutDuration)
|
||||
{
|
||||
_logger.LogWarning(
|
||||
Logger.LogWarning(
|
||||
"Unable to schedule duration block of {DurationBlock:hh\\:mm\\:ss} which is longer than the configured playout duration {PlayoutDuration:hh\\:mm\\:ss}",
|
||||
durationBlock,
|
||||
scheduleItem.PlayoutDuration);
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ShuffledScheduleItemsEnumerator : IScheduleItemsEnumerator
|
||||
return _shuffled[(State.Index + offset) % _scheduleItemsCount];
|
||||
}
|
||||
|
||||
private IList<ProgramScheduleItem> Shuffle(IEnumerable<ProgramScheduleItem> list, CloneableRandom random)
|
||||
private static IList<ProgramScheduleItem> Shuffle(IEnumerable<ProgramScheduleItem> list, CloneableRandom random)
|
||||
{
|
||||
ProgramScheduleItem[] copy = list.ToArray();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user