From 0b5a6f9dcd10c083585ecd1664bd0d4f45f225b2 Mon Sep 17 00:00:00 2001 From: Jason Dove Date: Fri, 12 Feb 2021 20:32:50 -0600 Subject: [PATCH] appease the c# compiler (#17) --- .../SynchronizePlexLibrariesHandler.cs | 2 +- ErsatzTV.Application/MediaSources/Mapper.cs | 6 ++-- .../ProgramScheduleItemCommandBase.cs | 6 ++-- .../ProgramSchedules/Mapper.cs | 7 +++-- ErsatzTV.Core/FFmpeg/FFmpegProcessBuilder.cs | 28 ++++++------------- .../Repositories/MediaCollectionRepository.cs | 6 ++-- .../Plex/PlexTvApiClient.cs | 2 +- ErsatzTV.sln.DotSettings | 13 ++++++++- ErsatzTV/Services/PlexService.cs | 5 ++-- ErsatzTV/Shared/MainLayout.razor | 2 +- 10 files changed, 44 insertions(+), 33 deletions(-) diff --git a/ErsatzTV.Application/MediaSources/Commands/SynchronizePlexLibrariesHandler.cs b/ErsatzTV.Application/MediaSources/Commands/SynchronizePlexLibrariesHandler.cs index 9d284103d..398e0ad48 100644 --- a/ErsatzTV.Application/MediaSources/Commands/SynchronizePlexLibrariesHandler.cs +++ b/ErsatzTV.Application/MediaSources/Commands/SynchronizePlexLibrariesHandler.cs @@ -86,7 +86,7 @@ namespace ErsatzTV.Application.MediaSources.Commands error => { _logger.LogWarning( - "Unable to synchronize libraries from Plex server {PlexServer}: {Error}", + "Unable to synchronize libraries from plex server {PlexServer}: {Error}", connectionParameters.PlexMediaSource.Name, error.Value); diff --git a/ErsatzTV.Application/MediaSources/Mapper.cs b/ErsatzTV.Application/MediaSources/Mapper.cs index 3d1ffc26f..df68b4e3c 100644 --- a/ErsatzTV.Application/MediaSources/Mapper.cs +++ b/ErsatzTV.Application/MediaSources/Mapper.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using ErsatzTV.Core.Domain; using static LanguageExt.Prelude; @@ -10,7 +11,8 @@ namespace ErsatzTV.Application.MediaSources mediaSource switch { LocalMediaSource lms => new LocalMediaSourceViewModel(lms.Id, lms.Name, lms.Folder), - PlexMediaSource pms => ProjectToViewModel(pms) + PlexMediaSource pms => ProjectToViewModel(pms), + _ => throw new NotSupportedException($"Unsupported media source {mediaSource.GetType().Name}") }; internal static PlexMediaSourceViewModel ProjectToViewModel(PlexMediaSource plexMediaSource) => diff --git a/ErsatzTV.Application/ProgramSchedules/Commands/ProgramScheduleItemCommandBase.cs b/ErsatzTV.Application/ProgramSchedules/Commands/ProgramScheduleItemCommandBase.cs index dec8de188..696d4d902 100644 --- a/ErsatzTV.Application/ProgramSchedules/Commands/ProgramScheduleItemCommandBase.cs +++ b/ErsatzTV.Application/ProgramSchedules/Commands/ProgramScheduleItemCommandBase.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using ErsatzTV.Core; using ErsatzTV.Core.Domain; using ErsatzTV.Core.Interfaces.Repositories; @@ -88,7 +89,8 @@ namespace ErsatzTV.Application.ProgramSchedules.Commands MediaCollectionId = item.MediaCollectionId, PlayoutDuration = item.PlayoutDuration.GetValueOrDefault(), OfflineTail = item.OfflineTail.GetValueOrDefault() - } + }, + _ => throw new NotSupportedException($"Unsupported playout mode {item.PlayoutMode}") }; } } diff --git a/ErsatzTV.Application/ProgramSchedules/Mapper.cs b/ErsatzTV.Application/ProgramSchedules/Mapper.cs index f5f96d5e9..1b7056882 100644 --- a/ErsatzTV.Application/ProgramSchedules/Mapper.cs +++ b/ErsatzTV.Application/ProgramSchedules/Mapper.cs @@ -1,4 +1,5 @@ -using ErsatzTV.Core.Domain; +using System; +using ErsatzTV.Core.Domain; namespace ErsatzTV.Application.ProgramSchedules { @@ -40,7 +41,9 @@ namespace ErsatzTV.Application.ProgramSchedules one.Index, one.StartType, one.StartTime, - MediaCollections.Mapper.ProjectToViewModel(one.MediaCollection)) + MediaCollections.Mapper.ProjectToViewModel(one.MediaCollection)), + _ => throw new NotSupportedException( + $"Unsupported program schedule item type {programScheduleItem.GetType().Name}") }; } } diff --git a/ErsatzTV.Core/FFmpeg/FFmpegProcessBuilder.cs b/ErsatzTV.Core/FFmpeg/FFmpegProcessBuilder.cs index d35647aa7..3cb6dab5d 100644 --- a/ErsatzTV.Core/FFmpeg/FFmpegProcessBuilder.cs +++ b/ErsatzTV.Core/FFmpeg/FFmpegProcessBuilder.cs @@ -285,7 +285,7 @@ namespace ErsatzTV.Core.FFmpeg bool hasVideoFilters = _videoFilters.Any(); if (hasVideoFilters) { - (string filter, string finalLabel) = GenerateFilter(_videoFilters, StreamType.Video); + (string filter, string finalLabel) = GenerateVideoFilter(_videoFilters); complexFilter.Append(filter); videoLabel = finalLabel; } @@ -297,7 +297,7 @@ namespace ErsatzTV.Core.FFmpeg complexFilter.Append(';'); } - (string filter, string finalLabel) = GenerateFilter(_audioFilters, StreamType.Audio); + (string filter, string finalLabel) = GenerateAudioFilter(_audioFilters); complexFilter.Append(filter); audioLabel = finalLabel; } @@ -348,20 +348,16 @@ namespace ErsatzTV.Core.FFmpeg }; } - private FilterResult GenerateFilter(Queue filterQueue, StreamType streamType) + private FilterResult GenerateVideoFilter(Queue filterQueue) => + GenerateFilter(filterQueue, "null", 'v'); + + private FilterResult GenerateAudioFilter(Queue filterQueue) => + GenerateFilter(filterQueue, "anull", 'a'); + + private static FilterResult GenerateFilter(Queue filterQueue, string nullFilter, char av) { var filter = new StringBuilder(); var index = 0; - string nullFilter = streamType switch - { - StreamType.Audio => "anull", - StreamType.Video => "null" - }; - char av = streamType switch - { - StreamType.Audio => 'a', - StreamType.Video => 'v' - }; filter.Append($"[0:{av}]{nullFilter}[{av}{index}]"); while (filterQueue.TryDequeue(out string result)) { @@ -372,11 +368,5 @@ namespace ErsatzTV.Core.FFmpeg } private record FilterResult(string Filter, string FinalLabel); - - private enum StreamType - { - Audio, - Video - } } } diff --git a/ErsatzTV.Infrastructure/Data/Repositories/MediaCollectionRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/MediaCollectionRepository.cs index e767108a7..9f532bea6 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/MediaCollectionRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/MediaCollectionRepository.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using ErsatzTV.Core.AggregateModels; @@ -68,7 +69,8 @@ namespace ErsatzTV.Infrastructure.Data.Repositories collection => collection switch { SimpleMediaCollection s => SimpleItems(s), - TelevisionMediaCollection t => TelevisionItems(t) + TelevisionMediaCollection t => TelevisionItems(t), + _ => throw new NotSupportedException($"Unsupported collection type {collection.GetType().Name}") }).Bind(x => x.Sequence()); public Task>> GetSimpleMediaCollectionItems(int id) => diff --git a/ErsatzTV.Infrastructure/Plex/PlexTvApiClient.cs b/ErsatzTV.Infrastructure/Plex/PlexTvApiClient.cs index 9c3f45fd3..0ab5103bf 100644 --- a/ErsatzTV.Infrastructure/Plex/PlexTvApiClient.cs +++ b/ErsatzTV.Infrastructure/Plex/PlexTvApiClient.cs @@ -105,7 +105,7 @@ namespace ErsatzTV.Infrastructure.Plex return true; } } - catch (Exception ex) + catch (Exception) { // ignored } diff --git a/ErsatzTV.sln.DotSettings b/ErsatzTV.sln.DotSettings index 40c458df3..71b2aa00a 100644 --- a/ErsatzTV.sln.DotSettings +++ b/ErsatzTV.sln.DotSettings @@ -2,18 +2,24 @@ DTO HDHR SAR + True + True True True True True True + True True True True + True True + True True True True + True True True @@ -21,5 +27,10 @@ True True True + True + True True - True \ No newline at end of file + True + True + True + True \ No newline at end of file diff --git a/ErsatzTV/Services/PlexService.cs b/ErsatzTV/Services/PlexService.cs index 4d1c6e093..7c1140027 100644 --- a/ErsatzTV/Services/PlexService.cs +++ b/ErsatzTV/Services/PlexService.cs @@ -63,14 +63,15 @@ namespace ErsatzTV.Services TryCompletePlexPinFlow pinRequest => CompletePinFlow(pinRequest, cancellationToken), SynchronizePlexMediaSources sourcesRequest => SynchronizeSources( sourcesRequest, - cancellationToken) + cancellationToken), + _ => throw new NotSupportedException($"Unsupported request type: {request.GetType().Name}") }; await requestTask; } catch (Exception ex) { - _logger.LogWarning(ex, "Failed to process poll for Plex auth token request"); + _logger.LogWarning(ex, "Failed to process plex background service request"); } } } diff --git a/ErsatzTV/Shared/MainLayout.razor b/ErsatzTV/Shared/MainLayout.razor index efac1ed82..c2c521569 100644 --- a/ErsatzTV/Shared/MainLayout.razor +++ b/ErsatzTV/Shared/MainLayout.razor @@ -34,7 +34,7 @@ Schedules Playouts Logs - + ErsatzTV Version @InfoVersion