1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-21 22:05:38 -04:00

fixed: return proper error when searching for invalid tvdb id.

This commit is contained in:
Keivan Beigi
2014-12-30 21:28:46 -08:00
parent 46bf80dcd1
commit d5da0ec4dd
2 changed files with 24 additions and 5 deletions
+17 -2
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Web;
using NLog;
@@ -37,12 +38,26 @@ namespace NzbDrone.Core.MetadataSource
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 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);