Skip to content

Commit

Permalink
search movies with imdb/tmdb links
Browse files Browse the repository at this point in the history
  • Loading branch information
HamletDuFromage committed Feb 9, 2024
1 parent 34cfb58 commit 5f03093
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public class SkyHookProxy : IProvideMovieInfo, ISearchForNewMovie
private readonly IMovieMetadataService _movieMetadataService;
private readonly IMovieTranslationService _movieTranslationService;

private static readonly Regex ImdbIdRegex = new Regex(@"imdb\.com/title/(?<id>tt\d+)",
RegexOptions.Compiled);
private static readonly Regex TmdbIdRegex = new Regex(@"themoviedb\.org/movie/(?<id>\d+)",
RegexOptions.Compiled);

public SkyHookProxy(IHttpClient httpClient,
IRadarrCloudRequestBuilder requestBuilder,
IConfigService configService,
Expand Down Expand Up @@ -401,12 +406,31 @@ public MovieMetadata MapMovieToTmdbMovie(MovieMetadata movie)
}
}

private List<Movie> ConvertDbLinkToId(string title)
{
var match = ImdbIdRegex.Match(title);
if (match.Success)
{
return "imdb:" + match.Groups["id"].Value;
}

match = TmdbIdRegex.Match(title);
if (match.Success)
{
return "tmdb:" + match.Groups["id"].Value;
}

return title;
}

public List<Movie> SearchForNewMovie(string title)
{
try
{
var lowerTitle = title.ToLower();

lowerTitle = ConvertDbLinkToId(lowerTitle);

lowerTitle = lowerTitle.Replace(".", "");

var parserTitle = lowerTitle;
Expand Down

0 comments on commit 5f03093

Please sign in to comment.