mirror of https://github.com/Radarr/Radarr
Added options for watched, and watchlist, and customlist to trakt
This commit is contained in:
parent
be083cfd53
commit
5b7d513986
|
@ -7,6 +7,16 @@ using NzbDrone.Core.Validation;
|
|||
namespace NzbDrone.Core.NetImport.CouchPotato
|
||||
{
|
||||
|
||||
public class CouchPotatoSettingsValidator : AbstractValidator<CouchPotatoSettings>
|
||||
{
|
||||
public CouchPotatoSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Link).ValidRootUrl();
|
||||
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
|
||||
RuleFor(c => c.ApiKey).NotEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public class CouchPotatoSettings : NetImportBaseSettings
|
||||
{
|
||||
public CouchPotatoSettings()
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace NzbDrone.Core.NetImport.Trakt
|
|||
{
|
||||
public class TraktImport : HttpNetImportBase<TraktSettings>
|
||||
{
|
||||
public override string Name => "Trakt User List";
|
||||
public override string Name => "Trakt List";
|
||||
public override bool Enabled => true;
|
||||
public override bool EnableAuto => false;
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
namespace NzbDrone.Core.NetImport.Trakt
|
||||
{
|
||||
public enum TraktListType
|
||||
{
|
||||
WatchList = 0,
|
||||
Watched = 1,
|
||||
CustomList = 2
|
||||
}
|
||||
}
|
|
@ -21,11 +21,22 @@ namespace NzbDrone.Core.NetImport.Trakt
|
|||
|
||||
private IEnumerable<NetImportRequest> GetMovies(string searchParameters)
|
||||
{
|
||||
// https://api.trakt.tv/users/timdturner/lists/custom1/items/movies
|
||||
// trakt-api-version = 2
|
||||
// trakt-api-key = 657bb899dcb81ec8ee838ff09f6e013ff7c740bf0ccfa54dd41e791b9a70b2f0
|
||||
var link = $"{Settings.Link.Trim()}{Settings.Username.Trim()}";
|
||||
|
||||
var request = new NetImportRequest($"{Settings.Link.Trim()}{Settings.Username.Trim()}/lists/{Settings.Listname.Trim()}/items/movies", HttpAccept.Json);
|
||||
switch (Settings.ListType)
|
||||
{
|
||||
case (int)TraktListType.CustomList:
|
||||
link = link + $"/lists/{Settings.Listname.Trim()}/items/movies";
|
||||
break;
|
||||
case (int)TraktListType.WatchList:
|
||||
link = link + "/watchlist/movies";
|
||||
break;
|
||||
case (int)TraktListType.Watched:
|
||||
link = link + "/watched/movies";
|
||||
break;
|
||||
}
|
||||
|
||||
var request = new NetImportRequest($"{link}", HttpAccept.Json);
|
||||
request.HttpRequest.Headers.Add("trakt-api-version", "2");
|
||||
request.HttpRequest.Headers.Add("trakt-api-key", "657bb899dcb81ec8ee838ff09f6e013ff7c740bf0ccfa54dd41e791b9a70b2f0");
|
||||
|
||||
|
|
|
@ -7,6 +7,15 @@ using NzbDrone.Core.Validation;
|
|||
namespace NzbDrone.Core.NetImport.Trakt
|
||||
{
|
||||
|
||||
public class TraktSettingsValidator : AbstractValidator<TraktSettings>
|
||||
{
|
||||
public TraktSettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Link).ValidRootUrl();
|
||||
RuleFor(c => c.Username).NotEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public class TraktSettings : NetImportBaseSettings
|
||||
{
|
||||
public TraktSettings()
|
||||
|
@ -19,10 +28,13 @@ namespace NzbDrone.Core.NetImport.Trakt
|
|||
[FieldDefinition(0, Label = "Trakt API URL", HelpText = "Link to to Trakt API URL, do not change unless you know what you are doing.")]
|
||||
public new string Link { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "Trakt Username", HelpText = "Trakt Username the list belongs to.")]
|
||||
[FieldDefinition(1, Label = "Trakt List Type", Type = FieldType.Select, SelectOptions = typeof(TraktListType), HelpText = "Trakt list type, custom or watchlist")]
|
||||
public int ListType { get; set; }
|
||||
|
||||
[FieldDefinition(2, Label = "Trakt Username", HelpText = "Trakt Username the list belongs to.")]
|
||||
public string Username { get; set; }
|
||||
|
||||
[FieldDefinition(2, Label = "Trakt List Name", HelpText = "Trakt List Name")]
|
||||
[FieldDefinition(3, Label = "Trakt List Name", HelpText = "Required for Custom List")]
|
||||
public string Listname { get; set; }
|
||||
|
||||
}
|
||||
|
|
|
@ -125,6 +125,7 @@
|
|||
<Compile Include="Datastore\Migration\123_create_netimport_table.cs" />
|
||||
<Compile Include="NetImport\Trakt\TraktAPI.cs" />
|
||||
<Compile Include="NetImport\Trakt\TraktImport.cs" />
|
||||
<Compile Include="NetImport\Trakt\TraktListType.cs" />
|
||||
<Compile Include="NetImport\Trakt\TraktParser.cs" />
|
||||
<Compile Include="NetImport\Trakt\TraktRequestGenerator.cs" />
|
||||
<Compile Include="NetImport\Trakt\TraktSettings.cs" />
|
||||
|
|
Loading…
Reference in New Issue