Merge branch 'develop' of https://github.com/dr3am37/OmbiPDev into develop

This commit is contained in:
dr3amer 2022-04-30 03:11:38 -07:00
commit ce265941cc
21 changed files with 248 additions and 129 deletions

View file

@ -8,6 +8,8 @@
name: Labeler
on: [pull_request]
permissions: write-all
jobs:
label:

View file

@ -5,6 +5,11 @@ on:
types: [opened, synchronize, reopened]
workflow_dispatch:
permissions:
pull-requests: write
issues: write
repository-projects: write
jobs:
build-ui:
runs-on: ubuntu-latest
@ -28,8 +33,7 @@ jobs:
unit-test:
runs-on: ubuntu-latest
permissions:
checks: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1

View file

@ -1,3 +1,43 @@
# [4.20.0](https://github.com/Ombi-app/Ombi/compare/v4.19.1...v4.20.0) (2022-04-28)
### Features
* **discover:** Show more relevant shows in upcoming TV ([8357819](https://github.com/Ombi-app/Ombi/commit/8357819b53b8c675c0b246d7006b5a778bdba33f))
## [4.19.1](https://github.com/Ombi-app/Ombi/compare/v4.19.0...v4.19.1) (2022-04-27)
# [4.19.0](https://github.com/Ombi-app/Ombi/compare/v4.18.0...v4.19.0) (2022-04-27)
### Features
* **sync:** Detect reidentified movies in Emby and Jellyfin ([5938077](https://github.com/Ombi-app/Ombi/commit/5938077d82a5357f79c07b218b3986557a5816e8))
* **sync:** Detect reidentified series in Emby and Jellyfin ([9096e91](https://github.com/Ombi-app/Ombi/commit/9096e91d55d268819bce22831f8a8b27f2a1776b))
# [4.18.0](https://github.com/Ombi-app/Ombi/compare/v4.17.0...v4.18.0) (2022-04-26)
### Bug Fixes
* **discover:** Fix cache mix up ([03d9422](https://github.com/Ombi-app/Ombi/commit/03d94220c7eaafb50c6c80a6ed1150794b873ac3))
* **discover:** Fix new trending feature detection ([6794b88](https://github.com/Ombi-app/Ombi/commit/6794b887f6544fb41528bdd9728b7824b65e47ee))
* **settings:** Allow toggling features when there are more than one ([a373359](https://github.com/Ombi-app/Ombi/commit/a373359ae8e6bad42b558a6e01a8ff2840d3bbaa))
### Features
* **discover:** Add new trending source experimental feature ([1a0823c](https://github.com/Ombi-app/Ombi/commit/1a0823ca80559417c67323aaeaa1ef5243e98031))
* **discover:** Default trending source to new logic ([4f12939](https://github.com/Ombi-app/Ombi/commit/4f12939e22020a67a5ee75e2907923faea136e8d))
# [4.17.0](https://github.com/Ombi-app/Ombi/compare/v4.16.17...v4.17.0) (2022-04-25)
@ -311,30 +351,3 @@
## [4.12.5](https://github.com/Ombi-app/Ombi/compare/v4.12.4...v4.12.5) (2022-02-21)
### Bug Fixes
* **emby:** :bug: Fixed the emby content sync [#4513](https://github.com/Ombi-app/Ombi/issues/4513) ([2927504](https://github.com/Ombi-app/Ombi/commit/2927504f0e0b4e7251e69b44e0e30c7ec9519980))
* **emby:** :bug: Fixed the emby content sync [#4513](https://github.com/Ombi-app/Ombi/issues/4513) ([bd441cb](https://github.com/Ombi-app/Ombi/commit/bd441cb54fd77d6befb03fae321dc36c29f0de2e))
## [4.12.4](https://github.com/Ombi-app/Ombi/compare/v4.12.3...v4.12.4) (2022-02-17)
## [4.12.3](https://github.com/Ombi-app/Ombi/compare/v4.12.2...v4.12.3) (2022-02-16)
## [4.12.2](https://github.com/Ombi-app/Ombi/compare/v4.12.1...v4.12.2) (2022-02-16)
### Bug Fixes
* **requests:** :bug: Fixed the approve 4k option on the requests list not working as expected ([c0189da](https://github.com/Ombi-app/Ombi/commit/c0189dad478ea375beda61ba3bee3f029a39b8e5))

View file

@ -99,19 +99,19 @@ Here are some of the features Ombi has:
<sub><b>Drew</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/anojht">
<img src="https://avatars.githubusercontent.com/u/21053678?v=4" width="50;" alt="anojht"/>
<br />
<sub><b>Anojh Thayaparan</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/sephrat">
<img src="https://avatars.githubusercontent.com/u/34862846?v=4" width="50;" alt="sephrat"/>
<br />
<sub><b>Sephrat</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/anojht">
<img src="https://avatars.githubusercontent.com/u/21053678?v=4" width="50;" alt="anojht"/>
<br />
<sub><b>Anojh Thayaparan</b></sub>
</a>
</td></tr>
<tr>
<td align="center">

View file

@ -161,7 +161,7 @@ namespace Ombi.Core.Engine
var result = await Cache.GetOrAddAsync(CacheKeys.UpcomingMovies, async () =>
{
var langCode = await DefaultLanguageCode(null);
return await MovieApi.Upcoming(langCode);
return await MovieApi.UpcomingMovies(langCode);
}, DateTimeOffset.Now.AddHours(12));
if (result != null)
{

View file

@ -11,6 +11,7 @@ using Ombi.Core.Models.Search;
using Ombi.Core.Models.Search.V2;
using Ombi.Core.Models.UI;
using Ombi.Core.Rule.Interfaces;
using Ombi.Core.Services;
using Ombi.Core.Settings;
using Ombi.Helpers;
using Ombi.Settings.Settings.Models;
@ -31,7 +32,8 @@ namespace Ombi.Core.Engine.V2
{
public MovieSearchEngineV2(ICurrentUser identity, IRequestServiceMain service, IMovieDbApi movApi, IMapper mapper,
ILogger<MovieSearchEngineV2> logger, IRuleEvaluator r, OmbiUserManager um, ICacheService mem, ISettingsService<OmbiSettings> s, IRepository<RequestSubscription> sub,
ISettingsService<CustomizationSettings> customizationSettings, IMovieRequestEngine movieRequestEngine, IHttpClientFactory httpClientFactory)
ISettingsService<CustomizationSettings> customizationSettings, IMovieRequestEngine movieRequestEngine, IHttpClientFactory httpClientFactory,
IFeatureService feature)
: base(identity, service, r, um, mem, s, sub)
{
MovieApi = movApi;
@ -40,6 +42,7 @@ namespace Ombi.Core.Engine.V2
_customizationSettings = customizationSettings;
_movieRequestEngine = movieRequestEngine;
_client = httpClientFactory.CreateClient();
_feature = feature;
}
private IMovieDbApi MovieApi { get; }
@ -48,6 +51,7 @@ namespace Ombi.Core.Engine.V2
private readonly ISettingsService<CustomizationSettings> _customizationSettings;
private readonly IMovieRequestEngine _movieRequestEngine;
private readonly HttpClient _client;
private readonly IFeatureService _feature;
public async Task<MovieFullInfoViewModel> GetFullMovieInformation(int theMovieDbId, CancellationToken cancellationToken, string langCode = null)
{
@ -196,14 +200,19 @@ namespace Ombi.Core.Engine.V2
public async Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies(int currentPosition, int amountToLoad)
{
var langCode = await DefaultLanguageCode(null);
var isOldTrendingSourceEnabled = await _feature.FeatureEnabled(FeatureNames.OldTrendingSource);
var pages = PaginationHelper.GetNextPages(currentPosition, amountToLoad, _theMovieDbMaxPageItems);
var results = new List<MovieDbSearchResult>();
foreach (var pagesToLoad in pages)
{
var search = () => (isOldTrendingSourceEnabled) ?
MovieApi.NowPlaying(langCode, pagesToLoad.Page)
: MovieApi.TrendingMovies(langCode, pagesToLoad.Page);
var apiResult = await Cache.GetOrAddAsync(nameof(NowPlayingMovies) + pagesToLoad.Page + langCode,
() => MovieApi.NowPlaying(langCode, pagesToLoad.Page), DateTimeOffset.Now.AddHours(12));
search, DateTimeOffset.Now.AddHours(12));
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
}
return await TransformMovieResultsToResponse(results);
@ -278,7 +287,7 @@ namespace Ombi.Core.Engine.V2
var result = await Cache.GetOrAddAsync(CacheKeys.UpcomingMovies, async () =>
{
var langCode = await DefaultLanguageCode(null);
return await MovieApi.Upcoming(langCode);
return await MovieApi.UpcomingMovies(langCode);
}, DateTimeOffset.Now.AddHours(12));
if (result != null)
{
@ -298,7 +307,7 @@ namespace Ombi.Core.Engine.V2
foreach (var pagesToLoad in pages)
{
var apiResult = await Cache.GetOrAddAsync(nameof(UpcomingMovies) + pagesToLoad.Page + langCode,
() => MovieApi.Upcoming(langCode, pagesToLoad.Page), DateTimeOffset.Now.AddHours(12));
() => MovieApi.UpcomingMovies(langCode, pagesToLoad.Page), DateTimeOffset.Now.AddHours(12));
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
}
return await TransformMovieResultsToResponse(results);

View file

@ -26,6 +26,7 @@ using System.Diagnostics;
using Ombi.Core.Engine.Interfaces;
using Ombi.Core.Models.UI;
using Ombi.Core.Helpers;
using Ombi.Core.Services;
namespace Ombi.Core.Engine.V2
{
@ -37,10 +38,12 @@ namespace Ombi.Core.Engine.V2
private readonly IMovieDbApi _movieApi;
private readonly ISettingsService<CustomizationSettings> _customization;
private readonly ITvRequestEngine _requestEngine;
private readonly IFeatureService _feature;
public TvSearchEngineV2(ICurrentUser identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper,
ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, ICacheService memCache, ISettingsService<OmbiSettings> s,
IRepository<RequestSubscription> sub, IMovieDbApi movieApi, ISettingsService<CustomizationSettings> customization, ITvRequestEngine requestEngine)
IRepository<RequestSubscription> sub, IMovieDbApi movieApi, ISettingsService<CustomizationSettings> customization, ITvRequestEngine requestEngine,
IFeatureService feature)
: base(identity, service, r, um, memCache, s, sub)
{
_tvMaze = tvMaze;
@ -49,6 +52,7 @@ namespace Ombi.Core.Engine.V2
_movieApi = movieApi;
_customization = customization;
_requestEngine = requestEngine;
_feature = feature;
}
@ -132,15 +136,19 @@ namespace Ombi.Core.Engine.V2
}
public async Task<IEnumerable<SearchTvShowViewModel>> Trending(int currentlyLoaded, int amountToLoad)
{
{
var langCode = await DefaultLanguageCode(null);
var isOldTrendingSourceEnabled = await _feature.FeatureEnabled(FeatureNames.OldTrendingSource);
var pages = PaginationHelper.GetNextPages(currentlyLoaded, amountToLoad, ResultLimit);
var results = new List<MovieDbSearchResult>();
foreach (var pagesToLoad in pages)
{
var search = ( async () => (isOldTrendingSourceEnabled) ?
await _movieApi.TopRatedTv(langCode, pagesToLoad.Page)
: await _movieApi.TrendingTv(langCode, pagesToLoad.Page));
var apiResult = await Cache.GetOrAddAsync(nameof(Trending) + langCode + pagesToLoad.Page,
async () => await _movieApi.TopRatedTv(langCode, pagesToLoad.Page), DateTimeOffset.Now.AddHours(12));
search, DateTimeOffset.Now.AddHours(12));
results.AddRange(apiResult.Skip(pagesToLoad.Skip).Take(pagesToLoad.Take));
}

View file

@ -157,9 +157,20 @@ namespace Ombi.Schedule.Jobs.Emby
}
var existingTv = await _repo.GetByEmbyId(tvShow.Id);
if (existingTv != null &&
( existingTv.ImdbId != tvShow.ProviderIds?.Imdb
|| existingTv.TheMovieDbId != tvShow.ProviderIds?.Tmdb
|| existingTv.TvDbId != tvShow.ProviderIds?.Tvdb))
{
_logger.LogDebug($"Series '{tvShow.Name}' has different IDs, probably a reidentification.");
await _repo.DeleteTv(existingTv);
existingTv = null;
}
if (existingTv == null)
{
_logger.LogDebug("Adding new TV Show {0}", tvShow.Name);
_logger.LogDebug("Adding TV Show {0}", tvShow.Name);
mediaToAdd.Add(new EmbyContent
{
TvDbId = tvShow.ProviderIds?.Tvdb,
@ -265,23 +276,21 @@ namespace Ombi.Schedule.Jobs.Emby
return;
}
_logger.LogDebug($"Adding new movie {movieInfo.Name}");
content.Add(new EmbyContent
{
ImdbId = movieInfo.ProviderIds.Imdb,
TheMovieDbId = movieInfo.ProviderIds?.Tmdb,
Title = movieInfo.Name,
Type = MediaType.Movie,
EmbyId = movieInfo.Id,
Url = EmbyHelper.GetEmbyMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname),
AddedAt = DateTime.UtcNow,
Quality = has4K ? null : quality,
Has4K = has4K
});
var newMovie = new EmbyContent();
newMovie.AddedAt = DateTime.UtcNow;
MapEmbyContent(newMovie, movieInfo, server, has4K, quality);
content.Add(newMovie);
}
else
{
if (!quality.Equals(existingMovie?.Quality, StringComparison.InvariantCultureIgnoreCase))
var movieHasChanged = false;
if (existingMovie.ImdbId != movieInfo.ProviderIds.Imdb || existingMovie.TheMovieDbId != movieInfo.ProviderIds.Tmdb)
{
_logger.LogDebug($"Updating existing movie '{movieInfo.Name}'");
MapEmbyContent(existingMovie, movieInfo, server, has4K, quality);
movieHasChanged = true;
}
else if (!quality.Equals(existingMovie?.Quality, StringComparison.InvariantCultureIgnoreCase))
{
_logger.LogDebug($"We have found another quality for Movie '{movieInfo.Name}', Quality: '{quality}'");
existingMovie.Quality = has4K ? null : quality;
@ -290,6 +299,11 @@ namespace Ombi.Schedule.Jobs.Emby
// Probably could refactor here
// If a 4k movie comes in (we don't store the quality on 4k)
// it will always get updated even know it's not changed
movieHasChanged = true;
}
if (movieHasChanged)
{
toUpdate.Add(existingMovie);
}
else
@ -300,6 +314,17 @@ namespace Ombi.Schedule.Jobs.Emby
}
}
private void MapEmbyContent(EmbyContent content, EmbyMovie movieInfo, EmbyServers server, bool has4K, string quality){
content.ImdbId = movieInfo.ProviderIds.Imdb;
content.TheMovieDbId = movieInfo.ProviderIds?.Tmdb;
content.Title = movieInfo.Name;
content.Type = MediaType.Movie;
content.EmbyId = movieInfo.Id;
content.Url = EmbyHelper.GetEmbyMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname);
content.Quality = has4K ? null : quality;
content.Has4K = has4K;
}
private bool ValidateSettings(EmbyServers server)
{
if (server?.Ip == null || string.IsNullOrEmpty(server?.ApiKey))

View file

@ -132,9 +132,20 @@ namespace Ombi.Schedule.Jobs.Jellyfin
}
var existingTv = await _repo.GetByJellyfinId(tvShow.Id);
if (existingTv != null &&
( existingTv.ImdbId != tvShow.ProviderIds?.Imdb
|| existingTv.TheMovieDbId != tvShow.ProviderIds?.Tmdb
|| existingTv.TvDbId != tvShow.ProviderIds?.Tvdb))
{
_logger.LogDebug($"Series '{tvShow.Name}' has different IDs, probably a reidentification.");
await _repo.DeleteTv(existingTv);
existingTv = null;
}
if (existingTv == null)
{
_logger.LogDebug("Adding new TV Show {0}", tvShow.Name);
_logger.LogDebug("Adding TV Show {0}", tvShow.Name);
mediaToAdd.Add(new JellyfinContent
{
TvDbId = tvShow.ProviderIds?.Tvdb,
@ -230,22 +241,21 @@ namespace Ombi.Schedule.Jobs.Jellyfin
return;
}
_logger.LogDebug($"Adding new movie {movieInfo.Name}");
content.Add(new JellyfinContent
{
ImdbId = movieInfo.ProviderIds.Imdb,
TheMovieDbId = movieInfo.ProviderIds?.Tmdb,
Title = movieInfo.Name,
Type = MediaType.Movie,
JellyfinId = movieInfo.Id,
Url = JellyfinHelper.GetJellyfinMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname),
AddedAt = DateTime.UtcNow,
Quality = has4K ? null : quality,
Has4K = has4K
});
var newMovie = new JellyfinContent();
newMovie.AddedAt = DateTime.UtcNow;
MapJellyfinMovie(newMovie, movieInfo, server, has4K, quality);
content.Add(newMovie);;
}
else
{
if (!quality.Equals(existingMovie?.Quality, StringComparison.InvariantCultureIgnoreCase))
var movieHasChanged = false;
if (existingMovie.ImdbId != movieInfo.ProviderIds.Imdb || existingMovie.TheMovieDbId != movieInfo.ProviderIds.Tmdb)
{
_logger.LogDebug($"Updating existing movie '{movieInfo.Name}'");
MapJellyfinMovie(existingMovie, movieInfo, server, has4K, quality);
movieHasChanged = true;
}
else if (!quality.Equals(existingMovie?.Quality, StringComparison.InvariantCultureIgnoreCase))
{
_logger.LogDebug($"We have found another quality for Movie '{movieInfo.Name}', Quality: '{quality}'");
existingMovie.Quality = has4K ? null : quality;
@ -255,6 +265,12 @@ namespace Ombi.Schedule.Jobs.Jellyfin
// If a 4k movie comes in (we don't store the quality on 4k)
// it will always get updated even know it's not changed
toUpdate.Add(existingMovie);
movieHasChanged = true;
}
if (movieHasChanged)
{
toUpdate.Add(existingMovie);
}
else
{
@ -264,6 +280,18 @@ namespace Ombi.Schedule.Jobs.Jellyfin
}
}
private void MapJellyfinMovie(JellyfinContent content, JellyfinMovie movieInfo, JellyfinServers server, bool has4K, string quality)
{
content.ImdbId = movieInfo.ProviderIds.Imdb;
content.TheMovieDbId = movieInfo.ProviderIds?.Tmdb;
content.Title = movieInfo.Name;
content.Type = MediaType.Movie;
content.JellyfinId = movieInfo.Id;
content.Url = JellyfinHelper.GetJellyfinMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname);
content.Quality = has4K ? null : quality;
content.Has4K = has4K;
}
private bool ValidateSettings(JellyfinServers server)
{
if (server?.Ip == null || string.IsNullOrEmpty(server?.ApiKey))

View file

@ -409,7 +409,9 @@ namespace Ombi.Schedule.Jobs.Ombi
private HashSet<IMediaServerEpisode> FilterEpisodes(IEnumerable<IMediaServerEpisode> source, IEnumerable<RecentlyAddedLog> recentlyAdded)
{
var itemsToReturn = new HashSet<IMediaServerEpisode>();
foreach (var ep in source.Where(x => x.Series.HasTvDb))
foreach (var ep in source.Where(x => x.Series.HasTvDb // needed for recentlyAddedLog
&& x.Series.HasTheMovieDb // needed to fetch info to publish, this is just in case...
))
{
var tvDbId = StringHelper.IntParseLinq(ep.Series.TvDbId);
if (recentlyAdded.Any(x => x.ContentId == tvDbId && x.EpisodeNumber == ep.EpisodeNumber && x.SeasonNumber == ep.SeasonNumber))
@ -501,16 +503,11 @@ namespace Ombi.Schedule.Jobs.Ombi
foreach (var content in ordered)
{
int.TryParse(content.TheMovieDbId, out var movieDbId);
if (movieDbId <= 0)
{
_log.LogWarning($"{content.Title} does not have a TMDB ID, it won't be published.");
continue;
}
var info = await _movieApi.GetMovieInformationWithExtraInfo(movieDbId, defaultLanguageCode);
var mediaurl = content.Url;
if (info == null)
{
_log.LogWarning($"TMDB does not know movie {content.Title}, it won't be published.");
_log.LogError($"TMDB does not know movie {content.Title}. This shouldn't happen because our media server knows it as ID '{movieDbId}'.");
continue;
}
try
@ -665,48 +662,18 @@ namespace Ombi.Schedule.Jobs.Ombi
var orderedTv = series.OrderByDescending(x => x.AddedAt);
foreach (var t in orderedTv)
{
if (!t.HasTvDb)
{
// We may need to use themoviedb for the imdbid or their own id to get info
if (t.HasTheMovieDb)
{
int.TryParse(t.TheMovieDbId, out var movieId);
var externals = await _movieApi.GetTvExternals(movieId);
if (externals == null || externals.tvdb_id <= 0)
{
// needed later for recently added log
_log.LogWarning($"{t.Title} has no TVDB ID, it won't be published.");
continue;
}
t.TvDbId = externals.tvdb_id.ToString();
}
// WE could check the below but we need to get the moviedb and then perform the above, let the metadata job figure this out.
//else if(t.HasImdb)
//{
// // Check the imdbid
// var externals = await _movieApi.Find(t.ImdbId, ExternalSource.imdb_id);
// if (externals?.tv_results == null || externals.tv_results.Length <= 0)
// {
// continue;
// }
// t.TvDbId = externals.tv_results.FirstOrDefault()..ToString();
//}
}
try
{
var tvInfo = await _movieApi.GetTVInfo(t.TheMovieDbId, languageCode);
if (tvInfo == null)
{
_log.LogWarning($"TMDB does not know series {t.Title}, it won't be published.");
_log.LogError($"TMDB does not know series {t.Title}. This shouldn't happen because our media server knows it as ID '{t.TheMovieDbId}'.");
continue;
}
if (tvInfo.backdrop_path.HasValue())
{
AddBackgroundInsideTable($"https://image.tmdb.org/t/p/w500{tvInfo.backdrop_path}");
}
else
@ -732,7 +699,7 @@ namespace Ombi.Schedule.Jobs.Ombi
}
catch (Exception e)
{
_log.LogError(e, "Error when processing Plex TV {0}", t.Title);
_log.LogError(e, "Error when processing TV {0}", t.Title);
}
finally
{

View file

@ -20,5 +20,6 @@ namespace Ombi.Settings.Settings.Models
public static class FeatureNames
{
public const string Movie4KRequests = nameof(Movie4KRequests);
public const string OldTrendingSource = nameof(OldTrendingSource);
}
}

View file

@ -102,6 +102,13 @@ namespace Ombi.Store.Repository
return InternalSaveChanges();
}
public override async Task DeleteTv(EmbyContent tv)
{
var episodesToDelete = GetAllEpisodes().Cast<EmbyEpisode>().Where(x => x.ParentId == tv.EmbyId).ToList();
Db.EmbyEpisode.RemoveRange(episodesToDelete);
await Delete(tv);
}
public override RecentlyAddedType RecentlyAddedType => RecentlyAddedType.Emby;
}
}

View file

@ -14,6 +14,7 @@ namespace Ombi.Store.Repository
IQueryable<IMediaServerEpisode> GetAllEpisodes();
Task<IMediaServerEpisode> Add(IMediaServerEpisode content);
Task AddRange(IEnumerable<IMediaServerEpisode> content);
Task DeleteTv(Content tv);
void UpdateWithoutSave(IMediaServerContent existingContent);
}
}

View file

@ -104,6 +104,13 @@ namespace Ombi.Store.Repository
return InternalSaveChanges();
}
public override async Task DeleteTv(JellyfinContent tv)
{
var episodesToDelete = GetAllEpisodes().Cast<JellyfinEpisode>().Where(x => x.ParentId == tv.JellyfinId).ToList();
Db.JellyfinEpisode.RemoveRange(episodesToDelete);
await Delete(tv);
}
public override RecentlyAddedType RecentlyAddedType => RecentlyAddedType.Jellyfin;
}
}

View file

@ -22,5 +22,6 @@ namespace Ombi.Store.Repository
public abstract Task AddRange(IEnumerable<IMediaServerEpisode> content);
public abstract void UpdateWithoutSave(IMediaServerContent existingContent);
public abstract Task UpdateRange(IEnumerable<IMediaServerContent> existingContent);
public abstract Task DeleteTv(T tv);
}
}

View file

@ -169,5 +169,12 @@ namespace Ombi.Store.Repository
Db.PlexServerContent.UpdateRange((IEnumerable<PlexServerContent>)existingContent);
return InternalSaveChanges();
}
public override Task DeleteTv(PlexServerContent tv)
{
// not used for now
// TODO: delete episodes, then delete series
throw new NotImplementedException();
}
}
}

View file

@ -15,14 +15,16 @@ namespace Ombi.Api.TheMovieDb
Task<MovieResponseDto> GetMovieInformation(int movieId);
Task<MovieResponseDto> GetMovieInformationWithExtraInfo(int movieId, string langCode = "en");
Task<List<MovieDbSearchResult>> NowPlaying(string languageCode, int? page = null);
Task<List<MovieDbSearchResult>> TrendingMovies(string languageCode, int? page = null);
Task<List<MovieDbSearchResult>> PopularMovies(string languageCode, int? page = null, CancellationToken cancellationToken = default(CancellationToken));
Task<List<MovieDbSearchResult>> PopularTv(string langCode, int? page = null, CancellationToken cancellationToken = default(CancellationToken));
Task<List<MovieDbSearchResult>> SearchMovie(string searchTerm, int? year, string languageCode);
Task<List<MovieDbSearchResult>> GetMoviesViaKeywords(string keywordId, string langCode, CancellationToken cancellationToken, int? page = null);
Task<List<TvSearchResult>> SearchTv(string searchTerm, string year = default);
Task<List<MovieDbSearchResult>> TopRated(string languageCode, int? page = null);
Task<List<MovieDbSearchResult>> Upcoming(string languageCode, int? page = null);
Task<List<MovieDbSearchResult>> UpcomingMovies(string languageCode, int? page = null);
Task<List<MovieDbSearchResult>> TopRatedTv(string languageCode, int? page = null);
Task<List<MovieDbSearchResult>> TrendingTv(string languageCode, int? page = null);
Task<List<MovieDbSearchResult>> UpcomingTv(string languageCode, int? page = null);
Task<List<MovieDbSearchResult>> SimilarMovies(int movieId, string langCode);
Task<FindResult> Find(string externalId, ExternalSource source);

View file

@ -281,22 +281,39 @@ namespace Ombi.Api.TheMovieDb
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
return Mapper.Map<List<MovieDbSearchResult>>(result.results);
}
public Task<List<MovieDbSearchResult>> Upcoming(string langCode, int? page = null)
public Task<List<MovieDbSearchResult>> TrendingMovies(string langCode, int? page = null)
{
return Upcoming("movie", langCode, page);
}
public Task<List<MovieDbSearchResult>> UpcomingTv(string langCode, int? page = null)
{
return Upcoming("tv", langCode, page);
return Trending("movie", langCode, page);
}
public Task<List<MovieDbSearchResult>> TrendingTv(string langCode, int? page = null)
{
return Trending("tv", langCode, page);
}
private async Task<List<MovieDbSearchResult>> Trending(string type, string langCode, int? page = null)
{
// https://developers.themoviedb.org/3/trending/get-trending
var timeWindow = "week"; // another option can be 'day'
var request = new Request($"trending/{type}/{timeWindow}", BaseUri, HttpMethod.Get);
request.AddQueryString("api_key", ApiToken);
request.AddQueryString("language", langCode);
if (page != null)
{
request.AddQueryString("page", page.ToString());
}
AddRetry(request);
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
return Mapper.Map<List<MovieDbSearchResult>>(result.results);
}
/// <remarks>
/// Maintains filter parity with <a href="https://developers.themoviedb.org/3/movies/get-upcoming">/movie/upcoming</a>.
/// </remarks>
private async Task<List<MovieDbSearchResult>> Upcoming(string type, string langCode, int? page = null)
public async Task<List<MovieDbSearchResult>> UpcomingMovies(string langCode, int? page = null)
{
var request = new Request($"discover/{type}", BaseUri, HttpMethod.Get);
var request = new Request($"discover/movie", BaseUri, HttpMethod.Get);
request.AddQueryString("api_key", ApiToken);
request.AddQueryString("language", langCode);
@ -313,7 +330,27 @@ namespace Ombi.Api.TheMovieDb
request.AddQueryString("page", page.ToString());
}
await AddDiscoverSettings(request);
await AddGenreFilter(request, type);
await AddGenreFilter(request, "movie");
AddRetry(request);
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
return Mapper.Map<List<MovieDbSearchResult>>(result.results);
}
public async Task<List<MovieDbSearchResult>> UpcomingTv(string langCode, int? page = null)
{
var request = new Request($"discover/tv", BaseUri, HttpMethod.Get);
request.AddQueryString("api_key", ApiToken);
request.AddQueryString("language", langCode);
// Search for shows that will air in the next month
var startDate = DateTime.Today.AddDays(1);
request.AddQueryString($"first_air_date.gte", startDate.ToString("yyyy-MM-dd"));
request.AddQueryString($"first_air_date.lte", startDate.AddDays(30).ToString("yyyy-MM-dd"));
if (page != null)
{
request.AddQueryString("page", page.ToString());
}
await AddDiscoverSettings(request);
await AddGenreFilter(request, "tv");
AddRetry(request);
var result = await Api.Request<TheMovieDbContainer<SearchResult>>(request);
return Mapper.Map<List<MovieDbSearchResult>>(result.results);

View file

@ -8,7 +8,7 @@
<div *ngFor="let feature of features">
<div class="row">
<div class="col-1">
<mat-slide-toggle [checked]="feature.enabled" (change)="updateFeature($event, feature)" id="enable"></mat-slide-toggle>
<mat-slide-toggle [checked]="feature.enabled" (change)="updateFeature($event, feature)" id="enable{{feature.name}}"></mat-slide-toggle>
</div>
<div class="col-2">
<h3>{{feature.name}}</h3>
@ -17,4 +17,4 @@
</div>
</div>
</div>
</div>
</div>

View file

@ -392,14 +392,14 @@ namespace Ombi.Controllers.V2
/// <summary>
/// Returns trending shows by page
/// </summary>
/// <remarks>We use Trakt.tv as the Provider</remarks>
/// <remarks>We use TheMovieDb as the Provider</remarks>
/// <returns></returns>
[HttpGet("tv/trending/{currentPosition}/{amountToLoad}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesDefaultResponseType]
public Task<IEnumerable<SearchTvShowViewModel>> Trending(int currentPosition, int amountToLoad)
public Task<IEnumerable<SearchTvShowViewModel>> TrendingTv(int currentPosition, int amountToLoad)
{
return _mediaCacheService.GetOrAddAsync(nameof(Trending) + currentPosition + amountToLoad,
return _mediaCacheService.GetOrAddAsync(nameof(TrendingTv) + currentPosition + amountToLoad,
() => _tvEngineV2.Trending(currentPosition, amountToLoad),
DateTimeOffset.Now.AddHours(12));
}

View file

@ -1,3 +1,3 @@
{
"version": "4.17.0"
"version": "4.20.0"
}