mirror of
https://github.com/Radarr/Radarr.git
synced 2024-06-30 17:43:59 +02:00
Compare commits
6 Commits
e60933900a
...
24c4ba6f02
Author | SHA1 | Date | |
---|---|---|---|
|
24c4ba6f02 | ||
|
5fc63ecb3f | ||
|
12f8312eec | ||
|
467ff799fc | ||
|
2b1838517c | ||
|
5f03093b38 |
|
@ -153,7 +153,11 @@ public IEnumerable<string> GetDirectories(string path)
|
|||
{
|
||||
Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);
|
||||
|
||||
return Directory.EnumerateDirectories(path);
|
||||
return Directory.EnumerateDirectories(path, "*", new EnumerationOptions
|
||||
{
|
||||
AttributesToSkip = FileAttributes.System,
|
||||
IgnoreInaccessible = true
|
||||
});
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetFiles(string path, bool recursive)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Languages;
|
||||
|
@ -23,6 +24,11 @@ public class MovieLookupController : RestController<MovieResource>
|
|||
private readonly IMapCoversToLocal _coverMapper;
|
||||
private readonly IConfigService _configService;
|
||||
|
||||
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 MovieLookupController(ISearchForNewMovie searchProxy,
|
||||
IProvideMovieInfo movieInfo,
|
||||
IBuildFileNames fileNameBuilder,
|
||||
|
@ -71,11 +77,29 @@ public object SearchByImdbId(string imdbId)
|
|||
[HttpGet]
|
||||
public object Search([FromQuery] string term)
|
||||
{
|
||||
var searchResults = _searchProxy.SearchForNewMovie(term);
|
||||
var convertedTerm = ConvertDbLinkToId(term);
|
||||
var searchResults = _searchProxy.SearchForNewMovie(convertedTerm);
|
||||
|
||||
return MapToResource(searchResults);
|
||||
}
|
||||
|
||||
private string 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;
|
||||
}
|
||||
|
||||
private IEnumerable<MovieResource> MapToResource(IEnumerable<Movie> movies)
|
||||
{
|
||||
var movieInfoLanguage = (Language)_configService.MovieInfoLanguage;
|
||||
|
|
Loading…
Reference in New Issue
Block a user