mirror of
https://github.com/Radarr/Radarr
synced 2025-01-03 05:44:50 +00:00
New: Parse IMDB and TMDB URLs as search terms
This commit is contained in:
parent
ab13fb6e99
commit
beeb5204b8
2 changed files with 19 additions and 0 deletions
|
@ -23,6 +23,8 @@ public void Setup()
|
|||
// [TestCase("The Man from U.N.C.L.E.", "The Man from U.N.C.L.E.")]
|
||||
[TestCase("imdb:tt2527336", "Star Wars: The Last Jedi")]
|
||||
[TestCase("imdb:tt2798920", "Annihilation")]
|
||||
[TestCase("https://www.imdb.com/title/tt0033467/", "Citizen Kane")]
|
||||
[TestCase("https://www.themoviedb.org/movie/775-le-voyage-dans-la-lune", "A Trip to the Moon")]
|
||||
public void successful_search(string title, string expected)
|
||||
{
|
||||
var result = Subject.SearchForNewMovie(title);
|
||||
|
@ -41,6 +43,8 @@ public void successful_search(string title, string expected)
|
|||
[TestCase("tmdbid:1")]
|
||||
[TestCase("adjalkwdjkalwdjklawjdlKAJD;EF")]
|
||||
[TestCase("imdb: tt9805708")]
|
||||
[TestCase("https://www.UNKNOWN-DOMAIN.com/title/tt0033467/")]
|
||||
[TestCase("https://www.themoviedb.org/MALFORMED/775-le-voyage-dans-la-lune")]
|
||||
public void no_search_result(string term)
|
||||
{
|
||||
var result = Subject.SearchForNewMovie(term);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Cloud;
|
||||
|
@ -405,6 +406,20 @@ public List<Movie> SearchForNewMovie(string title)
|
|||
{
|
||||
try
|
||||
{
|
||||
var match = new Regex("^https://www.imdb.com/title/(tt[0-9]+).*?$").Match(title);
|
||||
if (match.Success)
|
||||
{
|
||||
title = "imdb:" + match.Groups[1].Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
match = new Regex("^https://www.themoviedb.org/movie/([0-9]+).*$").Match(title);
|
||||
if (match.Success)
|
||||
{
|
||||
title = "tmdb:" + match.Groups[1].Value;
|
||||
}
|
||||
}
|
||||
|
||||
var lowerTitle = title.ToLower();
|
||||
|
||||
lowerTitle = lowerTitle.Replace(".", "");
|
||||
|
|
Loading…
Reference in a new issue