/// <summary> /// Get IMDB info by the media title /// </summary> /// <param name="title">Media title</param> /// <param name="bestMatch">Whether to automatically choose first popular result match or let the user choose</param> public Media getInfoByTitle(string title, bool bestMatch) { try { title = SCTVObjects.MediaHandler.FormatNameString(title); if (title.IndexOf("(") > 0) { title = title.Substring(0, title.IndexOf("(")); } //title = title.Replace("_", " "); //download the whole page, to be able to search it by regex string URL = imdbTitleSearchURL + HttpUtility.UrlEncode(title); StreamReader sr = new StreamReader(new WebClient().OpenRead(URL)); _FileContent = sr.ReadToEnd(); htmlCodes = new HTMLCodes(); Media media = new Media(); media.Title = title; return(getInfo(media, bestMatch)); } catch (Exception ex) { Tools.WriteToFile(ex); Media media = new Media(); media.Title = title; return(media); } }
/// <summary> /// Get IMDB info by the IMDB number /// </summary> /// <param name="imdbNum">imdb number</param> public Media getInfoByNumber(Media media) { //download the whole page, to be able to search it by regex string URL = imdbNumSearchURL + HttpUtility.UrlEncode(media.IMDBNum) + "/"; StreamReader sr = new StreamReader(new WebClient().OpenRead(URL)); _FileContent = sr.ReadToEnd(); _imdbNum = media.IMDBNum; htmlCodes = new HTMLCodes(); return(getInfo(media, false)); }