mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-02 05:04:15 -04:00
Refining exception handling of the crawler
This commit is contained in:
parent
fc65716906
commit
0728ef5e67
@ -51,8 +51,6 @@ namespace Kyoo.Controllers
|
||||
_transcoder = serviceProvider.GetService<ITranscoder>();
|
||||
_config = serviceProvider.GetService<IConfiguration>();
|
||||
|
||||
try
|
||||
{
|
||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||
await using ILibraryManager libraryManager = serviceScope.ServiceProvider.GetService<ILibraryManager>();
|
||||
ICollection<Episode> episodes = await libraryManager.GetEpisodes();
|
||||
@ -71,11 +69,6 @@ namespace Kyoo.Controllers
|
||||
library.Providers = library.Providers;
|
||||
|
||||
await Task.WhenAll(libraries.Select(x => Scan(x, episodes, cancellationToken)).ToArray());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await Console.Error.WriteLineAsync($"Unknown exception thrown durring libraries scan.\nException: {ex.Message}");
|
||||
}
|
||||
Console.WriteLine("Scan finished!");
|
||||
}
|
||||
|
||||
@ -135,6 +128,8 @@ namespace Kyoo.Controllers
|
||||
if (token.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||
await using ILibraryManager libraryManager = serviceScope.ServiceProvider.GetService<ILibraryManager>();
|
||||
|
||||
@ -157,13 +152,26 @@ namespace Kyoo.Controllers
|
||||
else
|
||||
{
|
||||
Season season = await GetSeason(libraryManager, show, seasonNumber, library);
|
||||
Episode episode = await GetEpisode(libraryManager, show, season, episodeNumber, absoluteNumber, path, library);
|
||||
Episode episode = await GetEpisode(libraryManager,
|
||||
show,
|
||||
season,
|
||||
episodeNumber,
|
||||
absoluteNumber,
|
||||
path,
|
||||
library);
|
||||
await libraryManager.RegisterEpisode(episode);
|
||||
}
|
||||
|
||||
await libraryManager.AddShowLink(show, library, collection);
|
||||
Console.WriteLine($"Episode at {path} registered.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await Console.Error.WriteLineAsync($"Unknown exception thrown while registering episode at {path}." +
|
||||
$"\nException: {ex.Message}" +
|
||||
$"\nAt {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<Collection> GetCollection(ILibraryManager libraryManager,
|
||||
string collectionName,
|
||||
|
Loading…
x
Reference in New Issue
Block a user