From a49b1066d35b664eb899be7c4d38d09066c14527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20T=C3=B6rcsv=C3=A1ri?= Date: Sat, 26 Mar 2016 17:47:35 +0100 Subject: [PATCH] fix (imdb): better toString --- NadekoBot/Classes/IMDB/ImdbMovie.cs | 28 ++++++++++++++++++++++++++-- NadekoBot/Modules/Searches.cs | 4 ++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/NadekoBot/Classes/IMDB/ImdbMovie.cs b/NadekoBot/Classes/IMDB/ImdbMovie.cs index a1930554..18bb3478 100644 --- a/NadekoBot/Classes/IMDB/ImdbMovie.cs +++ b/NadekoBot/Classes/IMDB/ImdbMovie.cs @@ -43,11 +43,35 @@ namespace NadekoBot.Classes.IMDB public Dictionary Aka { get; set; } - public string ToString + public override string ToString() + { + return "`Title:` **" + EnglishTitle + " (" + OriginalTitle + ")" + + "**\n`Year:` " + Year + + "**\n`Rating:` " + Rating + + "**\n`Genre:` " + GenresAsString + + "\n`Link:` " + ImdbURL + + "\n`Plot:` " + Plot.Substring(0, Plot.Length > 500 ? 500 : Plot.Length) + "..." + //"\n`img:` " + Poster //imdb url do it for us I think its a discord auto thing + ; + } + + public string EnglishTitle { get { - return ImdbURL + "\n" + OriginalTitle + " (" + Year + ") - " + Rating; + return Aka.ContainsKey("USA") ? Aka["USA"] : + (Aka.ContainsKey("UK") ? Aka["UK"] : + (Aka.ContainsKey("(original title)") ? Aka["(original title)"] : + (Aka.ContainsKey("(original)") ? Aka["(original)"] : OriginalTitle))); + } + } + public string GenresAsString + { + get + { + string ret = ""; + Genres.ForEach(g => ret = ret + " " + g); + return ret; } } } diff --git a/NadekoBot/Modules/Searches.cs b/NadekoBot/Modules/Searches.cs index 7f85297a..fc4c8115 100644 --- a/NadekoBot/Modules/Searches.cs +++ b/NadekoBot/Modules/Searches.cs @@ -96,8 +96,8 @@ $@"🌍 **Weather for** 【{obj["target"]}】 string result; try { - var movie = ImdbScraper.ImdbScrape(e.GetArg("query"), false); - if (movie.status) result = movie.ToString; + var movie = ImdbScraper.ImdbScrape(e.GetArg("query"), true); + if (movie.status) result = movie.ToString(); else result = "Failed to find that movie."; } catch