Patch/filter trakt (#838)

* Update wording for Certification

* Add Filter Options for Trakt
pull/2/head
Devin Buhl 8 years ago committed by GitHub
parent a0050fedd3
commit 97ee66465d

@ -42,7 +42,7 @@ namespace NzbDrone.Core.NetImport.TMDb
[FieldDefinition(4, Label = "Minimum Number of Votes", HelpText = "Filter movies by number of votes")]
public int MinVotes { get; set; }
[FieldDefinition(5, Label = "Rating", HelpText = "Filter movies by a rating (NR,G,PG,PG-13,R,NC-17)")]
[FieldDefinition(5, Label = "Ceritification", HelpText = "Filter movies by a ceritification (NR,G,PG,PG-13,R,NC-17)")]
public string Ceritification { get; set; }
[FieldDefinition(6, Label = "Include Genre Ids", HelpText = "Filter movies by TMDb Genre Ids (Comma Separated)")]

@ -20,6 +20,8 @@ namespace NzbDrone.Core.NetImport.Trakt
{
var link = Settings.Link.Trim();
var filters = $"?years={Settings.Years}&genres={Settings.Genres.ToLower()}&ratings={Settings.Rating}&certifications={Settings.Ceritification.ToLower()}";
switch (Settings.ListType)
{
case (int)TraktListType.UserCustomList:
@ -32,28 +34,28 @@ namespace NzbDrone.Core.NetImport.Trakt
link = link + $"/users/{Settings.Username.Trim()}/watched/movies";
break;
case (int)TraktListType.Trending:
link = link + "/movies/trending";
link = link + "/movies/trending" + filters;
break;
case (int)TraktListType.Popular:
link = link + "/movies/popular";
link = link + "/movies/popular" + filters;
break;
case (int)TraktListType.Anticipated:
link = link + "/movies/anticipated";
link = link + "/movies/anticipated" + filters;
break;
case (int)TraktListType.BoxOffice:
link = link + "/movies/boxoffice";
link = link + "/movies/boxoffice" + filters;
break;
case (int)TraktListType.TopWatchedByWeek:
link = link + "/movies/watched/weekly";
link = link + "/movies/watched/weekly" + filters;
break;
case (int)TraktListType.TopWatchedByMonth:
link = link + "/movies/watched/monthly";
link = link + "/movies/watched/monthly" + filters;
break;
case (int)TraktListType.TopWatchedByYear:
link = link + "/movies/watched/yearly";
link = link + "/movies/watched/yearly" + filters;
break;
case (int)TraktListType.TopWatchedByAllTime:
link = link + "/movies/watched/all";
link = link + "/movies/watched/all" + filters;
break;
}

@ -10,31 +10,53 @@ namespace NzbDrone.Core.NetImport.Trakt
public TraktSettingsValidator()
{
RuleFor(c => c.Link).ValidRootUrl();
RuleFor(c => c.Username).NotEmpty();
}
}
public class TraktSettings : NetImportBaseSettings
{
private static readonly TraktSettingsValidator Validator = new TraktSettingsValidator();
public TraktSettings()
{
Link = "https://api.trakt.tv";
Username = "";
Listname = "";
Rating = "0-100";
Ceritification = "NR,G,PG,PG-13,R,NC-17";
Genres = "";
Years = "2011-2017";
}
[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 = "List Type", Type = FieldType.Select, SelectOptions = typeof(TraktListType), HelpText = "Trakt list type, custom or watchlist")]
[FieldDefinition(1, Label = "List Type", Type = FieldType.Select, SelectOptions = typeof(TraktListType), HelpText = "Trakt list type")]
public int ListType { get; set; }
[FieldDefinition(2, Label = "Username", HelpText = "Required for User List")]
[FieldDefinition(2, Label = "Username", HelpText = "Required for User List (Ignores Filtering Options)")]
public string Username { get; set; }
[FieldDefinition(3, Label = "List Name", HelpText = "Required for Custom List")]
[FieldDefinition(3, Label = "List Name", HelpText = "Required for Custom List (Ignores Filtering Options)")]
public string Listname { get; set; }
[FieldDefinition(4, Label = "Rating", HelpText = "Filter movies by rating range (0-100)")]
public string Rating { get; set; }
[FieldDefinition(5, Label = "Ceritification", HelpText = "Filter movies by a ceritification (NR,G,PG,PG-13,R,NC-17), (Comma Separated)")]
public string Ceritification { get; set; }
[FieldDefinition(6, Label = "Genres", HelpText = "Filter movies by Trakt Genre Slug (Comma Separated)")]
public string Genres { get; set; }
[FieldDefinition(7, Label = "Years", HelpText = "Filter movies by year or year range")]
public string Years { get; set; }
public new NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));
}
}

Loading…
Cancel
Save