mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-22 22:15:17 -04:00
Add Ability to set RootFolderPath for Net Import List
Fixed other things. Finished command to automatically add a movie.
This commit is contained in:
@@ -27,7 +27,14 @@ namespace NzbDrone.Core.NetImport.CouchPotato
|
||||
urlBase = Settings.UrlBase.StartsWith("/") ? Settings.UrlBase : $"/{Settings.UrlBase}";
|
||||
}
|
||||
|
||||
var request = new NetImportRequest($"{Settings.Link.Trim()}:{Settings.Port}{urlBase}/api/{Settings.ApiKey}/movie.list/?status=active", HttpAccept.Json);
|
||||
var status = "";
|
||||
|
||||
if (Settings.OnlyActive)
|
||||
{
|
||||
status = "?status=active";
|
||||
}
|
||||
|
||||
var request = new NetImportRequest($"{Settings.Link.Trim()}:{Settings.Port}{urlBase}/api/{Settings.ApiKey}/movie.list/{status}", HttpAccept.Json);
|
||||
yield return request;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace NzbDrone.Core.NetImport.CouchPotato
|
||||
Link = "http://localhost";
|
||||
Port = 5050;
|
||||
UrlBase = "";
|
||||
OnlyActive = false;
|
||||
}
|
||||
|
||||
[FieldDefinition(0, Label = "CouchPotato URL", HelpText = "Link to your CoouchPootato.")]
|
||||
@@ -22,10 +23,16 @@ namespace NzbDrone.Core.NetImport.CouchPotato
|
||||
[FieldDefinition(1, Label = "CouchPotato Port", HelpText = "Port your CoouchPootato uses.")]
|
||||
public int Port { get; set; }
|
||||
|
||||
[FieldDefinition(2, Label = "CouchPotato Url Base", HelpText = "UrlBase your CoouchPootato uses, leave blank for none")]
|
||||
[FieldDefinition(2, Label = "CouchPotato Url Base",
|
||||
HelpText = "UrlBase your CoouchPootato uses, leave blank for none")]
|
||||
public string UrlBase { get; set; }
|
||||
|
||||
[FieldDefinition(3, Label = "CouchPotato API Key", HelpText = "CoouchPootato API Key.")]
|
||||
public string ApiKey { get; set; }
|
||||
|
||||
[FieldDefinition(4, Label = "Only Active", HelpText = "Should only active (not yet downloaded) movies be fetched")]
|
||||
public bool OnlyActive { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -214,7 +214,12 @@ namespace NzbDrone.Core.NetImport
|
||||
{
|
||||
var response = FetchIndexerResponse(request);
|
||||
|
||||
return parser.ParseResponse(response).ToList();
|
||||
return parser.ParseResponse(response).ToList().Select(m =>
|
||||
{
|
||||
m.RootFolderPath = ((NetImportDefinition) Definition).RootFolderPath;
|
||||
m.ProfileId = ((NetImportDefinition) Definition).ProfileId;
|
||||
return m;
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
protected virtual NetImportResponse FetchIndexerResponse(NetImportRequest request)
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace NzbDrone.Core.NetImport
|
||||
public bool EnableAuto { get; set; }
|
||||
public int ProfileId { get; set; }
|
||||
public LazyLoaded<Profile> Profile { get; set; }
|
||||
public string RootFolderPath { get; set; }
|
||||
public override bool Enable => Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.NetImport
|
||||
@@ -20,14 +23,26 @@ namespace NzbDrone.Core.NetImport
|
||||
private readonly Logger _logger;
|
||||
private readonly INetImportFactory _netImportFactory;
|
||||
private readonly IMovieService _movieService;
|
||||
private readonly ISearchForNewMovie _movieSearch;
|
||||
private readonly IRootFolderService _rootFolder;
|
||||
private string defaultRootFolder;
|
||||
|
||||
public NetImportSearchService(INetImportFactory netImportFactory, IMovieService movieService, Logger logger)
|
||||
public NetImportSearchService(INetImportFactory netImportFactory, IMovieService movieService,
|
||||
ISearchForNewMovie movieSearch, IRootFolderService rootFolder, Logger logger)
|
||||
{
|
||||
_netImportFactory = netImportFactory;
|
||||
_movieService = movieService;
|
||||
_movieSearch = movieSearch;
|
||||
_rootFolder = rootFolder;
|
||||
var folder = _rootFolder.All().FirstOrDefault();
|
||||
if (folder != null)
|
||||
{
|
||||
defaultRootFolder = folder.Path;
|
||||
}
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public List<Movie> Fetch(int listId, bool onlyEnableAuto = false)
|
||||
{
|
||||
return MovieListSearch(listId, onlyEnableAuto);
|
||||
@@ -65,9 +80,19 @@ namespace NzbDrone.Core.NetImport
|
||||
|
||||
public void Execute(NetImportSyncCommand message)
|
||||
{
|
||||
var movies = FetchAndFilter(2, false);
|
||||
var movies = FetchAndFilter(0, true);
|
||||
|
||||
_logger.Debug("Found {0} movies on your lists not in your library", movies.Count);
|
||||
_logger.Debug("Found {0} movies on your auto enabled lists not in your library", movies.Count);
|
||||
|
||||
foreach (var movie in movies)
|
||||
{
|
||||
var mapped = _movieSearch.MapMovieToTmdbMovie(movie);
|
||||
|
||||
if (mapped != null)
|
||||
{
|
||||
_movieService.AddMovie(mapped);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user