mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 12:59:39 -07:00
Made the episode check parallel
This commit is contained in:
parent
25b8e2e78b
commit
1fa32d29ea
1 changed files with 14 additions and 17 deletions
|
@ -27,6 +27,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
|
@ -91,8 +92,6 @@ namespace PlexRequests.Services.Jobs
|
||||||
// Parse the total amount of episodes
|
// Parse the total amount of episodes
|
||||||
int.TryParse(episodes.TotalSize, out totalSize);
|
int.TryParse(episodes.TotalSize, out totalSize);
|
||||||
|
|
||||||
currentPosition += ResultCount;
|
|
||||||
|
|
||||||
// Get all of the episodes in batches until we them all (Got'a catch 'em all!)
|
// Get all of the episodes in batches until we them all (Got'a catch 'em all!)
|
||||||
while (currentPosition < totalSize)
|
while (currentPosition < totalSize)
|
||||||
{
|
{
|
||||||
|
@ -103,9 +102,8 @@ namespace PlexRequests.Services.Jobs
|
||||||
|
|
||||||
var entities = new HashSet<PlexEpisodes>();
|
var entities = new HashSet<PlexEpisodes>();
|
||||||
|
|
||||||
foreach (var video in videoHashset)
|
Parallel.ForEach(videoHashset, video =>
|
||||||
{
|
{
|
||||||
|
|
||||||
// Get the individual episode Metadata (This is for us to get the TheTVDBId which also includes the episode number and season number)
|
// Get the individual episode Metadata (This is for us to get the TheTVDBId which also includes the episode number and season number)
|
||||||
var metadata = PlexApi.GetEpisodeMetaData(settings.PlexAuthToken, settings.FullUri, video.RatingKey);
|
var metadata = PlexApi.GetEpisodeMetaData(settings.PlexAuthToken, settings.FullUri, video.RatingKey);
|
||||||
|
|
||||||
|
@ -113,28 +111,27 @@ namespace PlexRequests.Services.Jobs
|
||||||
foreach (var metadataVideo in metadata.Video)
|
foreach (var metadataVideo in metadata.Video)
|
||||||
{
|
{
|
||||||
var epInfo = PlexHelper.GetSeasonsAndEpisodesFromPlexGuid(metadataVideo.Guid);
|
var epInfo = PlexHelper.GetSeasonsAndEpisodesFromPlexGuid(metadataVideo.Guid);
|
||||||
entities.Add(
|
entities.Add(new PlexEpisodes
|
||||||
new PlexEpisodes
|
{
|
||||||
{
|
EpisodeNumber = epInfo.EpisodeNumber,
|
||||||
EpisodeNumber = epInfo.EpisodeNumber,
|
EpisodeTitle = metadataVideo.Title,
|
||||||
EpisodeTitle = metadataVideo.Title,
|
ProviderId = epInfo.ProviderId,
|
||||||
ProviderId = epInfo.ProviderId,
|
RatingKey = metadataVideo.RatingKey,
|
||||||
RatingKey = metadataVideo.RatingKey,
|
SeasonNumber = epInfo.SeasonNumber,
|
||||||
SeasonNumber = epInfo.SeasonNumber,
|
ShowTitle = metadataVideo.GrandparentThumb
|
||||||
ShowTitle = metadataVideo.GrandparentThumb
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// Delete all of the current items
|
// Delete all of the current items
|
||||||
Repo.DeleteAll(TableName);
|
Repo.DeleteAll(TableName);
|
||||||
// TODO Fix the datatype mismatch...
|
|
||||||
// Insert the new items
|
// Insert the new items
|
||||||
var result = Repo.BatchInsert(entities, TableName, typeof(PlexEpisodes).GetPropertyNames());
|
var result = Repo.BatchInsert(entities, TableName, typeof(PlexEpisodes).GetPropertyNames());
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
Log.Error("Saving the plex episodes to the DB Failed");
|
Log.Error("Saving the Plex episodes to the DB Failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue