public async Task TranslateMovieFullAsync(MovieFull movieToTranslate, CancellationToken ct)
{
var watch = Stopwatch.StartNew();
try
{
await Task.Run(async () =>
{
var movie = await TmdbClient.GetMovieAsync(movieToTranslate.ImdbCode,
MovieMethods.Credits);
movieToTranslate.Title = movie?.Title;
movieToTranslate.Genres = movie?.Genres?.Select(a => a.Name).ToList();
movieToTranslate.DescriptionFull = movie?.Overview;
}, ct);
}
catch (Exception exception) when (exception is TaskCanceledException)
{
Logger.Debug(
"TranslateMovieFull cancelled.");
}
catch (Exception exception)
{
Logger.Error(
$"TranslateMovieFull: {exception.Message}");
throw;
}
finally
{
watch.Stop();
var elapsedMs = watch.ElapsedMilliseconds;
Logger.Debug(
$"TranslateMovieFull ({movieToTranslate.ImdbCode}) in {elapsedMs} milliseconds.");
}
}