Browse Source

update subtitle titles (#2605)

pull/2606/head
Jason Dove 2 months ago committed by GitHub
parent
commit
d87561d140
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      CHANGELOG.md
  2. 6864
      ErsatzTV.Infrastructure.MySql/Migrations/20251106120601_Update_SubtitleTitle.Designer.cs
  3. 27
      ErsatzTV.Infrastructure.MySql/Migrations/20251106120601_Update_SubtitleTitle.cs
  4. 6691
      ErsatzTV.Infrastructure.Sqlite/Migrations/20251106120837_Update_SubtitleTitle.Designer.cs
  5. 35
      ErsatzTV.Infrastructure.Sqlite/Migrations/20251106120837_Update_SubtitleTitle.cs

2
CHANGELOG.md

@ -36,7 +36,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -36,7 +36,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Deep scans will be required to update subtitle titles on existing media items
- Fix saving subtitle title changes to the database
- This fixes e.g. where stream selection would continue to use the original title
- This applies to all libraries (local and media server) and may require deep scans to fix
- This fix applies to all libraries (local and media server)
### Changed
- Use smaller batch size for search index updates (100, down from 1000)

6864
ErsatzTV.Infrastructure.MySql/Migrations/20251106120601_Update_SubtitleTitle.Designer.cs generated

File diff suppressed because it is too large Load Diff

27
ErsatzTV.Infrastructure.MySql/Migrations/20251106120601_Update_SubtitleTitle.cs

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.MySql.Migrations
{
/// <inheritdoc />
public partial class Update_SubtitleTitle : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(
@"UPDATE Subtitle s
INNER JOIN EpisodeMetadata em ON em.Id = s.EpisodeMetadataId
INNER JOIN MediaVersion mv ON mv.EpisodeId = em.EpisodeId
INNER JOIN MediaStream ms ON ms.MediaVersionId = mv.Id AND ms.MediaStreamKind = 3 AND ms.`Index` = s.StreamIndex
SET s.Title = ms.Title
WHERE s.Title != ms.Title;");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

6691
ErsatzTV.Infrastructure.Sqlite/Migrations/20251106120837_Update_SubtitleTitle.Designer.cs generated

File diff suppressed because it is too large Load Diff

35
ErsatzTV.Infrastructure.Sqlite/Migrations/20251106120837_Update_SubtitleTitle.cs

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.Sqlite.Migrations
{
/// <inheritdoc />
public partial class Update_SubtitleTitle : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(
@"WITH Match AS (
SELECT s.Id AS SubtitleId, ms.Title AS NewTitle
FROM Subtitle AS s
JOIN EpisodeMetadata AS em ON em.Id = s.EpisodeMetadataId
JOIN MediaVersion AS mv ON mv.EpisodeId = em.EpisodeId
JOIN MediaStream AS ms ON ms.MediaVersionId = mv.Id
WHERE ms.MediaStreamKind = 3
AND ms.`Index` = s.StreamIndex
AND s.Title != ms.Title
)
UPDATE Subtitle
SET Title = (SELECT NewTitle FROM Match WHERE Match.SubtitleId = Subtitle.Id)
WHERE Id IN (SELECT SubtitleId FROM Match);
");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
Loading…
Cancel
Save