Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/tidusjar/Ombi into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tidusjar committed Feb 5, 2022
2 parents cfb85c2 + 90ecb14 commit d390070
Show file tree
Hide file tree
Showing 20 changed files with 151 additions and 83 deletions.
37 changes: 19 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## [4.11.4](https://github.com/Ombi-app/Ombi/compare/v4.11.3...v4.11.4) (2022-02-05)


### Bug Fixes

* **media-sync:** Add sanity checks upon media server sync ([#4493](https://github.com/Ombi-app/Ombi/issues/4493)) ([9915234](https://github.com/Ombi-app/Ombi/commit/9915234d38d4701c527081ccc21b566980375331)), closes [#4472](https://github.com/Ombi-app/Ombi/issues/4472)
* **newsletter:** Fix newsletter not publishing double episodes ([#4495](https://github.com/Ombi-app/Ombi/issues/4495)) ([ddf63fb](https://github.com/Ombi-app/Ombi/commit/ddf63fbed0b9cbe458aec37318758c76b99b2de9))



## [4.11.3](https://github.com/Ombi-app/Ombi/compare/v4.11.2...v4.11.3) (2022-02-03)


### Bug Fixes

* **API:** Fixed an issue where the API key couldn't delete a request [#4489](https://github.com/Ombi-app/Ombi/issues/4489) ([8e42dbf](https://github.com/Ombi-app/Ombi/commit/8e42dbf8f78caa51ca891bf3d702c6b0ac401f9c))



## [4.11.2](https://github.com/Ombi-app/Ombi/compare/v4.11.1...v4.11.2) (2022-02-01)


Expand Down Expand Up @@ -356,21 +375,3 @@



## [4.2.10](https://github.com/Ombi-app/Ombi/compare/v4.2.9...v4.2.10) (2021-10-15)


### Bug Fixes

* :bug: Really really fix it this time? ([543d36e](https://github.com/Ombi-app/Ombi/commit/543d36e5615341bc8378cac377b843a3dbc1ef99))



## [4.2.9](https://github.com/Ombi-app/Ombi/compare/v4.2.8...v4.2.9) (2021-10-15)


### Bug Fixes

* :fire: Really fix the base url issue this time ([9f36923](https://github.com/Ombi-app/Ombi/commit/9f36923c51bfabf9cb026f2da14f9947050af0d9))



14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ Here are some of the features Ombi has:
</a>
</td></tr>
<tr>
<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/MrTopCat">
<img src="https://avatars.githubusercontent.com/u/774415?v=4" width="50;" alt="MrTopCat"/>
Expand All @@ -128,13 +135,6 @@ Here are some of the features Ombi has:
<sub><b>Shaun McPeck</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/MattJeanes">
<img src="https://avatars.githubusercontent.com/u/2363642?v=4" width="50;" alt="MattJeanes"/>
Expand Down
10 changes: 4 additions & 6 deletions src/Ombi.Api.Emby/Models/Media/EmbyProviderids.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
namespace Ombi.Api.Emby.Models.Movie
using Ombi.Api.MediaServer.Models;

namespace Ombi.Api.Emby.Models.Movie
{
public class EmbyProviderids
public class EmbyProviderids: BaseProviderids
{
public string Tmdb { get; set; }
public string Imdb { get; set; }
public string TmdbCollection { get; set; }

public string Tvdb { get; set; }
public string Zap2It { get; set; }
public string TvRage { get; set; }
}
Expand Down
1 change: 1 addition & 0 deletions src/Ombi.Api.Emby/Ombi.Api.Emby.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
<ProjectReference Include="..\Ombi.Api.MediaServer\Ombi.Api.MediaServer.csproj" />
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
</ItemGroup>

Expand Down
10 changes: 4 additions & 6 deletions src/Ombi.Api.Jellyfin/Models/Media/JellyfinProviderids.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
namespace Ombi.Api.Jellyfin.Models.Movie
using Ombi.Api.MediaServer.Models;

namespace Ombi.Api.Jellyfin.Models.Movie
{
public class JellyfinProviderids
public class JellyfinProviderids: BaseProviderids
{
public string Tmdb { get; set; }
public string Imdb { get; set; }
public string TmdbCollection { get; set; }

public string Tvdb { get; set; }
public string Zap2It { get; set; }
public string TvRage { get; set; }
}
Expand Down
1 change: 1 addition & 0 deletions src/Ombi.Api.Jellyfin/Ombi.Api.Jellyfin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
<ProjectReference Include="..\Ombi.Api.MediaServer\Ombi.Api.MediaServer.csproj" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions src/Ombi.Api.MediaServer/Models/BaseProviderids.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Ombi.Api.MediaServer.Models
{
public class BaseProviderids
{
public string Tmdb { get; set; }
public string Imdb { get; set; }
public string Tvdb { get; set; }
public bool Any() =>
!string.IsNullOrEmpty(Imdb) || !string.IsNullOrEmpty(Tmdb) || !string.IsNullOrEmpty(Tvdb);
}
}
18 changes: 18 additions & 0 deletions src/Ombi.Api.MediaServer/Ombi.Api.MediaServer.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.0.0.0</FileVersion>
<Version></Version>
<PackageVersion></PackageVersion>
<LangVersion>8.0</LangVersion>
<Configurations>Debug;Release;NonUiBuild</Configurations>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
</ItemGroup>

</Project>
8 changes: 7 additions & 1 deletion src/Ombi.Schedule/Jobs/Emby/EmbyContentSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private async Task ProcessTv(EmbyServers server, bool recentlyAdded, string pare
foreach (var tvShow in tv.Items)
{
processed++;
if (string.IsNullOrEmpty(tvShow.ProviderIds?.Tvdb))
if (!tvShow.ProviderIds.Any())
{
_logger.LogInformation("Provider Id on tv {0} is null", tvShow.Name);
continue;
Expand Down Expand Up @@ -249,6 +249,12 @@ private async Task ProcessMovies(EmbyMovie movieInfo, ICollection<EmbyContent> c
var alreadyGoingToAdd = content.Any(x => x.EmbyId == movieInfo.Id);
if (existingMovie == null && !alreadyGoingToAdd)
{

if (!movieInfo.ProviderIds.Any())
{
_logger.LogWarning($"Movie {movieInfo.Name} has no relevant metadata. Skipping.");
return;
}
_logger.LogDebug("Adding new movie {0}", movieInfo.Name);
content.Add(new EmbyContent
{
Expand Down
7 changes: 7 additions & 0 deletions src/Ombi.Schedule/Jobs/Emby/EmbyEpisodeSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ private async Task CacheEpisodes(EmbyServers server, bool recentlyAdded, string

if (existingEpisode == null && !existingInList)
{
// Sanity checks
if (ep.IndexNumber == 0)
{
_logger.LogWarning($"Episode {ep.Name} has no episode number. Skipping.");
continue;
}

_logger.LogDebug("Adding new episode {0} to parent {1}", ep.Name, ep.SeriesName);
// add it
epToAdd.Add(new EmbyEpisode
Expand Down
7 changes: 6 additions & 1 deletion src/Ombi.Schedule/Jobs/Jellyfin/JellyfinContentSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private async Task ProcessTv(JellyfinServers server, string parentId = default)
{

processed++;
if (string.IsNullOrEmpty(tvShow.ProviderIds?.Tvdb))
if (!tvShow.ProviderIds.Any())
{
_logger.LogInformation("Provider Id on tv {0} is null", tvShow.Name);
continue;
Expand Down Expand Up @@ -217,6 +217,11 @@ private async Task ProcessMovies(JellyfinMovie movieInfo, ICollection<JellyfinCo
var alreadyGoingToAdd = content.Any(x => x.JellyfinId == movieInfo.Id);
if (existingMovie == null && !alreadyGoingToAdd)
{
if (!movieInfo.ProviderIds.Any())
{
_logger.LogWarning($"Movie {movieInfo.Name} has no relevant metadata. Skipping.");
return;
}
_logger.LogDebug("Adding new movie {0}", movieInfo.Name);
content.Add(new JellyfinContent
{
Expand Down
9 changes: 8 additions & 1 deletion src/Ombi.Schedule/Jobs/Jellyfin/JellyfinEpisodeSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public JellyfinEpisodeSync(ISettingsService<JellyfinSettings> s, IJellyfinApiFac
public async Task Execute(IJobExecutionContext job)
{
var settings = await _settings.GetSettingsAsync();

Api = _apiFactory.CreateClient(settings);
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
.SendAsync(NotificationHub.NotificationEvent, "Jellyfin Episode Sync Started");
Expand Down Expand Up @@ -128,6 +128,13 @@ private async Task CacheEpisodes(JellyfinServers server, string parentIdFilter)

if (existingEpisode == null && !existingInList)
{
// Sanity checks
if (ep.IndexNumber == 0) // no check on season number, Season 0 can be Specials
{
_logger.LogWarning($"Episode {ep.Name} has no episode number. Skipping.");
continue;
}

_logger.LogDebug("Adding new episode {0} to parent {1}", ep.Name, ep.SeriesName);
// add it
epToAdd.Add(new JellyfinEpisode
Expand Down
62 changes: 40 additions & 22 deletions src/Ombi.Schedule/Jobs/Ombi/NewsletterJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -726,28 +726,8 @@ private async Task ProcessTv(IEnumerable<IMediaServerEpisode> episodes, string l

AddTvTitle(tvInfo);

// Group by the season number
var results = t.Episodes.GroupBy(p => p.SeasonNumber,
(key, g) => new
{
SeasonNumber = key,
Episodes = g.ToList(),
EpisodeAirDate = tvInfo?.seasons?.Where(x => x.season_number == key)?.Select(x => x.air_date).FirstOrDefault()
}
);

// Group the episodes
var finalsb = new StringBuilder();
foreach (var epInformation in results.OrderBy(x => x.SeasonNumber))
{
var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
var episodeString = StringHelper.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber));
var episodeAirDate = epInformation.EpisodeAirDate;
finalsb.Append($"{Texts.SeasonLabel} {epInformation.SeasonNumber} - {Texts.EpisodesLabel} {episodeString} {episodeAirDate}");
finalsb.Append("<br />");
}

AddTvEpisodesSummaryGenres(finalsb.ToString(), tvInfo);
var tvEpisodesString = GetTvEpisodesString(tvInfo, t.Episodes);
AddTvEpisodesSummaryGenres(tvEpisodesString, tvInfo);

}
catch (Exception e)
Expand All @@ -769,6 +749,44 @@ private async Task ProcessTv(IEnumerable<IMediaServerEpisode> episodes, string l
}
}

private string GetTvEpisodesString(TvInfo tvInfo, ICollection<IMediaServerEpisode> episodes)
{
if (episodes.Count >= tvInfo.number_of_episodes)
{
// do not list individual episodes when the series is complete
return string.Empty;
}

var sb = new StringBuilder();
// Group by the season number
var seasons = episodes.GroupBy(p => p.SeasonNumber,
(key, g) => new
{
SeasonNumber = key,
Episodes = g.ToList(),
Header = tvInfo?.seasons?.Where(x => x.season_number == key).FirstOrDefault(),
}
);
// Group the episodes
foreach (var season in seasons.OrderBy(x => x.SeasonNumber))
{
string episodeList;
if (season.Episodes.Count >= season.Header.episode_count)
{
// do not list individual episodes when the season is complete
episodeList = string.Empty;
}
else
{
var orderedEpisodes = season.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
episodeList = $"{Texts.EpisodesLabel} {StringHelper.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber))}";
}
var episodeAirDate = season.Header.air_date;
sb.Append($"{Texts.SeasonLabel} {season.SeasonNumber} - {episodeList} {episodeAirDate}");
sb.Append("<br />");
}
return sb.ToString();
}
private void AddTvTitle(TvInfo tvInfo)
{
var title = "";
Expand Down
5 changes: 5 additions & 0 deletions src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ public async Task MovieLoop(PlexServers servers, Mediacontainer content, HashSet
}
}

if (!guids.Any())
{
Logger.LogWarning($"Movie {movie.title} has no relevant metadata. Skipping.");
continue;
}
var providerIds = PlexHelper.GetProviderIdsFromMetadata(guids.ToArray());

var item = new PlexServerContent
Expand Down
7 changes: 7 additions & 0 deletions src/Ombi.Schedule/Jobs/Plex/PlexEpisodeSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ public async Task<HashSet<PlexEpisode>> ProcessEpsiodes(Metadata[] episodes, IQu
episode.grandparentRatingKey = seriesExists.Key;
}

// Sanity checks
if (episode.index == 0)
{
_log.LogWarning($"Episode {episode.title} has no episode number. Skipping.");
continue;
}

ep.Add(new PlexEpisode
{
EpisodeNumber = episode.index,
Expand Down
6 changes: 0 additions & 6 deletions src/Ombi.Store/Entities/EmbyEpisode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,5 @@ public override IMediaServerContent SeriesIsIn(ICollection<IMediaServerContent>
return content.OfType<EmbyContent>().FirstOrDefault(
x => x.EmbyId == this.EmbySeries.EmbyId);
}

public override bool IsIn(IMediaServerContent content)
{
return content.Episodes.Cast<EmbyEpisode>().Any(x => x.EmbyId == this.EmbyId);
}

}
}
5 changes: 0 additions & 5 deletions src/Ombi.Store/Entities/JellyfinEpisode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,5 @@ public override IMediaServerContent SeriesIsIn(ICollection<IMediaServerContent>
return content.OfType<JellyfinContent>().FirstOrDefault(
x => x.JellyfinId == this.JellyfinSeries.JellyfinId);
}

public override bool IsIn(IMediaServerContent content)
{
return content.Episodes.Cast<JellyfinEpisode>().Any(x => x.JellyfinId == this.JellyfinId);
}
}
}
8 changes: 5 additions & 3 deletions src/Ombi.Store/Entities/MediaServerContent.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using Ombi.Store.Repository;
using System.Linq;

namespace Ombi.Store.Entities
{
Expand Down Expand Up @@ -42,6 +41,9 @@ public abstract class MediaServerEpisode: Entity, IMediaServerEpisode
public IMediaServerContent Series { get; set; }

public abstract IMediaServerContent SeriesIsIn(ICollection<IMediaServerContent> content);
public abstract bool IsIn(IMediaServerContent content);
public bool IsIn(IMediaServerContent content)
{
return content.Episodes.Any(x => x.SeasonNumber == this.SeasonNumber && x.EpisodeNumber == this.EpisodeNumber);
}
}
}
6 changes: 0 additions & 6 deletions src/Ombi.Store/Entities/PlexEpisode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,5 @@ public override IMediaServerContent SeriesIsIn(ICollection<IMediaServerContent>
return content.OfType<PlexServerContent>().FirstOrDefault(
x => x.Key == this.PlexSeries.Key);
}

public override bool IsIn(IMediaServerContent content)
{
return content.Episodes.Cast<PlexEpisode>().Any(x => x.Key == this.Key);
}

}
}
Loading

0 comments on commit d390070

Please # to comment.