Browse Source

fix movie fallback metadata titles (#305)

pull/306/head
Jason Dove 5 years ago committed by GitHub
parent
commit
7a06ac71e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 25
      ErsatzTV.Core.Tests/Metadata/FallbackMetadataProviderTests.cs
  3. 2
      ErsatzTV.Core/Metadata/FallbackMetadataProvider.cs
  4. 2979
      ErsatzTV.Infrastructure/Migrations/20210714005550_Fix_MovieFallbackMetadataTitle.Designer.cs
  5. 17
      ErsatzTV.Infrastructure/Migrations/20210714005550_Fix_MovieFallbackMetadataTitle.cs

1
CHANGELOG.md

@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Fixed
- Fix bug preventing ingestion of local movies with fallback metadata (without NFO files)
- Fix extra spaces in titles of local movies with fallback metadata (without NFO files)
## [0.0.49-prealpha] - 2021-07-11
### Added

25
ErsatzTV.Core.Tests/Metadata/FallbackMetadataProviderTests.cs

@ -93,5 +93,30 @@ namespace ErsatzTV.Core.Tests.Metadata @@ -93,5 +93,30 @@ namespace ErsatzTV.Core.Tests.Metadata
metadata.Count.Should().Be(2);
metadata.Map(m => m.EpisodeNumber).Should().BeEquivalentTo(episode1, episode2);
}
[Test]
[TestCase("Something (2021).mkv", "Something")]
[TestCase("Something Else (2021).mkv", "Something Else")]
public void GetFallbackMetadata_Should_Set_Proper_Movie_Title(string path, string expectedTitle)
{
MovieMetadata metadata = _fallbackMetadataProvider.GetFallbackMetadata(
new Movie
{
LibraryPath = new LibraryPath(),
MediaVersions = new List<MediaVersion>
{
new()
{
MediaFiles = new List<MediaFile>
{
new() { Path = path }
}
}
}
});
metadata.Should().NotBeNull();
metadata.Title.Should().Be(expectedTitle);
}
}
}

2
ErsatzTV.Core/Metadata/FallbackMetadataProvider.cs

@ -161,7 +161,7 @@ namespace ErsatzTV.Core.Metadata @@ -161,7 +161,7 @@ namespace ErsatzTV.Core.Metadata
Match match = Regex.Match(fileName, PATTERN);
if (match.Success)
{
metadata.Title = match.Groups[1].Value;
metadata.Title = match.Groups[1].Value.Trim();
metadata.Year = int.Parse(match.Groups[2].Value);
metadata.ReleaseDate = new DateTime(int.Parse(match.Groups[2].Value), 1, 1);
metadata.Genres = new List<Genre>();

2979
ErsatzTV.Infrastructure/Migrations/20210714005550_Fix_MovieFallbackMetadataTitle.Designer.cs generated

File diff suppressed because it is too large Load Diff

17
ErsatzTV.Infrastructure/Migrations/20210714005550_Fix_MovieFallbackMetadataTitle.cs

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace ErsatzTV.Infrastructure.Migrations
{
public partial class Fix_MovieFallbackMetadataTitle : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(
"UPDATE MovieMetadata SET Title = TRIM(Title), SortTitle = TRIM(SortTitle) WHERE MetadataKind = 0");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
Loading…
Cancel
Save