1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Fixed: Subtitle extensions should be case-insensitive.

This commit is contained in:
Taloth Saldono 2017-06-25 18:23:32 +02:00
parent f46a576df5
commit 905ab18336
6 changed files with 21 additions and 17 deletions

View File

@ -104,7 +104,7 @@ public override MetadataFile FindMetadataFile(Series series, string path)
return metadata;
}
if (filename.Equals("tvshow.nfo", StringComparison.InvariantCultureIgnoreCase))
if (filename.Equals("tvshow.nfo", StringComparison.OrdinalIgnoreCase))
{
metadata.Type = MetadataType.SeriesMetadata;
return metadata;
@ -114,7 +114,7 @@ public override MetadataFile FindMetadataFile(Series series, string path)
if (parseResult != null &&
!parseResult.FullSeason &&
Path.GetExtension(filename) == ".nfo")
Path.GetExtension(filename).Equals(".nfo", StringComparison.OrdinalIgnoreCase))
{
metadata.Type = MetadataType.EpisodeMetadata;
return metadata;

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NLog;
@ -65,7 +66,7 @@ public override IEnumerable<ExtraFile> MoveFilesAfterRename(Series series, List<
public override ExtraFile Import(Series series, EpisodeFile episodeFile, string path, string extension, bool readOnly)
{
// 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";
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace NzbDrone.Core.Extras.Subtitles
{
@ -8,7 +9,7 @@ public static class SubtitleFileExtensions
static SubtitleFileExtensions()
{
_fileExtensions = new HashSet<string>
_fileExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
".aqt",
".ass",

View File

@ -135,7 +135,7 @@ public string[] GetVideoFiles(string path, bool allDirectories = true)
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
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();
_logger.Trace("{0} files were found in {1}", filesOnDisk.Count, path);
@ -150,7 +150,7 @@ public string[] GetNonVideoFiles(string path, bool allDirectories = true)
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
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();
_logger.Trace("{0} files were found in {1}", filesOnDisk.Count, path);
@ -184,7 +184,7 @@ private void SetPermissions(string path)
_logger.Warn(ex, "Unable to apply permissions to: " + path);
_logger.Debug(ex, ex.Message);
}
}
}
public void Handle(SeriesUpdatedEvent message)
{
@ -210,4 +210,4 @@ public void Execute(RescanSeriesCommand message)
}
}
}
}
}

View File

@ -1,14 +1,15 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles.EpisodeImport;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Download;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.MediaFiles
{
@ -101,7 +102,7 @@ public List<ImportResult> ProcessPath(string path, ImportMode importMode = Impor
public bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Series series)
{
var videoFiles = _diskScanService.GetVideoFiles(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 videoFile in videoFiles)
{

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using NzbDrone.Core.Qualities;
@ -10,7 +11,7 @@ public static class MediaFileExtensions
static MediaFileExtensions()
{
_fileExtensions = new Dictionary<string, Quality>
_fileExtensions = new Dictionary<string, Quality>(StringComparer.OrdinalIgnoreCase)
{
//Unknown
{ ".webm", Quality.Unknown },
@ -70,7 +71,7 @@ static MediaFileExtensions()
};
}
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)
{