diff --git a/MetaNodes/TheMovieDb/TVShowLookup.cs b/MetaNodes/TheMovieDb/TVShowLookup.cs index 56bc13d6..91de16fd 100644 --- a/MetaNodes/TheMovieDb/TVShowLookup.cs +++ b/MetaNodes/TheMovieDb/TVShowLookup.cs @@ -135,6 +135,8 @@ public class TVShowLookup : Node args.Logger?.ILog("Detected Original Language: " + result.OriginalLanguage); } + DownloadThumbnail(args, result.PosterPath); + args.UpdateVariables(Variables); return 1; @@ -158,6 +160,35 @@ public class TVShowLookup : Node // return (result.ShowName, result.Year); // } + + /// + /// Downloads the poster path + /// + /// the node parameteres + /// the poster path + private void DownloadThumbnail(NodeParameters args, string posterPath) + { + if (string.IsNullOrWhiteSpace(posterPath) == false) + { + try + { + string url = "https://image.tmdb.org/t/p/w500" + posterPath; + args.Logger?.ILog("Downloading poster: " + url); + using var httpClient = new HttpClient(); + using var stream = httpClient.GetStreamAsync(url).Result; + string file = Path.Combine(args.TempPath, Guid.NewGuid() + ".jpg"); + using var fileStream = new FileStream(file, FileMode.CreateNew); + stream.CopyTo(fileStream); + args.SetThumbnail(file); + args.Logger?.ILog("Set thumbnail: " + file); + //md.ArtJpeg = file; + } + catch (Exception) + { + // Ignored + } + } + } /// /// Looks up a show online ///