Browse Source

case-insensitive file extensions in local scanner (#1197)

pull/1198/head
Jason Dove 3 years ago committed by GitHub
parent
commit
dfc36b4581
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 45
      ErsatzTV.Scanner.Tests/Core/Metadata/MovieFolderScannerTests.cs
  3. 10
      ErsatzTV.Scanner/Core/Metadata/LocalFolderScanner.cs

4
CHANGELOG.md

@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Note that these subtitles are not currently supported in ETV, but they did cause a playback issue - Note that these subtitles are not currently supported in ETV, but they did cause a playback issue
- Fix Jellyfin, Emby and Plex library scans that wouldn't work in certain timezones - Fix Jellyfin, Emby and Plex library scans that wouldn't work in certain timezones
### Changed
- Ignore case of video and audio file extensions in local folder scanner
- For example, the scanner will now find `movie.MKV` as well as `movie.mkv` on case-sensitive filesystems
## [0.7.5-beta] - 2023-03-05 ## [0.7.5-beta] - 2023-03-05
### Added ### Added
- Use AV1 hardware-accelerated decoder with VAAPI, QSV, NVIDIA when available - Use AV1 hardware-accelerated decoder with VAAPI, QSV, NVIDIA when available

45
ErsatzTV.Scanner.Tests/Core/Metadata/MovieFolderScannerTests.cs

@ -121,6 +121,51 @@ public class MovieFolderScannerTests
It.Is<Movie>(i => i.MediaVersions.Head().MediaFiles.Head().Path == moviePath)), It.Is<Movie>(i => i.MediaVersions.Head().MediaFiles.Head().Path == moviePath)),
Times.Once); Times.Once);
} }
[Test]
public async Task NewMovie_Statistics_And_FallbackMetadata_MixedCase(
[ValueSource(typeof(LocalFolderScanner), nameof(LocalFolderScanner.VideoFileExtensions))]
string videoExtension)
{
char[] mixedCaseExtension = videoExtension.ToLowerInvariant().ToArray();
mixedCaseExtension[2] = char.ToUpper(mixedCaseExtension[2]);
videoExtension = new string(mixedCaseExtension);
string moviePath = Path.Combine(
FakeRoot,
Path.Combine("Movie (2020)", $"Movie (2020){videoExtension}"));
MovieFolderScanner service = GetService(
new FakeFileEntry(moviePath) { LastWriteTime = DateTime.Now }
);
var libraryPath = new LibraryPath
{ Id = 1, Path = FakeRoot, LibraryFolders = new List<LibraryFolder>() };
Either<BaseError, Unit> result = await service.ScanFolder(
libraryPath,
FFmpegPath,
FFprobePath,
0,
1,
CancellationToken.None);
result.IsRight.Should().BeTrue();
_movieRepository.Verify(x => x.GetOrAdd(It.IsAny<LibraryPath>(), It.IsAny<string>()), Times.Once);
_movieRepository.Verify(x => x.GetOrAdd(libraryPath, moviePath), Times.Once);
_localStatisticsProvider.Verify(
x => x.RefreshStatistics(
FFmpegPath,
FFprobePath,
It.Is<Movie>(i => i.MediaVersions.Head().MediaFiles.Head().Path == moviePath)),
Times.Once);
_localMetadataProvider.Verify(
x => x.RefreshFallbackMetadata(
It.Is<Movie>(i => i.MediaVersions.Head().MediaFiles.Head().Path == moviePath)),
Times.Once);
}
[Test] [Test]
public async Task NewMovie_Statistics_And_SidecarMetadata_MovieNameNfo( public async Task NewMovie_Statistics_And_SidecarMetadata_MovieNameNfo(

10
ErsatzTV.Scanner/Core/Metadata/LocalFolderScanner.cs

@ -22,24 +22,24 @@ public abstract class LocalFolderScanner
{ {
".mpg", ".mp2", ".mpeg", ".mpe", ".mpv", ".ogg", ".mp4", ".mpg", ".mp2", ".mpeg", ".mpe", ".mpv", ".ogg", ".mp4",
".m4p", ".m4v", ".avi", ".wmv", ".mov", ".mkv", ".ts", ".webm" ".m4p", ".m4v", ".avi", ".wmv", ".mov", ".mkv", ".ts", ".webm"
}.ToImmutableHashSet(); }.ToImmutableHashSet(StringComparer.OrdinalIgnoreCase);
public static readonly ImmutableHashSet<string> AudioFileExtensions = new[] public static readonly ImmutableHashSet<string> AudioFileExtensions = new[]
{ {
".aac", ".alac", ".dff", ".dsf", ".flac", ".mp3", ".m4a", ".ogg", ".opus", ".oga", ".ogx", ".spx", ".wav", ".aac", ".alac", ".dff", ".dsf", ".flac", ".mp3", ".m4a", ".ogg", ".opus", ".oga", ".ogx", ".spx", ".wav",
".wma" ".wma"
}.ToImmutableHashSet(); }.ToImmutableHashSet(StringComparer.OrdinalIgnoreCase);
public static readonly ImmutableHashSet<string> ImageFileExtensions = new[] public static readonly ImmutableHashSet<string> ImageFileExtensions = new[]
{ {
"jpg", "jpeg", "png", "gif", "tbn" "jpg", "jpeg", "png", "gif", "tbn"
}.ToImmutableHashSet(); }.ToImmutableHashSet(StringComparer.OrdinalIgnoreCase);
public static readonly ImmutableHashSet<string> ExtraFiles = new[] public static readonly ImmutableHashSet<string> ExtraFiles = new[]
{ {
"behindthescenes", "deleted", "featurette", "behindthescenes", "deleted", "featurette",
"interview", "scene", "short", "trailer", "other" "interview", "scene", "short", "trailer", "other"
}.ToImmutableHashSet(); }.ToImmutableHashSet(StringComparer.OrdinalIgnoreCase);
public static readonly ImmutableHashSet<string> ExtraDirectories = new List<string> public static readonly ImmutableHashSet<string> ExtraDirectories = new List<string>
{ {
@ -48,7 +48,7 @@ public abstract class LocalFolderScanner
"extras", "specials" "extras", "specials"
} }
.Map(s => $"{Path.DirectorySeparatorChar}{s}{Path.DirectorySeparatorChar}") .Map(s => $"{Path.DirectorySeparatorChar}{s}{Path.DirectorySeparatorChar}")
.ToImmutableHashSet(); .ToImmutableHashSet(StringComparer.OrdinalIgnoreCase);
private readonly IClient _client; private readonly IClient _client;
private readonly IFFmpegPngService _ffmpegPngService; private readonly IFFmpegPngService _ffmpegPngService;

Loading…
Cancel
Save