fix movie fallback metadata titles (#305)

This commit is contained in:
Jason Dove
2021-07-13 20:15:52 -05:00
committed by GitHub
parent 3b9b8796b9
commit 7a06ac71e2
5 changed files with 3023 additions and 1 deletions
+1
View File
@@ -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
@@ -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);
}
}
}
@@ -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>();
File diff suppressed because it is too large Load Diff
@@ -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)
{
}
}
}