public static async Task <DiscordEmbed> GenerateMovieDetailsAsync(Movie movie, IMovieSearcher movieSearcher = null) { var embedBuilder = new DiscordEmbedBuilder() .WithTitle($"{movie.Title} {(!string.IsNullOrWhiteSpace(movie.ReleaseDate) && movie.ReleaseDate.Length >= 4 ? $"({movie.ReleaseDate.Split("T")[0].Substring(0, 4)})" : string.Empty)}") .WithTimestamp(DateTime.Now) .WithUrl($"https://www.themoviedb.org/movie/{movie.TheMovieDbId}") .WithThumbnail("https://i.imgur.com/44ueTES.png") .WithFooter("Powered by Requestrr"); if (!string.IsNullOrWhiteSpace(movie.Overview)) { embedBuilder.WithDescription(movie.Overview.Substring(0, Math.Min(movie.Overview.Length, 255)) + "(...)"); } if (!string.IsNullOrEmpty(movie.PosterPath) && movie.PosterPath.StartsWith("http", StringComparison.InvariantCultureIgnoreCase)) { embedBuilder.WithImageUrl(movie.PosterPath); } if (!string.IsNullOrWhiteSpace(movie.Quality)) { embedBuilder.AddField($"__{Language.Current.DiscordEmbedMovieQuality}__", $"{movie.Quality}p", true); } if (movieSearcher != null) { try { var details = await movieSearcher.GetMovieDetails(new MovieRequest(null, int.MinValue), movie.TheMovieDbId); if (!string.IsNullOrWhiteSpace(details.InTheatersDate)) { embedBuilder.AddField($"__{Language.Current.DiscordEmbedMovieInTheaters}__", $"{details.InTheatersDate}", true); } else if (!string.IsNullOrWhiteSpace(movie.ReleaseDate)) { embedBuilder.AddField($"__{Language.Current.DiscordEmbedMovieInTheaters}__", $"{DateTime.Parse(movie.ReleaseDate).ToString("MMMM dd yyyy", DateTimeFormatInfo.InvariantInfo)}", true); } if (!string.IsNullOrWhiteSpace(details.PhysicalReleaseName) && !string.IsNullOrWhiteSpace(details.PhysicalReleaseDate)) { embedBuilder.AddField($"__{details.PhysicalReleaseName} {Language.Current.DiscordEmbedMovieRelease}__", $"{details.PhysicalReleaseDate}", true); } } catch { // Ignore } } if (!string.IsNullOrWhiteSpace(movie.PlexUrl)) { embedBuilder.AddField($"__Plex__", $"[{Language.Current.DiscordEmbedMovieWatchNow}]({movie.PlexUrl})", true); } if (!string.IsNullOrWhiteSpace(movie.EmbyUrl)) { embedBuilder.AddField($"__Emby__", $"[{Language.Current.DiscordEmbedMovieWatchNow}]({movie.EmbyUrl})", true); } return(embedBuilder.Build()); }
public static async Task <Embed> GenerateMovieDetailsAsync(Movie movie, SocketUser user, IMovieSearcher movieSearcher = null) { var embedBuilder = new EmbedBuilder() .WithTitle($"{movie.Title} {(!string.IsNullOrWhiteSpace(movie.ReleaseDate) ? $"({movie.ReleaseDate.Split("T")[0].Substring(0, 4)})" : string.Empty)}") .WithDescription(movie.Overview.Substring(0, Math.Min(movie.Overview.Length, 255)) + "(...)") .WithFooter(user.Username, $"https://cdn.discordapp.com/avatars/{user.Id.ToString()}/{user.AvatarId}.png") .WithTimestamp(DateTime.Now) .WithUrl($"https://www.themoviedb.org/movie/{movie.TheMovieDbId}") .WithThumbnailUrl("https://i.imgur.com/44ueTES.png"); if (!string.IsNullOrEmpty(movie.PosterPath) && movie.PosterPath.StartsWith("http", StringComparison.InvariantCultureIgnoreCase)) { embedBuilder.WithImageUrl(movie.PosterPath); } if (!string.IsNullOrWhiteSpace(movie.Quality)) { embedBuilder.AddField("__Quality__", $"{movie.Quality}p", true); } if (!string.IsNullOrWhiteSpace(movie.PlexUrl)) { embedBuilder.AddField("__Plex__", $"[Watch now]({movie.PlexUrl})", true); } if (!string.IsNullOrWhiteSpace(movie.EmbyUrl)) { embedBuilder.AddField("__Emby__", $"[Watch now]({movie.EmbyUrl})", true); } if (movieSearcher != null) { try { var details = await movieSearcher.GetMovieDetails(movie.TheMovieDbId); if (!string.IsNullOrWhiteSpace(details.InTheatersDate)) { embedBuilder.AddField("__In Theaters__", $"{details.InTheatersDate}", true); } if (!string.IsNullOrWhiteSpace(details.PhysicalReleaseName) && !string.IsNullOrWhiteSpace(details.PhysicalReleaseDate)) { embedBuilder.AddField($"__{details.PhysicalReleaseName} Release__", $"{details.PhysicalReleaseDate}", true); } } catch { // Ignore } } return(embedBuilder.Build()); }