Browse Source

fix unicode song metadata on windows (#523)

* test setting utf8 encoding with ffprobe

* use utf8 encoding for console (logging) output

* use proper sink package

* reset song metadata on windows

* fix nfo processing with missing year

* update changelog
pull/524/head
Jason Dove 4 years ago committed by GitHub
parent
commit
35ba2bab2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CHANGELOG.md
  2. 8
      ErsatzTV.Core/Metadata/LocalMetadataProvider.cs
  3. 5
      ErsatzTV.Core/Metadata/LocalStatisticsProvider.cs
  4. 9
      ErsatzTV.Core/Metadata/Nfo/TvShowNfo.cs
  5. 3843
      ErsatzTV.Infrastructure/Migrations/20211201191945_Reset_SongMetadataOnWindows.Designer.cs
  6. 34
      ErsatzTV.Infrastructure/Migrations/20211201191945_Reset_SongMetadataOnWindows.cs
  7. 3
      ErsatzTV/Startup.cs
  8. BIN
      lib/Serilog.Sinks.SQLite.6.0.0.nupkg

3
CHANGELOG.md

@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Fixed
- Fix artwork upload on Windows
- Fix unicode song metadata on Windows
- Fix unicode console output on Windows
- Fix TV Show NFO metadata processing when `year` is missing
### Changed
- Use custom log database backend which should be more portable (i.e. work in osx-arm64)

8
ErsatzTV.Core/Metadata/LocalMetadataProvider.cs

@ -969,9 +969,9 @@ namespace ErsatzTV.Core.Metadata @@ -969,9 +969,9 @@ namespace ErsatzTV.Core.Metadata
}
}
private static int? GetYear(int year, string premiered)
private static int? GetYear(int? year, string premiered)
{
if (year > 1000)
if (year is > 1000)
{
return year;
}
@ -989,9 +989,9 @@ namespace ErsatzTV.Core.Metadata @@ -989,9 +989,9 @@ namespace ErsatzTV.Core.Metadata
return null;
}
private static DateTime? GetAired(int year, string aired)
private static DateTime? GetAired(int? year, string aired)
{
DateTime? fallback = year > 1000 ? new DateTime(year, 1, 1) : null;
DateTime? fallback = year is > 1000 ? new DateTime(year.Value, 1, 1) : null;
if (string.IsNullOrWhiteSpace(aired))
{

5
ErsatzTV.Core/Metadata/LocalStatisticsProvider.cs

@ -3,6 +3,7 @@ using System.Collections.Generic; @@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Extensions;
@ -141,7 +142,9 @@ namespace ErsatzTV.Core.Metadata @@ -141,7 +142,9 @@ namespace ErsatzTV.Core.Metadata
FileName = ffprobePath,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false
UseShellExecute = false,
StandardOutputEncoding = Encoding.UTF8,
StandardErrorEncoding = Encoding.UTF8
};
startInfo.ArgumentList.Add("-v");

9
ErsatzTV.Core/Metadata/Nfo/TvShowNfo.cs

@ -9,8 +9,15 @@ namespace ErsatzTV.Core.Metadata.Nfo @@ -9,8 +9,15 @@ namespace ErsatzTV.Core.Metadata.Nfo
[XmlElement("title")]
public string Title { get; set; }
[XmlIgnore]
public int? Year { get; set; }
[XmlElement("year")]
public int Year { get; set; }
public string YearAsText
{
get => Year.HasValue ? Year.ToString() : null;
set => Year = !string.IsNullOrWhiteSpace(value) ? int.Parse(value) : default(int?);
}
[XmlElement("plot")]
public string Plot { get; set; }

3843
ErsatzTV.Infrastructure/Migrations/20211201191945_Reset_SongMetadataOnWindows.Designer.cs generated

File diff suppressed because it is too large Load Diff

34
ErsatzTV.Infrastructure/Migrations/20211201191945_Reset_SongMetadataOnWindows.cs

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
using System.Runtime.InteropServices;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.Migrations
{
public partial class Reset_SongMetadataOnWindows : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
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 = 5)");
migrationBuilder.Sql(
@"UPDATE Library SET LastScan = '0001-01-01 00:00:00' WHERE MediaKind = 5");
migrationBuilder.Sql(
@"UPDATE SongMetadata SET DateUpdated = '0001-01-01 00:00:00'");
migrationBuilder.Sql(
@"UPDATE LibraryFolder SET Etag = NULL WHERE Id IN
(SELECT LF.Id FROM LibraryFolder LF INNER JOIN LibraryPath LP on LF.LibraryPathId = LP.Id INNER JOIN Library L on LP.LibraryId = L.Id WHERE MediaKind = 5)");
}
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

3
ErsatzTV/Startup.cs

@ -2,6 +2,7 @@ using System; @@ -2,6 +2,7 @@ using System;
using System.Data;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading.Channels;
using Blazored.LocalStorage;
using Dapper;
@ -120,6 +121,8 @@ namespace ErsatzTV @@ -120,6 +121,8 @@ namespace ErsatzTV
services.AddCourier(Assembly.GetAssembly(typeof(LibraryScanProgress)));
services.AddBlazoredLocalStorage();
Console.OutputEncoding = Encoding.UTF8;
Log.Logger.Information(
"ErsatzTV version {Version}",
Assembly.GetEntryAssembly()?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()

BIN
lib/Serilog.Sinks.SQLite.6.0.0.nupkg

Binary file not shown.
Loading…
Cancel
Save