1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-06-30 17:43:59 +02:00

search movies with imdb/tmdb links

This commit is contained in:
flb 2024-02-09 18:48:49 +01:00
parent 34cfb58b39
commit 5f03093b38

View File

@ -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,
@ -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;