Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: if search results empty, use GetMovieByImdbId #9810

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
21 changes: 20 additions & 1 deletion src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,27 @@ public List<Movie> SearchForNewMovie(string title)
request.SuppressHttpError = true;

var httpResponse = _httpClient.Get<List<MovieResource>>(request);
var output = httpResponse.Resource.SelectList(MapSearchResult);

return httpResponse.Resource.SelectList(MapSearchResult);
// if output is zero and format is ttXXXXXXXX, use GetMovieByImdbId
if (output.Count == 0 && title.Length == 10 && title.StartsWith("tt"))
{
var imdbid = title;
try
{
var movieLookup = GetMovieByImdbId(imdbid);
return new List<Movie>
{
new Movie { MovieMetadata = movieLookup }
};
}
catch (MovieNotFoundException)
{
return new List<Movie>();
}
}

return output;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sounds good.

Just like #9754, I would rather prefer for this to happen in the MovieLookupController.

We like documented code, but that comment can be removed. output is somewhat confusing, and I think we should check if StartsWith("tt") and ^tt\d{7,8}$.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok got it. i'll edit it
thank you for the review

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need advise,
should i move the main logic to SkyHookProxy.cs ?

}
catch (HttpException ex)
{
Expand Down