mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 14:55:20 -07:00
Merge pull request #573 from Radarr/patch/more-trakt-options
Added more options to trakt, popular movies, upcoming, anticipated etc..
This commit is contained in:
commit
a282ad7809
6 changed files with 107 additions and 31 deletions
|
@ -21,9 +21,18 @@ namespace NzbDrone.Core.NetImport.Trakt
|
||||||
|
|
||||||
public class TraktResponse
|
public class TraktResponse
|
||||||
{
|
{
|
||||||
public int rank { get; set; }
|
public int? rank { get; set; }
|
||||||
public string listed_at { get; set; }
|
public string listed_at { get; set; }
|
||||||
public string type { get; set; }
|
public string type { get; set; }
|
||||||
|
|
||||||
|
public int? watchers { get; set; }
|
||||||
|
|
||||||
|
public long? revenue { get; set; }
|
||||||
|
|
||||||
|
public long? watcher_count { get; set; }
|
||||||
|
public long? play_count { get; set; }
|
||||||
|
public long? collected_count { get; set; }
|
||||||
|
|
||||||
public Movie movie { get; set; }
|
public Movie movie { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,32 @@
|
||||||
namespace NzbDrone.Core.NetImport.Trakt
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.NetImport.Trakt
|
||||||
{
|
{
|
||||||
public enum TraktListType
|
public enum TraktListType
|
||||||
{
|
{
|
||||||
WatchList = 0,
|
[EnumMember(Value = "User Watch List")]
|
||||||
Watched = 1,
|
UserWatchList = 0,
|
||||||
CustomList = 2
|
[EnumMember(Value = "User Watched List")]
|
||||||
|
UserWatchedList = 1,
|
||||||
|
[EnumMember(Value = "User Custom List")]
|
||||||
|
UserCustomList = 2,
|
||||||
|
|
||||||
|
[EnumMember(Value = "Trending Movies")]
|
||||||
|
TrendingMovies = 3,
|
||||||
|
[EnumMember(Value = "Popular Movies")]
|
||||||
|
PopularMovies = 4,
|
||||||
|
[EnumMember(Value = "Top Anticipated Movies")]
|
||||||
|
AnticipatedMovies = 5,
|
||||||
|
[EnumMember(Value = "Top Box Office Movies")]
|
||||||
|
BoxOfficeMovies = 6,
|
||||||
|
|
||||||
|
[EnumMember(Value = "Top Watched Movies By Week")]
|
||||||
|
TopWatchedByWeek = 7,
|
||||||
|
[EnumMember(Value = "Top Watched Movies By Month")]
|
||||||
|
TopWatchedByMonth = 8,
|
||||||
|
[EnumMember(Value = "Top Watched Movies By Year")]
|
||||||
|
TopWatchedByYear = 9,
|
||||||
|
[EnumMember(Value = "Top Watched Movies Of All Time")]
|
||||||
|
TopWatchedByAllTime = 10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,23 @@ namespace NzbDrone.Core.NetImport.Trakt
|
||||||
return movies;
|
return movies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_settings.ListType == (int) TraktListType.PopularMovies)
|
||||||
|
{
|
||||||
|
var jsonResponse = JsonConvert.DeserializeObject<List<Movie>>(_importResponse.Content);
|
||||||
|
|
||||||
|
foreach (var movie in jsonResponse)
|
||||||
|
{
|
||||||
|
movies.AddIfNotNull(new Tv.Movie()
|
||||||
|
{
|
||||||
|
Title = movie.title,
|
||||||
|
ImdbId = movie.ids.imdb,
|
||||||
|
TmdbId = movie.ids.tmdb,
|
||||||
|
Year = (movie.year ?? 0)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
var jsonResponse = JsonConvert.DeserializeObject<List<TraktResponse>>(_importResponse.Content);
|
var jsonResponse = JsonConvert.DeserializeObject<List<TraktResponse>>(_importResponse.Content);
|
||||||
|
|
||||||
// no movies were return
|
// no movies were return
|
||||||
|
@ -60,8 +77,10 @@ namespace NzbDrone.Core.NetImport.Trakt
|
||||||
Year = (movie.movie.year ?? 0)
|
Year = (movie.movie.year ?? 0)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return movies;
|
return movies;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool PreProcess(NetImportResponse indexerResponse)
|
protected virtual bool PreProcess(NetImportResponse indexerResponse)
|
||||||
|
|
|
@ -21,18 +21,42 @@ namespace NzbDrone.Core.NetImport.Trakt
|
||||||
|
|
||||||
private IEnumerable<NetImportRequest> GetMovies(string searchParameters)
|
private IEnumerable<NetImportRequest> GetMovies(string searchParameters)
|
||||||
{
|
{
|
||||||
var link = $"{Settings.Link.Trim()}{Settings.Username.Trim()}";
|
var link = Settings.Link.Trim();
|
||||||
|
|
||||||
switch (Settings.ListType)
|
switch (Settings.ListType)
|
||||||
{
|
{
|
||||||
case (int)TraktListType.CustomList:
|
case (int)TraktListType.UserCustomList:
|
||||||
link = link + $"/lists/{Settings.Listname.Trim()}/items/movies";
|
link = link + $"/users/{Settings.Username.Trim()}/lists/{Settings.Listname.Trim()}/items/movies";
|
||||||
break;
|
break;
|
||||||
case (int)TraktListType.WatchList:
|
case (int)TraktListType.UserWatchList:
|
||||||
link = link + "/watchlist/movies";
|
link = link + $"/users/{Settings.Username.Trim()}/watchlist/movies";
|
||||||
break;
|
break;
|
||||||
case (int)TraktListType.Watched:
|
case (int)TraktListType.UserWatchedList:
|
||||||
link = link + "/watched/movies";
|
link = link + $"/users/{Settings.Username.Trim()}/watched/movies";
|
||||||
|
break;
|
||||||
|
case (int)TraktListType.TrendingMovies:
|
||||||
|
link = link + "/movies/trending";
|
||||||
|
break;
|
||||||
|
case (int)TraktListType.PopularMovies:
|
||||||
|
link = link + "/movies/popular";
|
||||||
|
break;
|
||||||
|
case (int)TraktListType.AnticipatedMovies:
|
||||||
|
link = link + "/movies/anticipated";
|
||||||
|
break;
|
||||||
|
case (int)TraktListType.BoxOfficeMovies:
|
||||||
|
link = link + "/movies/boxoffice";
|
||||||
|
break;
|
||||||
|
case (int)TraktListType.TopWatchedByWeek:
|
||||||
|
link = link + "/movies/watched/weekly";
|
||||||
|
break;
|
||||||
|
case (int)TraktListType.TopWatchedByMonth:
|
||||||
|
link = link + "/movies/watched/monthly";
|
||||||
|
break;
|
||||||
|
case (int)TraktListType.TopWatchedByYear:
|
||||||
|
link = link + "/movies/watched/yearly";
|
||||||
|
break;
|
||||||
|
case (int)TraktListType.TopWatchedByAllTime:
|
||||||
|
link = link + "/movies/watched/all";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Core.Annotations;
|
using NzbDrone.Core.Annotations;
|
||||||
using NzbDrone.Core.Profiles;
|
|
||||||
using NzbDrone.Core.ThingiProvider;
|
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
namespace NzbDrone.Core.NetImport.Trakt
|
namespace NzbDrone.Core.NetImport.Trakt
|
||||||
|
@ -20,7 +18,7 @@ namespace NzbDrone.Core.NetImport.Trakt
|
||||||
{
|
{
|
||||||
public TraktSettings()
|
public TraktSettings()
|
||||||
{
|
{
|
||||||
Link = "https://api.trakt.tv/users/";
|
Link = "https://api.trakt.tv";
|
||||||
Username = "";
|
Username = "";
|
||||||
Listname = "";
|
Listname = "";
|
||||||
}
|
}
|
||||||
|
@ -31,7 +29,7 @@ namespace NzbDrone.Core.NetImport.Trakt
|
||||||
[FieldDefinition(1, Label = "Trakt List Type", Type = FieldType.Select, SelectOptions = typeof(TraktListType), HelpText = "Trakt list type, custom or watchlist")]
|
[FieldDefinition(1, Label = "Trakt List Type", Type = FieldType.Select, SelectOptions = typeof(TraktListType), HelpText = "Trakt list type, custom or watchlist")]
|
||||||
public int ListType { get; set; }
|
public int ListType { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(2, Label = "Trakt Username", HelpText = "Trakt Username the list belongs to.")]
|
[FieldDefinition(2, Label = "Trakt Username", HelpText = "Required for User List")]
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(3, Label = "Trakt List Name", HelpText = "Required for Custom List")]
|
[FieldDefinition(3, Label = "Trakt List Name", HelpText = "Required for Custom List")]
|
||||||
|
@ -39,4 +37,6 @@ namespace NzbDrone.Core.NetImport.Trakt
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,7 @@
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
<Reference Include="System.Web" />
|
<Reference Include="System.Web" />
|
||||||
<Reference Include="System.Web.Extensions" />
|
<Reference Include="System.Web.Extensions" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue