mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 10:36:54 -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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using NLog;
|
||||
|
||||
|
@ -91,8 +92,6 @@ namespace PlexRequests.Services.Jobs
|
|||
// Parse the total amount of episodes
|
||||
int.TryParse(episodes.TotalSize, out totalSize);
|
||||
|
||||
currentPosition += ResultCount;
|
||||
|
||||
// Get all of the episodes in batches until we them all (Got'a catch 'em all!)
|
||||
while (currentPosition < totalSize)
|
||||
{
|
||||
|
@ -103,9 +102,8 @@ namespace PlexRequests.Services.Jobs
|
|||
|
||||
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)
|
||||
var metadata = PlexApi.GetEpisodeMetaData(settings.PlexAuthToken, settings.FullUri, video.RatingKey);
|
||||
|
||||
|
@ -113,28 +111,27 @@ namespace PlexRequests.Services.Jobs
|
|||
foreach (var metadataVideo in metadata.Video)
|
||||
{
|
||||
var epInfo = PlexHelper.GetSeasonsAndEpisodesFromPlexGuid(metadataVideo.Guid);
|
||||
entities.Add(
|
||||
new PlexEpisodes
|
||||
{
|
||||
EpisodeNumber = epInfo.EpisodeNumber,
|
||||
EpisodeTitle = metadataVideo.Title,
|
||||
ProviderId = epInfo.ProviderId,
|
||||
RatingKey = metadataVideo.RatingKey,
|
||||
SeasonNumber = epInfo.SeasonNumber,
|
||||
ShowTitle = metadataVideo.GrandparentThumb
|
||||
});
|
||||
entities.Add(new PlexEpisodes
|
||||
{
|
||||
EpisodeNumber = epInfo.EpisodeNumber,
|
||||
EpisodeTitle = metadataVideo.Title,
|
||||
ProviderId = epInfo.ProviderId,
|
||||
RatingKey = metadataVideo.RatingKey,
|
||||
SeasonNumber = epInfo.SeasonNumber,
|
||||
ShowTitle = metadataVideo.GrandparentThumb
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Delete all of the current items
|
||||
Repo.DeleteAll(TableName);
|
||||
// TODO Fix the datatype mismatch...
|
||||
|
||||
// Insert the new items
|
||||
var result = Repo.BatchInsert(entities, TableName, typeof(PlexEpisodes).GetPropertyNames());
|
||||
|
||||
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