mirror of
https://github.com/Radarr/Radarr
synced 2025-02-25 23:53:14 +00:00
parent
99b75a3089
commit
88ec106ec6
3 changed files with 15 additions and 0 deletions
|
@ -162,6 +162,7 @@ public void should_parse_imdb_in_title(string postTitle, string imdb)
|
||||||
parsed.ImdbId.Should().Be(imdb);
|
parsed.ImdbId.Should().Be(imdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase("asfd", null)]
|
||||||
[TestCase("123", "tt0000123")]
|
[TestCase("123", "tt0000123")]
|
||||||
[TestCase("1234567", "tt1234567")]
|
[TestCase("1234567", "tt1234567")]
|
||||||
[TestCase("tt1234567", "tt1234567")]
|
[TestCase("tt1234567", "tt1234567")]
|
||||||
|
|
|
@ -125,6 +125,13 @@ public List<Movie> GetBulkMovieInfo(List<int> tmdbIds)
|
||||||
|
|
||||||
public Movie GetMovieByImdbId(string imdbId)
|
public Movie GetMovieByImdbId(string imdbId)
|
||||||
{
|
{
|
||||||
|
imdbId = Parser.Parser.NormalizeImdbId(imdbId);
|
||||||
|
|
||||||
|
if (imdbId == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var httpRequest = _radarrMetadata.Create()
|
var httpRequest = _radarrMetadata.Create()
|
||||||
.SetSegment("route", "movie/imdb")
|
.SetSegment("route", "movie/imdb")
|
||||||
.Resource(imdbId.ToString())
|
.Resource(imdbId.ToString())
|
||||||
|
|
|
@ -357,6 +357,13 @@ public static string ReplaceGermanUmlauts(string s)
|
||||||
|
|
||||||
public static string NormalizeImdbId(string imdbId)
|
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)
|
if (imdbId.Length > 2)
|
||||||
{
|
{
|
||||||
imdbId = imdbId.Replace("tt", "").PadLeft(7, '0');
|
imdbId = imdbId.Replace("tt", "").PadLeft(7, '0');
|
||||||
|
|
Loading…
Reference in a new issue