mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-20 01:42:35 +01:00
search movies with imdb/tmdb links
This commit is contained in:
parent
34cfb58b39
commit
5f03093b38
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user