mirror of
https://github.com/Radarr/Radarr
synced 2025-01-01 12:54:21 +00:00
fixed: return proper error when searching for invalid tvdb id.
This commit is contained in:
parent
46bf80dcd1
commit
d5da0ec4dd
2 changed files with 24 additions and 5 deletions
|
@ -44,10 +44,14 @@ public void successful_search(string title, string expected)
|
||||||
result[0].Title.Should().Be(expected);
|
result[0].Title.Should().Be(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[TestCase("tvdbid:")]
|
||||||
public void no_search_result()
|
[TestCase("tvdbid: 99999999999999999999")]
|
||||||
|
[TestCase("tvdbid: 0")]
|
||||||
|
[TestCase("tvdbid: -12")]
|
||||||
|
[TestCase("adjalkwdjkalwdjklawjdlKAJD;EF")]
|
||||||
|
public void no_search_result(string term)
|
||||||
{
|
{
|
||||||
var result = Subject.SearchForNewSeries(Guid.NewGuid().ToString());
|
var result = Subject.SearchForNewSeries(term);
|
||||||
result.Should().BeEmpty();
|
result.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
@ -37,12 +38,26 @@ public TvDbProxy(Logger logger)
|
||||||
|
|
||||||
int tvdbId;
|
int tvdbId;
|
||||||
|
|
||||||
if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || !Int32.TryParse(slug, out tvdbId))
|
if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || !Int32.TryParse(slug, out tvdbId) || tvdbId <= 0)
|
||||||
{
|
{
|
||||||
return Enumerable.Empty<TVDBSharp.Models.Show>();
|
return Enumerable.Empty<TVDBSharp.Models.Show>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new[] { _tvdb.GetShow(tvdbId) };
|
try
|
||||||
|
{
|
||||||
|
return new[] { _tvdb.GetShow(tvdbId) };
|
||||||
|
}
|
||||||
|
catch (WebException ex)
|
||||||
|
{
|
||||||
|
var resp = ex.Response as HttpWebResponse;
|
||||||
|
|
||||||
|
if (resp != null && resp.StatusCode == HttpStatusCode.NotFound)
|
||||||
|
{
|
||||||
|
return Enumerable.Empty<TVDBSharp.Models.Show>();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _tvdb.Search(GetSearchTerm(lowerTitle), 10);
|
return _tvdb.Search(GetSearchTerm(lowerTitle), 10);
|
||||||
|
|
Loading…
Reference in a new issue