private async Task <bool> ScrapeImageAsync(IScrapeSession session, string imdbCode, MovieImageSourceDto source, CancellationToken cancellationToken) { if (source is null) { return(false); } var scraper = _scrapers.FirstOrDefault(x => x.Source == source.Source); if (scraper is null) { return(false); } _logger.LogInformation("scraping {source} -> {value}", source.Source, source.Value); CreateMovieImageRequest image = null; try { image = await scraper.ScrapeImageAsync(imdbCode, source, cancellationToken); } catch (Exception e) { _logger.LogError(e, $"failed to scrape image {source.Source} -> {source.Value}"); } if (image is null) { return(false); } await session.CreateMovieImageAsync(image, cancellationToken); return(true); }