mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-18 16:29:41 +02:00
parent
99b75a3089
commit
88ec106ec6
@ -162,6 +162,7 @@ public void should_parse_imdb_in_title(string postTitle, string imdb)
|
||||
parsed.ImdbId.Should().Be(imdb);
|
||||
}
|
||||
|
||||
[TestCase("asfd", null)]
|
||||
[TestCase("123", "tt0000123")]
|
||||
[TestCase("1234567", "tt1234567")]
|
||||
[TestCase("tt1234567", "tt1234567")]
|
||||
|
@ -125,6 +125,13 @@ public List<Movie> GetBulkMovieInfo(List<int> tmdbIds)
|
||||
|
||||
public Movie GetMovieByImdbId(string imdbId)
|
||||
{
|
||||
imdbId = Parser.Parser.NormalizeImdbId(imdbId);
|
||||
|
||||
if (imdbId == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var httpRequest = _radarrMetadata.Create()
|
||||
.SetSegment("route", "movie/imdb")
|
||||
.Resource(imdbId.ToString())
|
||||
|
@ -357,6 +357,13 @@ public static string ReplaceGermanUmlauts(string s)
|
||||
|
||||
public static string NormalizeImdbId(string imdbId)
|
||||
{
|
||||
var imdbRegex = new Regex(@"^(\d{1,10}|(tt)\d{1,10})$");
|
||||
|
||||
if (!imdbRegex.IsMatch(imdbId))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (imdbId.Length > 2)
|
||||
{
|
||||
imdbId = imdbId.Replace("tt", "").PadLeft(7, '0');
|
||||
|
Loading…
Reference in New Issue
Block a user