mirror of https://github.com/Sonarr/Sonarr
Fixed: Extensions are now removed from scene names during import.
This commit is contained in:
parent
92f73900ef
commit
cc8c88e921
|
@ -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;
|
||||||
|
@ -139,7 +140,6 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
Times.Never());
|
Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_use_nzb_title_as_scene_name()
|
public void should_use_nzb_title_as_scene_name()
|
||||||
{
|
{
|
||||||
|
@ -150,6 +150,19 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<EpisodeFile>(c => c.SceneName == _downloadClientItem.Title)));
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<EpisodeFile>(c => c.SceneName == _downloadClientItem.Title)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(".mkv")]
|
||||||
|
[TestCase(".par2")]
|
||||||
|
[TestCase(".nzb")]
|
||||||
|
public void should_remove_extension_from_nzb_title_for_scene_name(String extension)
|
||||||
|
{
|
||||||
|
var title = "malcolm.in.the.middle.s02e05.dvdrip.xvid-ingot";
|
||||||
|
|
||||||
|
_downloadClientItem.Title = title + extension;
|
||||||
|
|
||||||
|
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
|
||||||
|
|
||||||
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<EpisodeFile>(c => c.SceneName == title)));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_use_nzb_title_as_scene_name_if_full_season()
|
public void should_not_use_nzb_title_as_scene_name_if_full_season()
|
||||||
|
@ -165,7 +178,6 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
[Test]
|
[Test]
|
||||||
public void should_use_file_name_as_scenename_only_if_it_looks_like_scenename()
|
public void should_use_file_name_as_scenename_only_if_it_looks_like_scenename()
|
||||||
{
|
{
|
||||||
|
|
||||||
_approvedDecisions.First().LocalEpisode.Path = "c:\\tv\\malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv".AsOsAgnostic();
|
_approvedDecisions.First().LocalEpisode.Path = "c:\\tv\\malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv".AsOsAgnostic();
|
||||||
|
|
||||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
|
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
|
||||||
|
@ -183,8 +195,6 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<EpisodeFile>(c => c.SceneName == null)));
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<EpisodeFile>(c => c.SceneName == null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_import_larger_files_first()
|
public void should_import_larger_files_first()
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,11 +129,13 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
|
||||||
{
|
{
|
||||||
if (downloadClientItem != null)
|
if (downloadClientItem != null)
|
||||||
{
|
{
|
||||||
var parsedTitle = Parser.Parser.ParseTitle(downloadClientItem.Title);
|
var title = Parser.Parser.RemoveFileExtension(downloadClientItem.Title);
|
||||||
|
|
||||||
|
var parsedTitle = Parser.Parser.ParseTitle(title);
|
||||||
|
|
||||||
if (parsedTitle != null && !parsedTitle.FullSeason)
|
if (parsedTitle != null && !parsedTitle.FullSeason)
|
||||||
{
|
{
|
||||||
return downloadClientItem.Title;
|
return title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,8 @@ namespace NzbDrone.Core.Parser
|
||||||
{
|
{
|
||||||
if (!title.ContainsInvalidPathChars())
|
if (!title.ContainsInvalidPathChars())
|
||||||
{
|
{
|
||||||
if (MediaFiles.MediaFileExtensions.Extensions.Contains(Path.GetExtension(title).ToLower()))
|
var extension = Path.GetExtension(title).ToLower();
|
||||||
|
if (MediaFiles.MediaFileExtensions.Extensions.Contains(extension) || new [] { ".par2", ".nzb" }.Contains(extension))
|
||||||
{
|
{
|
||||||
title = Path.Combine(Path.GetDirectoryName(title), Path.GetFileNameWithoutExtension(title));
|
title = Path.Combine(Path.GetDirectoryName(title), Path.GetFileNameWithoutExtension(title));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue