Browse Source

fix mid roll pad; fix mysql queries (#1416)

* fix mysql queries

* fix mid roll pad with hls segmenter
pull/1417/head
Jason Dove 2 years ago committed by GitHub
parent
commit
8c9cf7b6f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      ErsatzTV.Application/Streaming/HlsSessionWorker.cs
  2. 7
      ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs
  3. 2
      ErsatzTV.Infrastructure.Sqlite/Migrations/20210227001213_Add_MediaItemPathIndex.cs
  4. 4
      ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs
  5. 2
      ErsatzTV.Infrastructure/Data/Repositories/FFmpegProfileRepository.cs
  6. 2
      ErsatzTV.Infrastructure/Data/Repositories/JellyfinTelevisionRepository.cs
  7. 6
      ErsatzTV.Infrastructure/Data/Repositories/MediaCollectionRepository.cs
  8. 1
      ErsatzTV.Infrastructure/Data/Repositories/MediaItemRepository.cs
  9. 2
      ErsatzTV.Infrastructure/Data/Repositories/PlexMovieRepository.cs
  10. 2
      ErsatzTV.Infrastructure/Data/Repositories/StreamSelectorRepository.cs
  11. 8
      ErsatzTV.Infrastructure/Data/Repositories/TelevisionRepository.cs
  12. 4
      ErsatzTV.Infrastructure/Health/HealthCheckService.cs

1
ErsatzTV.Application/Streaming/HlsSessionWorker.cs

@ -393,6 +393,7 @@ public class HlsSessionWorker : IHlsSessionWorker @@ -393,6 +393,7 @@ public class HlsSessionWorker : IHlsSessionWorker
if (commandResult.ExitCode == 0)
{
_transcodedUntil = processModel.Until;
_state = NextState(_state, null);
_hasWrittenSegments = true;

7
ErsatzTV.Application/Streaming/Queries/GetPlayoutItemProcessByChannelNumberHandler.cs

@ -180,11 +180,16 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler< @@ -180,11 +180,16 @@ public class GetPlayoutItemProcessByChannelNumberHandler : FFmpegProcessHandler<
TimeSpan duration = finish - effectiveNow;
var isComplete = true;
// _logger.LogDebug("PRE Start: {Start}, Finish {Finish}", start, finish);
// _logger.LogDebug("PRE in: {In}, out: {Out}", inPoint, outPoint);
if (!request.HlsRealtime && duration > TimeSpan.FromMinutes(2))
{
finish = effectiveNow + TimeSpan.FromMinutes(2);
outPoint = finish - start + TimeSpan.FromMinutes(2);
outPoint = finish - start + inPoint;
isComplete = false;
// _logger.LogDebug("POST Start: {Start}, Finish {Finish}", start, finish);
// _logger.LogDebug("POST in: {In}, out: {Out}", inPoint, outPoint);
}
Command process = await _ffmpegProcessService.ForPlayoutItem(

2
ErsatzTV.Infrastructure.Sqlite/Migrations/20210227001213_Add_MediaItemPathIndex.cs

@ -21,7 +21,7 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations @@ -21,7 +21,7 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations
(SELECT mi.Id FROM Library l
INNER JOIN LibraryPath lp ON l.Id = lp.LibraryId
INNER JOIN MediaItem mi ON lp.Id = mi.LibraryPathId
LEFT OUTER JOIN Show s ON mi.Id = s.Id
LEFT OUTER JOIN `Show` s ON mi.Id = s.Id
LEFT OUTER JOIN Season ssn ON mi.Id = ssn.Id
LEFT OUTER JOIN Episode e ON mi.Id = e.Id
WHERE l.MediaKind = 2 AND s.Id IS NULL AND ssn.Id IS NULL AND e.Id IS NULL)");

4
ErsatzTV.Infrastructure/Data/Repositories/ChannelRepository.cs

@ -13,7 +13,7 @@ public class ChannelRepository : IChannelRepository @@ -13,7 +13,7 @@ public class ChannelRepository : IChannelRepository
public async Task<Option<Channel>> GetChannel(int id)
{
await using TvContext dbContext = _dbContextFactory.CreateDbContext();
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync();
return await dbContext.Channels
.Include(c => c.Artwork)
.Include(c => c.Watermark)
@ -24,7 +24,7 @@ public class ChannelRepository : IChannelRepository @@ -24,7 +24,7 @@ public class ChannelRepository : IChannelRepository
public async Task<Option<Channel>> GetByNumber(string number)
{
await using TvContext dbContext = _dbContextFactory.CreateDbContext();
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync();
return await dbContext.Channels
.Include(c => c.FFmpegProfile)
.ThenInclude(p => p.Resolution)

2
ErsatzTV.Infrastructure/Data/Repositories/FFmpegProfileRepository.cs

@ -14,7 +14,7 @@ public class FFmpegProfileRepository : IFFmpegProfileRepository @@ -14,7 +14,7 @@ public class FFmpegProfileRepository : IFFmpegProfileRepository
public async Task<FFmpegProfile> Copy(int ffmpegProfileId, string name)
{
await using TvContext dbContext = _dbContextFactory.CreateDbContext();
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync();
FFmpegProfile ffmpegProfile = await dbContext.FFmpegProfiles.FindAsync(ffmpegProfileId);
PropertyValues values = dbContext.Entry(ffmpegProfile).CurrentValues.Clone();

2
ErsatzTV.Infrastructure/Data/Repositories/JellyfinTelevisionRepository.cs

@ -614,7 +614,7 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository @@ -614,7 +614,7 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository
await dbContext.SaveChangesAsync();
}
public static async Task UpdateEpisode(TvContext dbContext, JellyfinEpisode existing, JellyfinEpisode incoming)
private static async Task UpdateEpisode(TvContext dbContext, JellyfinEpisode existing, JellyfinEpisode incoming)
{
// library path is used for search indexing later
incoming.LibraryPath = existing.LibraryPath;

6
ErsatzTV.Infrastructure/Data/Repositories/MediaCollectionRepository.cs

@ -595,10 +595,10 @@ public class MediaCollectionRepository : IMediaCollectionRepository @@ -595,10 +595,10 @@ public class MediaCollectionRepository : IMediaCollectionRepository
private static async Task<List<Episode>> GetShowItemsFromShowId(TvContext dbContext, int showId)
{
IEnumerable<int> ids = await dbContext.Connection.QueryAsync<int>(
@"SELECT Episode.Id FROM Show
INNER JOIN Season ON Season.ShowId = Show.Id
@"SELECT Episode.Id FROM `Show`
INNER JOIN Season ON Season.ShowId = `Show`.Id
INNER JOIN Episode ON Episode.SeasonId = Season.Id
WHERE Show.Id = @ShowId",
WHERE `Show`.Id = @ShowId",
new { ShowId = showId });
return await GetShowItemsFromEpisodeIds(dbContext, ids);

1
ErsatzTV.Infrastructure/Data/Repositories/MediaItemRepository.cs

@ -201,7 +201,6 @@ public class MediaItemRepository : IMediaItemRepository @@ -201,7 +201,6 @@ public class MediaItemRepository : IMediaItemRepository
private async Task<List<string>> GetAllLanguageCodes()
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync();
// TODO: might need to fix this for sqlite
return await dbContext.Connection.QueryAsync<string>(
@"SELECT LanguageCode FROM
(SELECT Language AS LanguageCode

2
ErsatzTV.Infrastructure/Data/Repositories/PlexMovieRepository.cs

@ -26,7 +26,7 @@ public class PlexMovieRepository : IPlexMovieRepository @@ -26,7 +26,7 @@ public class PlexMovieRepository : IPlexMovieRepository
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync();
return await dbContext.Connection.QueryAsync<PlexItemEtag>(
@"SELECT Key, Etag, MI.State FROM PlexMovie
@"SELECT `Key`, Etag, MI.State FROM PlexMovie
INNER JOIN Movie M on PlexMovie.Id = M.Id
INNER JOIN MediaItem MI on M.Id = MI.Id
INNER JOIN LibraryPath LP on MI.LibraryPathId = LP.Id

2
ErsatzTV.Infrastructure/Data/Repositories/StreamSelectorRepository.cs

@ -25,7 +25,7 @@ public class StreamSelectorRepository : IStreamSelectorRepository @@ -25,7 +25,7 @@ public class StreamSelectorRepository : IStreamSelectorRepository
EM.Id as EpisodeMetadataId
from EpisodeMetadata EM
inner join Episode E on EM.EpisodeId = E.Id
inner join Season S on S.Id == E.SeasonId
inner join Season S on S.Id = E.SeasonId
inner join ShowMetadata SM on S.ShowId = SM.ShowId
where EpisodeId = @Id",
new { Id = episodeId });

8
ErsatzTV.Infrastructure/Data/Repositories/TelevisionRepository.cs

@ -24,7 +24,7 @@ public class TelevisionRepository : ITelevisionRepository @@ -24,7 +24,7 @@ public class TelevisionRepository : ITelevisionRepository
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync();
return await dbContext.Connection.QuerySingleAsync<int>(
"SELECT COUNT(*) FROM Show WHERE Id in @ShowIds",
"SELECT COUNT(*) FROM `Show` WHERE Id in @ShowIds",
new { ShowIds = showIds })
.Map(c => c == showIds.Count);
}
@ -502,10 +502,10 @@ public class TelevisionRepository : ITelevisionRepository @@ -502,10 +502,10 @@ public class TelevisionRepository : ITelevisionRepository
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync();
IEnumerable<int> ids = await dbContext.Connection.QueryAsync<int>(
@"SELECT Episode.Id FROM Show
INNER JOIN Season ON Season.ShowId = Show.Id
@"SELECT Episode.Id FROM `Show`
INNER JOIN Season ON Season.ShowId = `Show`.Id
INNER JOIN Episode ON Episode.SeasonId = Season.Id
WHERE Show.Id = @ShowId",
WHERE `Show`.Id = @ShowId",
new { ShowId = showId });
return await dbContext.Episodes

4
ErsatzTV.Infrastructure/Health/HealthCheckService.cs

@ -53,8 +53,12 @@ public class HealthCheckService : IHealthCheckService @@ -53,8 +53,12 @@ public class HealthCheckService : IHealthCheckService
.Map(results => results.ToList());
private HealthCheckResult LogAndReturn(Exception ex, HealthCheckResult failedResult)
{
if (ex is not OperationCanceledException)
{
_logger.LogWarning(ex, "Failed to run health check {Title}", failedResult.Title);
}
return failedResult;
}
}

Loading…
Cancel
Save