mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 12:59:39 -07:00
slightly increased the wait time for the emby newsletter
also fixed a potential error in the plex user checker
This commit is contained in:
parent
af023fb9d5
commit
7c37458e3b
2 changed files with 4 additions and 25 deletions
|
@ -31,6 +31,7 @@ using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using Ombi.Api.Interfaces;
|
using Ombi.Api.Interfaces;
|
||||||
|
using Ombi.Api.Models.Plex;
|
||||||
using Ombi.Core;
|
using Ombi.Core;
|
||||||
using Ombi.Core.SettingModels;
|
using Ombi.Core.SettingModels;
|
||||||
using Ombi.Core.Users;
|
using Ombi.Core.Users;
|
||||||
|
@ -89,7 +90,7 @@ namespace Ombi.Services.Jobs
|
||||||
var localUsers = LocalUserRepository.GetAll().ToList();
|
var localUsers = LocalUserRepository.GetAll().ToList();
|
||||||
|
|
||||||
// Regular users
|
// Regular users
|
||||||
foreach (var user in plexUsers.User)
|
foreach (var user in plexUsers?.User ?? new UserFriends[]{})
|
||||||
{
|
{
|
||||||
var dbUser = dbUsers.FirstOrDefault(x => x.PlexUserId == user.Id);
|
var dbUser = dbUsers.FirstOrDefault(x => x.PlexUserId == user.Id);
|
||||||
if (dbUser != null)
|
if (dbUser != null)
|
||||||
|
|
|
@ -159,9 +159,11 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
||||||
var i = Api.GetInformation(relatedSeries.EmbyId, Ombi.Api.Models.Emby.EmbyMediaType.Series,
|
var i = Api.GetInformation(relatedSeries.EmbyId, Ombi.Api.Models.Emby.EmbyMediaType.Series,
|
||||||
embySettings.ApiKey, embySettings.AdministratorId, embySettings.FullUri);
|
embySettings.ApiKey, embySettings.AdministratorId, embySettings.FullUri);
|
||||||
|
|
||||||
|
Thread.Sleep(200);
|
||||||
var episodeInfo = Api.GetInformation(embyEpisodes.EmbyId,
|
var episodeInfo = Api.GetInformation(embyEpisodes.EmbyId,
|
||||||
Ombi.Api.Models.Emby.EmbyMediaType.Episode,
|
Ombi.Api.Models.Emby.EmbyMediaType.Episode,
|
||||||
embySettings.ApiKey, embySettings.AdministratorId, embySettings.FullUri);
|
embySettings.ApiKey, embySettings.AdministratorId, embySettings.FullUri);
|
||||||
|
|
||||||
// Check if we already have this series
|
// Check if we already have this series
|
||||||
var existingSeries = recentlyAddedModel.FirstOrDefault(x =>
|
var existingSeries = recentlyAddedModel.FirstOrDefault(x =>
|
||||||
x.EmbyInformation.SeriesInformation.Id.Equals(i.SeriesInformation.Id,
|
x.EmbyInformation.SeriesInformation.Id.Equals(i.SeriesInformation.Id,
|
||||||
|
@ -197,35 +199,11 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
||||||
{
|
{
|
||||||
var i = Api.GetInformation(t.EmbyId, Ombi.Api.Models.Emby.EmbyMediaType.Series,
|
var i = Api.GetInformation(t.EmbyId, Ombi.Api.Models.Emby.EmbyMediaType.Series,
|
||||||
embySettings.ApiKey, embySettings.AdministratorId, embySettings.FullUri);
|
embySettings.ApiKey, embySettings.AdministratorId, embySettings.FullUri);
|
||||||
var ep = filteredEp.Where(x => x.ParentId == t.EmbyId).ToList();
|
|
||||||
var item = new EmbyRecentlyAddedModel
|
var item = new EmbyRecentlyAddedModel
|
||||||
{
|
{
|
||||||
EmbyContent = t,
|
EmbyContent = t,
|
||||||
EmbyInformation = i,
|
EmbyInformation = i,
|
||||||
};
|
};
|
||||||
if (ep.Any() && embySettings.EnableEpisodeSearching)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var episodeList = new List<EmbyEpisodeInformation>();
|
|
||||||
foreach (var embyEpisodese in ep)
|
|
||||||
{
|
|
||||||
var epInfo = Api.GetInformation(embyEpisodese.EmbyId,
|
|
||||||
Ombi.Api.Models.Emby.EmbyMediaType.Episode,
|
|
||||||
embySettings.ApiKey, embySettings.AdministratorId, embySettings.FullUri);
|
|
||||||
episodeList.Add(epInfo.EpisodeInformation);
|
|
||||||
Thread.Sleep(600); // Let's not try and overload the server
|
|
||||||
}
|
|
||||||
item.EpisodeInformation = episodeList;
|
|
||||||
}
|
|
||||||
catch (JsonReaderException)
|
|
||||||
{
|
|
||||||
Log.Error(
|
|
||||||
"Failed getting episode information, we may have overloaded Emby's api... Waiting and we will skip this one and go to the next");
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
info.Add(item);
|
info.Add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue