Special characters removed from titles

#ND-128 fixed
Fixed: Remove special characters from titles when searching
pull/4/head
Mark McDowall 12 years ago
parent 1596e8530f
commit e2cc4ef4ea

@ -56,5 +56,20 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests
Mocker.Resolve<TestSearch>().GetSearchTitle(_series, 5) Mocker.Resolve<TestSearch>().GetSearchTitle(_series, 5)
.Should().Be("Franklin and Bash"); .Should().Be("Franklin and Bash");
} }
[TestCase("Betty White's Off Their Rockers", "Betty Whites Off Their Rockers")]
[TestCase("Star Wars: The Clone Wars", "Star Wars The Clone Wars")]
[TestCase("Hawaii Five-0", "Hawaii Five-0")]
public void should_replace_some_special_characters(string input, string expected)
{
_series.Title = input;
Mocker.GetMock<SceneMappingProvider>()
.Setup(s => s.GetSceneName(_series.SeriesId))
.Returns("");
Mocker.Resolve<TestSearch>().GetSearchTitle(_series, 5)
.Should().Be(expected);
}
} }
} }

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using NLog; using NLog;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
@ -174,6 +175,7 @@ namespace NzbDrone.Core.Providers.Search
{ {
title = series.Title; title = series.Title;
title = title.Replace("&", "and"); title = title.Replace("&", "and");
title = Regex.Replace(title, @"[^\w\d\s\-]", "");
} }
return title; return title;

Loading…
Cancel
Save