1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-15 21:05:48 -04:00

New: Trending and Popular Movies in Discovery

This commit is contained in:
Qstick
2024-01-27 20:24:56 -06:00
parent 3b1d4460ad
commit 0be449033f
15 changed files with 221 additions and 5 deletions

View File

@@ -877,7 +877,9 @@
"MovieIsDownloading": "Movie is downloading",
"MovieIsMonitored": "Movie is monitored",
"MovieIsOnImportExclusionList": "Movie is on Import Exclusion List",
"MovieIsPopular": "Movie is Popular on TMDb",
"MovieIsRecommend": "Movie is recommended based on recent addition",
"MovieIsTrending": "Movie is Trending on TMDb",
"MovieIsUnmonitored": "Movie is unmonitored",
"MovieMatchType": "Movie Match Type",
"MovieNaming": "Movie Naming",

View File

@@ -12,6 +12,8 @@ namespace NzbDrone.Core.MetadataSource
Tuple<MovieMetadata, List<Credit>> GetMovieInfo(int tmdbId);
MovieCollection GetCollectionInfo(int tmdbId);
List<MovieMetadata> GetBulkMovieInfo(List<int> tmdbIds);
List<MovieMetadata> GetTrendingMovies();
List<MovieMetadata> GetPopularMovies();
HashSet<int> GetChangedMovies(DateTime startTime);
}

View File

@@ -70,6 +70,34 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
return new HashSet<int>(response.Resource);
}
public List<MovieMetadata> GetTrendingMovies()
{
var request = _radarrMetadata.Create()
.SetSegment("route", "list/tmdb/trending")
.Build();
request.AllowAutoRedirect = true;
request.SuppressHttpError = true;
var response = _httpClient.Get<List<MovieResource>>(request);
return response.Resource.DistinctBy(x => x.TmdbId).Select(MapMovie).ToList();
}
public List<MovieMetadata> GetPopularMovies()
{
var request = _radarrMetadata.Create()
.SetSegment("route", "list/tmdb/popular")
.Build();
request.AllowAutoRedirect = true;
request.SuppressHttpError = true;
var response = _httpClient.Get<List<MovieResource>>(request);
return response.Resource.DistinctBy(x => x.TmdbId).Select(MapMovie).ToList();
}
public Tuple<MovieMetadata, List<Credit>> GetMovieInfo(int tmdbId)
{
var httpRequest = _radarrMetadata.Create()

View File

@@ -54,7 +54,7 @@ namespace Radarr.Api.V3.ImportLists
}
[HttpGet]
public object GetDiscoverMovies(bool includeRecommendations = false)
public object GetDiscoverMovies(bool includeRecommendations = false, bool includeTrending = false, bool includePopular = false)
{
var movieLanguage = (Language)_configService.MovieInfoLanguage;
@@ -77,6 +77,17 @@ namespace Radarr.Api.V3.ImportLists
realResults.ForEach(x => x.IsRecommendation = true);
}
// Add TMDB Trending
var trendingResults = _movieInfo.GetTrendingMovies();
realResults.AddRange(MapToResource(trendingResults.Select(m => new Movie { MovieMetadata = m }).Where(x => x != null), movieLanguage, true));
// Add TMDB Popular
var popularResults = _movieInfo.GetPopularMovies();
realResults.AddRange(MapToResource(popularResults.Select(m => new Movie { MovieMetadata = m }).Where(x => x != null), movieLanguage, false, true));
// Add List Movies
var listMovies = MapToResource(_listMovieService.GetAllForLists(_importListFactory.Enabled().Select(x => x.Definition.Id).ToList()), movieLanguage).ToList();
realResults.AddRange(listMovies);
@@ -92,6 +103,8 @@ namespace Radarr.Api.V3.ImportLists
movie.IsExcluded = listExclusions.Any(e => e.TmdbId == movie.TmdbId);
movie.IsExisting = existingTmdbIds.Any(e => e == movie.TmdbId);
movie.IsRecommendation = x.Any(m => m.IsRecommendation);
movie.IsPopular = x.Any(m => m.IsPopular);
movie.IsTrending = x.Any(m => m.IsTrending);
return movie;
}).ToList();
@@ -107,7 +120,7 @@ namespace Radarr.Api.V3.ImportLists
return _addMovieService.AddMovies(newMovies, true).ToResource(0);
}
private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<Movie> movies, Language language)
private IEnumerable<ImportListMoviesResource> MapToResource(IEnumerable<Movie> movies, Language language, bool isTrending = false, bool isPopular = false)
{
// Avoid calling for naming spec on every movie in filenamebuilder
var namingConfig = _namingService.GetConfig();
@@ -127,6 +140,8 @@ namespace Radarr.Api.V3.ImportLists
resource.Title = translation?.Title ?? resource.Title;
resource.Overview = translation?.Overview ?? resource.Overview;
resource.Folder = _fileNameBuilder.GetMovieFolder(currentMovie, namingConfig);
resource.IsTrending = isTrending;
resource.IsPopular = isPopular;
yield return resource;
}

View File

@@ -42,6 +42,8 @@ namespace Radarr.Api.V3.ImportLists
public MovieCollection Collection { get; set; }
public bool IsExcluded { get; set; }
public bool IsExisting { get; set; }
public bool IsTrending { get; set; }
public bool IsPopular { get; set; }
public bool IsRecommendation { get; set; }
public HashSet<int> Lists { get; set; }