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

Fixed: Extensions are now removed from scene names during import.

This commit is contained in:
Taloth Saldono 2014-09-26 23:28:24 +02:00
parent 92f73900ef
commit cc8c88e921
3 changed files with 21 additions and 8 deletions

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -70,7 +71,7 @@ public void Setup()
_downloadClientItem = Builder<DownloadClientItem>.CreateNew().Build();
}
[Test]
public void should_not_import_any_if_there_are_no_approved_decisions()
{
@ -139,7 +140,6 @@ public void should_not_move_existing_files()
Times.Never());
}
[Test]
public void should_use_nzb_title_as_scene_name()
{
@ -150,6 +150,19 @@ public void should_use_nzb_title_as_scene_name()
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]
public void should_not_use_nzb_title_as_scene_name_if_full_season()
@ -165,7 +178,6 @@ public void should_not_use_nzb_title_as_scene_name_if_full_season()
[Test]
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();
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
@ -183,8 +195,6 @@ public void should_not_use_file_name_as_scenename_if_it_doesnt_looks_like_scenen
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<EpisodeFile>(c => c.SceneName == null)));
}
[Test]
public void should_import_larger_files_first()
{

View File

@ -129,11 +129,13 @@ private string GetSceneName(DownloadClientItem downloadClientItem, LocalEpisode
{
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)
{
return downloadClientItem.Title;
return title;
}
}

View File

@ -348,7 +348,8 @@ public static string RemoveFileExtension(string title)
{
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));
}