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

This commit is contained in:
Jason Dove
2023-03-06 18:21:34 -06:00
committed by GitHub
parent c56e2526c4
commit dfc36b4581
3 changed files with 54 additions and 5 deletions
+4
View File
@@ -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
- 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
### Added
- Use AV1 hardware-accelerated decoder with VAAPI, QSV, NVIDIA when available
@@ -121,6 +121,51 @@ public class MovieFolderScannerTests
It.Is<Movie>(i => i.MediaVersions.Head().MediaFiles.Head().Path == moviePath)),
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]
public async Task NewMovie_Statistics_And_SidecarMetadata_MovieNameNfo(
@@ -22,24 +22,24 @@ public abstract class LocalFolderScanner
{
".mpg", ".mp2", ".mpeg", ".mpe", ".mpv", ".ogg", ".mp4",
".m4p", ".m4v", ".avi", ".wmv", ".mov", ".mkv", ".ts", ".webm"
}.ToImmutableHashSet();
}.ToImmutableHashSet(StringComparer.OrdinalIgnoreCase);
public static readonly ImmutableHashSet<string> AudioFileExtensions = new[]
{
".aac", ".alac", ".dff", ".dsf", ".flac", ".mp3", ".m4a", ".ogg", ".opus", ".oga", ".ogx", ".spx", ".wav",
".wma"
}.ToImmutableHashSet();
}.ToImmutableHashSet(StringComparer.OrdinalIgnoreCase);
public static readonly ImmutableHashSet<string> ImageFileExtensions = new[]
{
"jpg", "jpeg", "png", "gif", "tbn"
}.ToImmutableHashSet();
}.ToImmutableHashSet(StringComparer.OrdinalIgnoreCase);
public static readonly ImmutableHashSet<string> ExtraFiles = new[]
{
"behindthescenes", "deleted", "featurette",
"interview", "scene", "short", "trailer", "other"
}.ToImmutableHashSet();
}.ToImmutableHashSet(StringComparer.OrdinalIgnoreCase);
public static readonly ImmutableHashSet<string> ExtraDirectories = new List<string>
{
@@ -48,7 +48,7 @@ public abstract class LocalFolderScanner
"extras", "specials"
}
.Map(s => $"{Path.DirectorySeparatorChar}{s}{Path.DirectorySeparatorChar}")
.ToImmutableHashSet();
.ToImmutableHashSet(StringComparer.OrdinalIgnoreCase);
private readonly IClient _client;
private readonly IFFmpegPngService _ffmpegPngService;