merge other video folder tags with nfo tags (#1144)

This commit is contained in:
Jason Dove
2023-02-01 05:58:26 -06:00
committed by GitHub
parent 0a3db92c60
commit cacde26796
4 changed files with 4461 additions and 1 deletions
+3
View File
@@ -13,6 +13,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix playback of content with undefined colorspace
- Fix NVIDIA color normalization with VP9 sources
### Changed
- Merge generated `Other Video` folder tags with tags from sidecar NFO
## [0.7.3-beta] - 2023-01-25
### Added
- Attempt to release memory periodically
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class ResetOtherVideoMetadataTags : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("UPDATE OtherVideoMetadata SET DateUpdated = '0001-01-01 00:00:00' WHERE OtherVideoId IN (SELECT OtherVideoId FROM OtherVideoMetadata WHERE MetadataKind = 1)");
migrationBuilder.Sql("UPDATE LibraryFolder SET Etag = NULL WHERE Id IN (SELECT LF.Id FROM LibraryFolder LF INNER JOIN LibraryPath LP on LP.Id = LF.LibraryPathId INNER JOIN Library L on L.Id = LP.LibraryId WHERE MediaKind = 4)");
migrationBuilder.Sql("UPDATE LibraryPath SET LastScan = '0001-01-01 00:00:00' WHERE Id IN (SELECT LP.Id FROM LibraryPath LP INNER JOIN Library L on L.Id = LP.LibraryId WHERE MediaKind = 4)");
migrationBuilder.Sql("UPDATE Library SET LastScan = '0001-01-01 00:00:00' WHERE MediaKind = 4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
@@ -168,6 +168,25 @@ public class LocalMetadataProvider : ILocalMetadataProvider
Option<OtherVideoMetadata> maybeMetadata = await LoadOtherVideoMetadata(nfoFileName);
foreach (OtherVideoMetadata metadata in maybeMetadata)
{
// merge path-based tags with nfo tags
string? folder = Path.GetDirectoryName(nfoFileName);
if (folder != null)
{
string libraryPath = otherVideo.LibraryPath.Path;
string parent = Optional(Directory.GetParent(libraryPath)).Match(
di => di.FullName,
() => libraryPath);
string diff = Path.GetRelativePath(parent, folder);
var tags = diff.Split(Path.DirectorySeparatorChar)
.Filter(t => metadata.Tags.Any(mt => mt.Name == t) == false)
.Map(t => new Tag { Name = t })
.ToList();
metadata.Tags.AddRange(tags);
}
return await ApplyMetadataUpdate(otherVideo, metadata);
}