@ -2,11 +2,10 @@
using System.Collections.Generic ;
using System.Collections.Generic ;
using System.Linq ;
using System.Linq ;
using System.Net ;
using System.Net ;
using System.Text.RegularExpressions ;
using System.Web ;
using NLog ;
using NLog ;
using NzbDrone.Common.Extensions ;
using NzbDrone.Common.Extensions ;
using NzbDrone.Common.Http ;
using NzbDrone.Common.Http ;
using NzbDrone.Core.Exceptions ;
using NzbDrone.Core.MediaCover ;
using NzbDrone.Core.MediaCover ;
using NzbDrone.Core.MetadataSource.SkyHook.Resource ;
using NzbDrone.Core.MetadataSource.SkyHook.Resource ;
using NzbDrone.Core.Tv ;
using NzbDrone.Core.Tv ;
@ -31,8 +30,23 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
{
{
var httpRequest = _requestBuilder . Build ( tvdbSeriesId . ToString ( ) ) ;
var httpRequest = _requestBuilder . Build ( tvdbSeriesId . ToString ( ) ) ;
httpRequest . AddSegment ( "route" , "shows" ) ;
httpRequest . AddSegment ( "route" , "shows" ) ;
httpRequest . AllowAutoRedirect = true ;
httpRequest . SuppressHttpError = true ;
var httpResponse = _httpClient . Get < ShowResource > ( httpRequest ) ;
var httpResponse = _httpClient . Get < ShowResource > ( httpRequest ) ;
if ( httpResponse . HasHttpError )
{
if ( httpResponse . StatusCode = = HttpStatusCode . NotFound )
{
throw new SeriesNotFoundException ( tvdbSeriesId ) ;
}
else
{
throw new HttpException ( httpRequest , httpResponse ) ;
}
}
var episodes = httpResponse . Resource . Episodes . Select ( MapEpisode ) ;
var episodes = httpResponse . Resource . Episodes . Select ( MapEpisode ) ;
var series = MapSeries ( httpResponse . Resource ) ;
var series = MapSeries ( httpResponse . Resource ) ;
@ -71,7 +85,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
}
}
}
}
var term = HttpUtility. UrlEncode ( ( title . ToLower ( ) . Trim ( ) ) ) ;
var term = System. Web . HttpUtility. UrlEncode ( ( title . ToLower ( ) . Trim ( ) ) ) ;
var httpRequest = _requestBuilder . Build ( "?term={term}" ) ;
var httpRequest = _requestBuilder . Build ( "?term={term}" ) ;
httpRequest . AddSegment ( "route" , "search" ) ;
httpRequest . AddSegment ( "route" , "search" ) ;
httpRequest . AddSegment ( "term" , term ) ;
httpRequest . AddSegment ( "term" , term ) ;
@ -80,7 +94,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
return httpResponse . Resource . SelectList ( MapSeries ) ;
return httpResponse . Resource . SelectList ( MapSeries ) ;
}
}
catch ( Common. Http . HttpException)
catch ( HttpException)
{
{
throw new SkyHookException ( "Search for '{0}' failed. Unable to communicate with SkyHook." , title ) ;
throw new SkyHookException ( "Search for '{0}' failed. Unable to communicate with SkyHook." , title ) ;
}
}