mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* fix embedded subtitles from media servers * fix plex external subtitles * fix artwork bug, delete orphaned subtitles * jellyfin subtitles work again * emby subtitles work * rescan all media server librariespull/1237/head
44 changed files with 4891 additions and 252 deletions
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
using ErsatzTV.Core; |
||||
|
||||
namespace ErsatzTV.Application.Maintenance; |
||||
|
||||
public record DeleteOrphanedSubtitles : IRequest<Either<BaseError, Unit>>, IBackgroundServiceRequest; |
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
using Dapper; |
||||
using ErsatzTV.Core; |
||||
using ErsatzTV.Infrastructure.Data; |
||||
using Microsoft.EntityFrameworkCore; |
||||
|
||||
namespace ErsatzTV.Application.Maintenance; |
||||
|
||||
public class DeleteOrphanedSubtitlesHandler : IRequestHandler<DeleteOrphanedSubtitles, Either<BaseError, Unit>> |
||||
{ |
||||
private readonly IDbContextFactory<TvContext> _dbContextFactory; |
||||
|
||||
public DeleteOrphanedSubtitlesHandler(IDbContextFactory<TvContext> dbContextFactory) |
||||
{ |
||||
_dbContextFactory = dbContextFactory; |
||||
} |
||||
|
||||
public async Task<Either<BaseError, Unit>> Handle( |
||||
DeleteOrphanedSubtitles request, |
||||
CancellationToken cancellationToken) |
||||
{ |
||||
try |
||||
{ |
||||
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken); |
||||
|
||||
IEnumerable<int> toDelete = await dbContext.Connection.QueryAsync<int>( |
||||
@"SELECT S.Id FROM Subtitle S
|
||||
WHERE S.ArtistMetadataId IS NULL AND S.EpisodeMetadataId IS NULL |
||||
AND S.MovieMetadataId IS NULL AND S.MusicVideoMetadataId IS NULL |
||||
AND S.OtherVideoMetadataId IS NULL AND S.SeasonMetadataId IS NULL |
||||
AND S.ShowMetadataId IS NULL AND s.SongMetadataId IS NULL");
|
||||
|
||||
foreach (int id in toDelete) |
||||
{ |
||||
await dbContext.Connection.ExecuteAsync("DELETE FROM Subtitle WHERE Id = @Id", new { Id = id }); |
||||
} |
||||
|
||||
return Unit.Default; |
||||
} |
||||
catch (Exception ex) |
||||
{ |
||||
return BaseError.New(ex.Message); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
namespace ErsatzTV.Core.Jellyfin; |
||||
|
||||
public static class JellyfinStream |
||||
{ |
||||
public static readonly int ExternalStreamOffset = 100_000; |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
||||
#nullable disable |
||||
|
||||
namespace ErsatzTV.Infrastructure.Migrations |
||||
{ |
||||
/// <inheritdoc />
|
||||
public partial class Rescan_AllMediaServerLibraries_Subtitles : Migration |
||||
{ |
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.Sql("UPDATE EmbyMovie SET Etag = NULL"); |
||||
migrationBuilder.Sql("UPDATE EmbyShow SET Etag = NULL"); |
||||
migrationBuilder.Sql("UPDATE EmbySeason SET Etag = NULL"); |
||||
migrationBuilder.Sql("UPDATE EmbyEpisode SET Etag = NULL"); |
||||
migrationBuilder.Sql( |
||||
@"UPDATE Library SET LastScan = '0001-01-01 00:00:00' WHERE Id IN (SELECT Id FROM EmbyLibrary)"); |
||||
|
||||
migrationBuilder.Sql("UPDATE JellyfinMovie SET Etag = NULL"); |
||||
migrationBuilder.Sql("UPDATE JellyfinShow SET Etag = NULL"); |
||||
migrationBuilder.Sql("UPDATE JellyfinSeason SET Etag = NULL"); |
||||
migrationBuilder.Sql("UPDATE JellyfinEpisode SET Etag = NULL"); |
||||
migrationBuilder.Sql( |
||||
@"UPDATE Library SET LastScan = '0001-01-01 00:00:00' WHERE Id IN (SELECT Id FROM JellyfinLibrary)"); |
||||
|
||||
migrationBuilder.Sql("UPDATE PlexMovie SET Etag = NULL"); |
||||
migrationBuilder.Sql("UPDATE PlexShow SET Etag = NULL"); |
||||
migrationBuilder.Sql("UPDATE PlexSeason SET Etag = NULL"); |
||||
migrationBuilder.Sql("UPDATE PlexEpisode SET Etag = NULL"); |
||||
migrationBuilder.Sql( |
||||
@"UPDATE Library SET LastScan = '0001-01-01 00:00:00' WHERE Id IN (SELECT Id FROM PlexLibrary)"); |
||||
} |
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder) |
||||
{ |
||||
|
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue