Fixed: Subtitle extensions should be case-insensitive.

pull/6/head
Qstick 7 years ago
parent 331bf5914a
commit 9a2cb67980

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace NzbDrone.Core.Extras.Lyrics namespace NzbDrone.Core.Extras.Lyrics
@ -8,7 +9,7 @@ namespace NzbDrone.Core.Extras.Lyrics
static LyricFileExtensions() static LyricFileExtensions()
{ {
_fileExtensions = new HashSet<string> _fileExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{ {
".lrc", ".lrc",
".txt", ".txt",

@ -103,13 +103,13 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
return metadata; return metadata;
} }
if (filename.Equals("artist.nfo", StringComparison.InvariantCultureIgnoreCase)) if (filename.Equals("artist.nfo", StringComparison.OrdinalIgnoreCase))
{ {
metadata.Type = MetadataType.ArtistMetadata; metadata.Type = MetadataType.ArtistMetadata;
return metadata; return metadata;
} }
if (filename.Equals("album.nfo", StringComparison.InvariantCultureIgnoreCase)) if (filename.Equals("album.nfo", StringComparison.OrdinalIgnoreCase))
{ {
metadata.Type = MetadataType.AlbumMetadata; metadata.Type = MetadataType.AlbumMetadata;
return metadata; return metadata;
@ -118,7 +118,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
var parseResult = Parser.Parser.ParseMusicTitle(filename); var parseResult = Parser.Parser.ParseMusicTitle(filename);
if (parseResult != null && if (parseResult != null &&
Path.GetExtension(filename) == ".nfo") Path.GetExtension(filename).Equals(".nfo", StringComparison.OrdinalIgnoreCase))
{ {
metadata.Type = MetadataType.TrackMetadata; metadata.Type = MetadataType.TrackMetadata;
return metadata; return metadata;

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -42,18 +43,18 @@ namespace NzbDrone.Core.Extras.Others
return Enumerable.Empty<ExtraFile>(); return Enumerable.Empty<ExtraFile>();
} }
public override IEnumerable<ExtraFile> MoveFilesAfterRename(Artist artist, List<TrackFile> episodeFiles) public override IEnumerable<ExtraFile> MoveFilesAfterRename(Artist artist, List<TrackFile> trackFiles)
{ {
var extraFiles = _otherExtraFileService.GetFilesByArtist(artist.Id); var extraFiles = _otherExtraFileService.GetFilesByArtist(artist.Id);
var movedFiles = new List<OtherExtraFile>(); var movedFiles = new List<OtherExtraFile>();
foreach (var episodeFile in episodeFiles) foreach (var trackFile in trackFiles)
{ {
var extraFilesForEpisodeFile = extraFiles.Where(m => m.TrackFileId == episodeFile.Id).ToList(); var extraFilesForTrackFile = extraFiles.Where(m => m.TrackFileId == trackFile.Id).ToList();
foreach (var extraFile in extraFilesForEpisodeFile) foreach (var extraFile in extraFilesForTrackFile)
{ {
movedFiles.AddIfNotNull(MoveFile(artist, episodeFile, extraFile)); movedFiles.AddIfNotNull(MoveFile(artist, trackFile, extraFile));
} }
} }
@ -65,7 +66,7 @@ namespace NzbDrone.Core.Extras.Others
public override ExtraFile Import(Artist artist, TrackFile trackFile, string path, string extension, bool readOnly) public override ExtraFile Import(Artist artist, TrackFile trackFile, string path, string extension, bool readOnly)
{ {
// If the extension is .nfo we need to change it to .nfo-orig // If the extension is .nfo we need to change it to .nfo-orig
if (Path.GetExtension(path).Equals(".nfo")) if (Path.GetExtension(path).Equals(".nfo", StringComparison.OrdinalIgnoreCase))
{ {
extension += "-orig"; extension += "-orig";
} }

@ -135,7 +135,7 @@ namespace NzbDrone.Core.MediaFiles
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
var filesOnDisk = _diskProvider.GetFiles(path, searchOption).ToList(); var filesOnDisk = _diskProvider.GetFiles(path, searchOption).ToList();
var mediaFileList = filesOnDisk.Where(file => MediaFileExtensions.Extensions.Contains(Path.GetExtension(file).ToLower())) var mediaFileList = filesOnDisk.Where(file => MediaFileExtensions.Extensions.Contains(Path.GetExtension(file)))
.ToList(); .ToList();
_logger.Trace("{0} files were found in {1}", filesOnDisk.Count, path); _logger.Trace("{0} files were found in {1}", filesOnDisk.Count, path);
@ -150,7 +150,7 @@ namespace NzbDrone.Core.MediaFiles
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
var filesOnDisk = _diskProvider.GetFiles(path, searchOption).ToList(); var filesOnDisk = _diskProvider.GetFiles(path, searchOption).ToList();
var mediaFileList = filesOnDisk.Where(file => !MediaFileExtensions.Extensions.Contains(Path.GetExtension(file).ToLower())) var mediaFileList = filesOnDisk.Where(file => !MediaFileExtensions.Extensions.Contains(Path.GetExtension(file)))
.ToList(); .ToList();
_logger.Trace("{0} files were found in {1}", filesOnDisk.Count, path); _logger.Trace("{0} files were found in {1}", filesOnDisk.Count, path);

@ -1,13 +1,14 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles.TrackImport; using NzbDrone.Core.MediaFiles.TrackImport;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.Download; using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles namespace NzbDrone.Core.MediaFiles
@ -98,7 +99,7 @@ namespace NzbDrone.Core.MediaFiles
public bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Artist artist) public bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Artist artist)
{ {
var audioFiles = _diskScanService.GetNonAudioFiles(directoryInfo.FullName); var audioFiles = _diskScanService.GetNonAudioFiles(directoryInfo.FullName);
var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f => Path.GetExtension(f) == ".rar"); var rarFiles = _diskProvider.GetFiles(directoryInfo.FullName, SearchOption.AllDirectories).Where(f => Path.GetExtension(f).Equals(".rar", StringComparison.OrdinalIgnoreCase));
foreach (var audioFile in audioFiles) foreach (var audioFile in audioFiles)
{ {

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
@ -10,7 +11,7 @@ namespace NzbDrone.Core.MediaFiles
static MediaFileExtensions() static MediaFileExtensions()
{ {
_fileExtensions = new Dictionary<string, Quality> _fileExtensions = new Dictionary<string, Quality>(StringComparer.OrdinalIgnoreCase)
{ {
{ ".mp3", Quality.Unknown }, { ".mp3", Quality.Unknown },
{ ".m4a", Quality.Unknown }, { ".m4a", Quality.Unknown },
@ -19,7 +20,7 @@ namespace NzbDrone.Core.MediaFiles
}; };
} }
public static HashSet<string> Extensions => new HashSet<string>(_fileExtensions.Keys); public static HashSet<string> Extensions => new HashSet<string>(_fileExtensions.Keys, StringComparer.OrdinalIgnoreCase);
public static Quality GetQualityForExtension(string extension) public static Quality GetQualityForExtension(string extension)
{ {

Loading…
Cancel
Save