Browse Source

read track from music video nfo metadata (#799)

pull/800/head
Jason Dove 4 years ago committed by GitHub
parent
commit
47252b1243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 1
      ErsatzTV.Core.Tests/Metadata/Nfo/MusicVideoNfoReaderTests.cs
  3. 1
      ErsatzTV.Core/Domain/Metadata/MusicVideoMetadata.cs
  4. 2
      ErsatzTV.Core/Metadata/LocalMetadataProvider.cs
  5. 3
      ErsatzTV.Core/Metadata/Nfo/MusicVideoNfo.cs
  6. 3
      ErsatzTV.Core/Metadata/Nfo/MusicVideoNfoReader.cs
  7. 6
      ErsatzTV.Core/Scheduling/ChronologicalMediaComparer.cs
  8. 4288
      ErsatzTV.Infrastructure/Migrations/20220512172811_Add_MusicVideoMetadata_Track.Designer.cs
  9. 25
      ErsatzTV.Infrastructure/Migrations/20220512172811_Add_MusicVideoMetadata_Track.cs
  10. 3
      ErsatzTV.Infrastructure/Migrations/TvContextModelSnapshot.cs

1
CHANGELOG.md

@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add global setting to skip missing (file-not-found or unavailable) items when building playouts - Add global setting to skip missing (file-not-found or unavailable) items when building playouts
- Add filler preset option to allow watermarks to overlay on top of filler (disabled by default) - Add filler preset option to allow watermarks to overlay on top of filler (disabled by default)
- This option is applied when new items are added to a playout; rebuilding is needed if you want the change to take effect immediately - This option is applied when new items are added to a playout; rebuilding is needed if you want the change to take effect immediately
- Read `track` field from music video NFO metadata and use it for chronological sorting (after release date)
### Changed ### Changed
- Replace invalid (control) characters in NFO metadata with replacement character `<EFBFBD>` before parsing - Replace invalid (control) characters in NFO metadata with replacement character `<EFBFBD>` before parsing

1
ErsatzTV.Core.Tests/Metadata/Nfo/MusicVideoNfoReaderTests.cs

@ -129,6 +129,7 @@ Le groupe a également enregistré une version espagnole de ce titre, La reina d
nfo.Year.Should().Be(1976); nfo.Year.Should().Be(1976);
nfo.Aired.IsNone.Should().BeTrue(); nfo.Aired.IsNone.Should().BeTrue();
nfo.Genres.Should().BeEquivalentTo(new List<string> { "Pop" }); nfo.Genres.Should().BeEquivalentTo(new List<string> { "Pop" });
nfo.Track.Should().Be(-1);
} }
} }

1
ErsatzTV.Core/Domain/Metadata/MusicVideoMetadata.cs

@ -4,6 +4,7 @@ public class MusicVideoMetadata : Metadata
{ {
public string Album { get; set; } public string Album { get; set; }
public string Plot { get; set; } public string Plot { get; set; }
public int? Track { get; set; }
public int MusicVideoId { get; set; } public int MusicVideoId { get; set; }
public MusicVideo MusicVideo { get; set; } public MusicVideo MusicVideo { get; set; }
public List<MusicVideoArtist> Artists { get; set; } public List<MusicVideoArtist> Artists { get; set; }

2
ErsatzTV.Core/Metadata/LocalMetadataProvider.cs

@ -250,6 +250,7 @@ public class LocalMetadataProvider : ILocalMetadataProvider
Album = nfo.Album, Album = nfo.Album,
Title = nfo.Title, Title = nfo.Title,
Plot = nfo.Plot, Plot = nfo.Plot,
Track = nfo.Track,
Year = GetYear(nfo.Year, nfo.Aired), Year = GetYear(nfo.Year, nfo.Aired),
ReleaseDate = GetAired(nfo.Year, nfo.Aired), ReleaseDate = GetAired(nfo.Year, nfo.Aired),
Artists = nfo.Artists.Map(a => new MusicVideoArtist { Name = a }).ToList(), Artists = nfo.Artists.Map(a => new MusicVideoArtist { Name = a }).ToList(),
@ -764,6 +765,7 @@ public class LocalMetadataProvider : ILocalMetadataProvider
existing.Title = metadata.Title; existing.Title = metadata.Title;
existing.Year = metadata.Year; existing.Year = metadata.Year;
existing.Plot = metadata.Plot; existing.Plot = metadata.Plot;
existing.Track = metadata.Track;
existing.Album = metadata.Album; existing.Album = metadata.Album;
if (existing.DateAdded == SystemTime.MinValueUtc) if (existing.DateAdded == SystemTime.MinValueUtc)

3
ErsatzTV.Core/Metadata/Nfo/MusicVideoNfo.cs

@ -17,6 +17,9 @@ public class MusicVideoNfo
[XmlElement("plot")] [XmlElement("plot")]
public string Plot { get; set; } public string Plot { get; set; }
[XmlElement("track")]
public int Track { get; set; }
[XmlElement("aired")] [XmlElement("aired")]
public Option<DateTime> Aired { get; set; } public Option<DateTime> Aired { get; set; }

3
ErsatzTV.Core/Metadata/Nfo/MusicVideoNfoReader.cs

@ -72,6 +72,9 @@ public class MusicVideoNfoReader : NfoReader<MusicVideoNfo>, IMusicVideoNfoReade
case "plot": case "plot":
await ReadStringContent(reader, nfo, (musicVideo, plot) => musicVideo.Plot = plot); await ReadStringContent(reader, nfo, (musicVideo, plot) => musicVideo.Plot = plot);
break; break;
case "track":
await ReadIntContent(reader, nfo, (musicVideo, track) => musicVideo.Track = track);
break;
case "year": case "year":
await ReadIntContent(reader, nfo, (musicVideo, year) => musicVideo.Year = year); await ReadIntContent(reader, nfo, (musicVideo, year) => musicVideo.Year = year);
break; break;

6
ErsatzTV.Core/Scheduling/ChronologicalMediaComparer.cs

@ -119,12 +119,18 @@ internal class ChronologicalMediaComparer : IComparer<MediaItem>
string track1 = x switch string track1 = x switch
{ {
Song s => s.SongMetadata.HeadOrNone().Match(sm => sm.Track ?? string.Empty, () => string.Empty), Song s => s.SongMetadata.HeadOrNone().Match(sm => sm.Track ?? string.Empty, () => string.Empty),
MusicVideo mv => mv.MusicVideoMetadata.HeadOrNone()
.Match(mvm => mvm.Track ?? int.MaxValue, () => int.MaxValue)
.ToString("D10"),
_ => string.Empty _ => string.Empty
}; };
string track2 = y switch string track2 = y switch
{ {
Song s => s.SongMetadata.HeadOrNone().Match(sm => sm.Track ?? string.Empty, () => string.Empty), Song s => s.SongMetadata.HeadOrNone().Match(sm => sm.Track ?? string.Empty, () => string.Empty),
MusicVideo mv => mv.MusicVideoMetadata.HeadOrNone()
.Match(mvm => mvm.Track ?? int.MaxValue, () => int.MaxValue)
.ToString("D10"),
_ => string.Empty _ => string.Empty
}; };

4288
ErsatzTV.Infrastructure/Migrations/20220512172811_Add_MusicVideoMetadata_Track.Designer.cs generated

File diff suppressed because it is too large Load Diff

25
ErsatzTV.Infrastructure/Migrations/20220512172811_Add_MusicVideoMetadata_Track.cs

@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.Migrations
{
public partial class Add_MusicVideoMetadata_Track : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "Track",
table: "MusicVideoMetadata",
type: "INTEGER",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Track",
table: "MusicVideoMetadata");
}
}
}

3
ErsatzTV.Infrastructure/Migrations/TvContextModelSnapshot.cs

@ -1288,6 +1288,9 @@ namespace ErsatzTV.Infrastructure.Migrations
b.Property<string>("Title") b.Property<string>("Title")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int?>("Track")
.HasColumnType("INTEGER");
b.Property<int?>("Year") b.Property<int?>("Year")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");

Loading…
Cancel
Save