Browse Source

Merge c6bfe8c80b into 15db3c4ca0

pull/2964/merge
Ministorm3 4 days ago committed by GitHub
parent
commit
9a29e3f18d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      ErsatzTV.Application/Channels/Commands/RefreshChannelDataHandler.cs
  2. 5
      ErsatzTV.Application/Playouts/Commands/ReplacePlayoutAlternateScheduleItemsHandler.cs
  3. 5
      ErsatzTV.Core/Scheduling/PlayoutBuilder.cs
  4. 34
      ErsatzTV.Infrastructure/Streaming/ExternalJsonPlayoutItemProvider.cs

12
ErsatzTV.Application/Channels/Commands/RefreshChannelDataHandler.cs

@ -1189,10 +1189,18 @@ public class RefreshChannelDataHandler : IRequestHandler<RefreshChannelData>
// must deserialize channel from json // must deserialize channel from json
foreach (ExternalJsonChannel channel in maybeChannel) foreach (ExternalJsonChannel channel in maybeChannel)
{ {
// TODO: null start time should log and throw if (string.IsNullOrWhiteSpace(channel.StartTime))
{
_logger.LogError(
"External json channel in file {File} has no start time; unable to refresh channel data",
path);
throw new InvalidOperationException(
$"External json channel in file {path} has no start time");
}
DateTimeOffset startTime = DateTimeOffset.Parse( DateTimeOffset startTime = DateTimeOffset.Parse(
channel.StartTime ?? string.Empty, channel.StartTime,
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
DateTimeStyles.AssumeUniversal).ToLocalTime(); DateTimeStyles.AssumeUniversal).ToLocalTime();

5
ErsatzTV.Application/Playouts/Commands/ReplacePlayoutAlternateScheduleItemsHandler.cs

@ -20,7 +20,10 @@ public class ReplacePlayoutAlternateScheduleItemsHandler(
ReplacePlayoutAlternateScheduleItems request, ReplacePlayoutAlternateScheduleItems request,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
// TODO: validate that items is not empty if (request.Items.Count == 0)
{
return BaseError.New("Playout alternate schedule items must not be empty");
}
try try
{ {

5
ErsatzTV.Core/Scheduling/PlayoutBuilder.cs

@ -1488,7 +1488,10 @@ public class PlayoutBuilder : IPlayoutBuilder
goto default; goto default;
default: default:
// TODO: handle this error case differently? _logger.LogWarning(
"Unsupported playback order {PlaybackOrder}; falling back to random",
playbackOrder);
return new RandomizedMediaCollectionEnumerator(mediaItems, state); return new RandomizedMediaCollectionEnumerator(mediaItems, state);
} }
} }

34
ErsatzTV.Infrastructure/Streaming/ExternalJsonPlayoutItemProvider.cs

@ -92,10 +92,18 @@ public class ExternalJsonPlayoutItemProvider : IExternalJsonPlayoutItemProvider
// must deserialize channel from json // must deserialize channel from json
foreach (ExternalJsonChannel channel in maybeChannel) foreach (ExternalJsonChannel channel in maybeChannel)
{ {
// TODO: null start time should log and throw if (string.IsNullOrWhiteSpace(channel.StartTime))
{
_logger.LogError(
"External json channel in file {File} has no start time; unable to locate playout item",
playout.ScheduleFile);
throw new InvalidOperationException(
$"External json channel in file {playout.ScheduleFile} has no start time");
}
DateTimeOffset startTime = DateTimeOffset.Parse( DateTimeOffset startTime = DateTimeOffset.Parse(
channel.StartTime ?? string.Empty, channel.StartTime,
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
DateTimeStyles.AssumeUniversal).ToLocalTime(); DateTimeStyles.AssumeUniversal).ToLocalTime();
@ -207,14 +215,35 @@ public class ExternalJsonPlayoutItemProvider : IExternalJsonPlayoutItemProvider
.Include(pms => pms.Connections) .Include(pms => pms.Connections)
.SelectOneAsync(pms => pms.ServerName, pms => pms.ServerName == program.ServerKey, cancellationToken); .SelectOneAsync(pms => pms.ServerName, pms => pms.ServerName == program.ServerKey, cancellationToken);
if (maybeServer.IsNone)
{
_logger.LogWarning(
"Unable to stream remotely; no Plex server found with server name {ServerName}",
program.ServerKey);
}
foreach (PlexMediaSource server in maybeServer) foreach (PlexMediaSource server in maybeServer)
{ {
Option<PlexConnection> maybeConnection = server.Connections.SingleOrDefault(c => c.IsActive); Option<PlexConnection> maybeConnection = server.Connections.SingleOrDefault(c => c.IsActive);
if (maybeConnection.IsNone)
{
_logger.LogWarning(
"Unable to stream remotely; Plex server {ServerName} has no active connection",
server.ServerName);
}
foreach (PlexConnection connection in maybeConnection) foreach (PlexConnection connection in maybeConnection)
{ {
Option<PlexServerAuthToken> maybeToken = Option<PlexServerAuthToken> maybeToken =
await _plexSecretStore.GetServerAuthToken(server.ClientIdentifier); await _plexSecretStore.GetServerAuthToken(server.ClientIdentifier);
if (maybeToken.IsNone)
{
_logger.LogWarning(
"Unable to stream remotely; Plex server {ServerName} has no auth token",
server.ServerName);
}
foreach (PlexServerAuthToken token in maybeToken) foreach (PlexServerAuthToken token in maybeToken)
{ {
MediaItem mediaItem = program.Type switch MediaItem mediaItem = program.Type switch
@ -230,7 +259,6 @@ public class ExternalJsonPlayoutItemProvider : IExternalJsonPlayoutItemProvider
} }
} }
// TODO: log errors?
return new UnableToLocatePlayoutItem(); return new UnableToLocatePlayoutItem();
} }

Loading…
Cancel
Save