mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
More Emby improvements !wip
This commit is contained in:
parent
207d5c8d60
commit
075b336430
3 changed files with 56 additions and 38 deletions
|
@ -104,9 +104,9 @@ namespace Ombi.Api.Emby
|
||||||
return await GetAll<EmbyMovie>("Movie", apiKey, userId, baseUri, true, startIndex, count);
|
return await GetAll<EmbyMovie>("Movie", apiKey, userId, baseUri, true, startIndex, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<EmbyItemContainer<EmbyEpisodes>> GetAllEpisodes(string apiKey, string userId, string baseUri)
|
public async Task<EmbyItemContainer<EmbyEpisodes>> GetAllEpisodes(string apiKey, int startIndex, int count, string userId, string baseUri)
|
||||||
{
|
{
|
||||||
return await GetAll<EmbyEpisodes>("Episode", apiKey, userId, baseUri);
|
return await GetAll<EmbyEpisodes>("Episode", apiKey, userId, baseUri, false, startIndex, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<EmbyItemContainer<EmbySeries>> GetAllShows(string apiKey, int startIndex, int count, string userId, string baseUri)
|
public async Task<EmbyItemContainer<EmbySeries>> GetAllShows(string apiKey, int startIndex, int count, string userId, string baseUri)
|
||||||
|
|
|
@ -73,11 +73,13 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
|
|
||||||
var movies = await _api.GetAllMovies(server.ApiKey, 0, 200, server.AdministratorId, server.FullUri);
|
var movies = await _api.GetAllMovies(server.ApiKey, 0, 200, server.AdministratorId, server.FullUri);
|
||||||
var totalCount = movies.TotalRecordCount;
|
var totalCount = movies.TotalRecordCount;
|
||||||
var processed = 0;
|
var processed = 1;
|
||||||
|
|
||||||
var mediaToAdd = new HashSet<EmbyContent>();
|
var mediaToAdd = new HashSet<EmbyContent>();
|
||||||
|
|
||||||
while (processed < totalCount)
|
while (processed < totalCount)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
foreach (var movie in movies.Items)
|
foreach (var movie in movies.Items)
|
||||||
{
|
{
|
||||||
|
@ -87,19 +89,28 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the next batch
|
// Get the next batch
|
||||||
movies = await _api.GetAllMovies(server.ApiKey, processed + 1, 200, server.AdministratorId, server.FullUri);
|
movies = await _api.GetAllMovies(server.ApiKey, processed, 200, server.AdministratorId, server.FullUri);
|
||||||
await _repo.AddRange(mediaToAdd);
|
await _repo.AddRange(mediaToAdd);
|
||||||
mediaToAdd.Clear();
|
mediaToAdd.Clear();
|
||||||
}
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TV Time
|
// TV Time
|
||||||
var tv = await _api.GetAllShows(server.ApiKey, 0, 200, server.AdministratorId, server.FullUri);
|
var tv = await _api.GetAllShows(server.ApiKey, 0, 200, server.AdministratorId, server.FullUri);
|
||||||
var totalTv = tv.TotalRecordCount;
|
var totalTv = tv.TotalRecordCount;
|
||||||
processed = 0;
|
processed = 1;
|
||||||
while (processed < totalTv)
|
while (processed < totalTv)
|
||||||
{
|
{
|
||||||
foreach (var tvShow in tv.Items)
|
foreach (var tvShow in tv.Items)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
processed++;
|
processed++;
|
||||||
if (string.IsNullOrEmpty(tvShow.ProviderIds?.Tvdb))
|
if (string.IsNullOrEmpty(tvShow.ProviderIds?.Tvdb))
|
||||||
{
|
{
|
||||||
|
@ -127,9 +138,16 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
{
|
{
|
||||||
_logger.LogDebug("We already have TV Show {0}", tvShow.Name);
|
_logger.LogDebug("We already have TV Show {0}", tvShow.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Get the next batch
|
// Get the next batch
|
||||||
tv = await _api.GetAllShows(server.ApiKey, processed + 1, 200, server.AdministratorId, server.FullUri);
|
tv = await _api.GetAllShows(server.ApiKey, processed, 200, server.AdministratorId, server.FullUri);
|
||||||
await _repo.AddRange(mediaToAdd);
|
await _repo.AddRange(mediaToAdd);
|
||||||
mediaToAdd.Clear();
|
mediaToAdd.Clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
{
|
{
|
||||||
var allEpisodes = await _api.GetAllEpisodes(server.ApiKey, 0, 200, server.AdministratorId, server.FullUri);
|
var allEpisodes = await _api.GetAllEpisodes(server.ApiKey, 0, 200, server.AdministratorId, server.FullUri);
|
||||||
var total = allEpisodes.TotalRecordCount;
|
var total = allEpisodes.TotalRecordCount;
|
||||||
var processed = 0;
|
var processed = 1;
|
||||||
var epToAdd = new HashSet<EmbyEpisode>();
|
var epToAdd = new HashSet<EmbyEpisode>();
|
||||||
while (processed < total)
|
while (processed < total)
|
||||||
{
|
{
|
||||||
|
@ -117,7 +117,7 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
|
|
||||||
await _repo.AddRange(epToAdd);
|
await _repo.AddRange(epToAdd);
|
||||||
epToAdd.Clear();
|
epToAdd.Clear();
|
||||||
allEpisodes = await _api.GetAllEpisodes(server.ApiKey, processed + 1, 200, server.AdministratorId, server.FullUri);
|
allEpisodes = await _api.GetAllEpisodes(server.ApiKey, processed, 200, server.AdministratorId, server.FullUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (epToAdd.Any())
|
if (epToAdd.Any())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue