protected static MovieInfo FetchFilm(uint filmId, FetchOptions options = FetchOptions.None) { var movie = new MovieInfo(); var filmInfo = new Kinopoisk.FilmPage(filmId); movie.AllGenres = filmInfo.GetGenreList().ToArray(); movie.Budget = filmInfo.Budget; movie.MPAArating = filmInfo.MPAA; movie.Revenue = filmInfo.Revenue; movie.Runtime = filmInfo.Runtime; movie.Summary = Utils.UnHTML(filmInfo.Summary); movie.IMDBscore = filmInfo.IMDBScore; movie.Year = Utils.SafeYear(filmInfo.Year); movie.Local_Title = filmInfo.LocalTitle; movie.Original_Title = filmInfo.Title; // Added with plugin system version 2.1 var countries = filmInfo.GetContries(); if (countries.Count() > 0) movie.Country = string.Join(", ", countries); //public string Language = string.Empty; //public string ParentalRatingSummary = string.Empty; // Added with plugin system version 2.2 movie.TagLine = filmInfo.TagLine; movie.FullMPAA = filmInfo.FullMPAA; movie.PosterURL = filmInfo.GetOnlyPoster(); movie.BackdropURL = filmInfo.GetOnlyBackdrop(); movie.Director = string.Join(", ", filmInfo.GetCrew().Where(p => p.Type == "director").Select(p=>p.LocalName).ToArray()); movie.Writers = filmInfo.GetCrew().Where(p => p.Type == "writer").Select(p => p.LocalName).ToArray(); movie.NumberOfVotes = filmInfo.Rating.ImdbRating.Votes.ToString(); //public string FullCertifications = string.Empty; //public string Outline = string.Empty; //public string Plot = string.Empty; //public string Top250 = string.Empty; //public string Awards = string.Empty; //public string Website = string.Empty; //public string Trailer = string.Empty; if ((options & FetchOptions.FetchImages)==FetchOptions.FetchImages) { var link = filmInfo.GetOnlyBackdrop(); if (link != null) movie.Backdrop = Utils.SerializeBitmap(Utils.LoadPictureFromURI(link)); link = filmInfo.GetOnlyPoster(); if (link != null) movie.Poster = Utils.SerializeBitmap(Utils.LoadPictureFromURI(link)); } movie.AllCastAndCrew = ProcessCastAndCrew(filmInfo); //movie.IMDB_ID = Utils.ChopperBlank(sMoviePageContents, "<imdb>", "</imdb>"); //movie.Studios // not supported by tMDB API 2.0 return movie; }
/// <summary> /// Retrieves all data, posters, etc. for the media per its ID. The local ID will be the /// one returned in the list of IDs from SearchByTitleAndYear(). When available, the external /// ID will be an IMDB ID (will be string.Empty when unavailable). /// /// For plugin system 1.0, it is acceptable for this function to download thumbnails for /// cast/crew. A future version may move this to a new function. /// /// Required for: /// meta data fetches (all) /// </summary> /// <returns>A serialized MCM_Common.MovieInfo object (cannot be null)</returns> public static string FetchByIDs(string sLocalID, string sExternalID) { MovieInfo movie = new MovieInfo(); Match myMatch; //Set rating movie.MPAArating = "X-Rated"; if ((Utils.CInt(sLocalID) < 1) && (!string.IsNullOrEmpty(sExternalID))) { List<MovieResult> lstMovies = new List<MovieResult>(); try { string sContents = Utils.PageFetch("http://www.adultdvdempire.com/" + sExternalID.Replace("/", "")); if (sContents == "[timeout]") { Utils.Logger(Tag + "<color=#B00000><u><b>it appears that Adult DVD Empire is offline</b></u></color>"); return Utils.SerializeObject(movie); } if (sContents.StartsWith("[exception: ")) { Utils.Logger(Tag + "<color=#B00000><u><b>Adult DVD Empire is online, but experiencing technical difficulties</b></u></color>"); return Utils.SerializeObject(movie); } if (sContents.Contains("Your query didn't return any results")) { Utils.Logger(Tag + "<color=#B00000><u>no results (by title)</u></color>"); return Utils.SerializeObject(movie); } //Scrape the content sContents = Utils.prepareString(sContents); string confirm_movie_Title = ""; string confirm_movie_Year = ""; string confirm_movie_ID = ""; //Get title Regex myRegex = new Regex(Title, RegexOptions.IgnoreCase); myMatch = myRegex.Match(sContents); if (myMatch.Success) { //transform HTML escaped stuff confirm_movie_Title = Utils.UnHTML(myMatch.Groups[1].ToString()); } //Get SKU as movie ID myRegex = new Regex(SKU, RegexOptions.IgnoreCase); if (myMatch.Success) { confirm_movie_ID = myMatch.Groups[1].ToString(); } //get production year myRegex = new Regex(Year, RegexOptions.IgnoreCase); if (myMatch.Success) { confirm_movie_Year = myMatch.Groups[1].ToString(); } Utils.Logger(Tag + "Found #" + confirm_movie_ID + ", \"" + confirm_movie_Title + "\" (" + confirm_movie_Year + ")"); lstMovies.Add(new MovieResult() { ID = confirm_movie_ID, Title = confirm_movie_Title, Year = confirm_movie_Year }); } catch (Exception ex) { Utils.Logger(Utils.GetAllErrorDetails(ex)); } if (lstMovies.Count < 1) return Utils.SerializeObject(movie); sLocalID = lstMovies[0].ID; } try { string sMoviePageContents = Utils.PageFetch("http://www.adultdvdempire.com/" + sLocalID); sMoviePageContents = Utils.prepareString(sMoviePageContents); // This is a private function that will get a list of cast and crew as well as // download thumbnails, if the user so chooses (per AppSetting). movie.AllCastAndCrew = ProcessCastAndCrew(sMoviePageContents); //Extract categories Regex myRegex = new Regex(Category, RegexOptions.IgnoreCase); string category = ""; foreach (Match m in myRegex.Matches(sMoviePageContents)) { category += Utils.UnHTML(m.Groups[1].ToString()) + "|"; } category = category.Trim(); movie.AllGenres = Utils.SubStrings(category, "|"); //Get summary myRegex = new Regex(Synopsis, RegexOptions.IgnoreCase); myMatch = myRegex.Match(sMoviePageContents); if (myMatch.Success) { movie.Summary = Utils.UnHTML(myMatch.Groups[1].ToString()); } //Get front cover myRegex = new Regex(Frontcover, RegexOptions.IgnoreCase); myMatch = myRegex.Match(sMoviePageContents); if (myMatch.Success) { string url = myMatch.Groups[1].ToString(); movie.PosterURL = url; } //get studio myRegex = new Regex(Studio, RegexOptions.IgnoreCase); myMatch = myRegex.Match(sMoviePageContents); if (myMatch.Success) { movie.Studios = Utils.UnHTML(myMatch.Groups[1].ToString()); } //Get production year myRegex = new Regex(Year, RegexOptions.IgnoreCase); myMatch = myRegex.Match(sMoviePageContents); if (myMatch.Success) { movie.Year = myMatch.Groups[1].ToString(); } //Get title myRegex = new Regex(Title, RegexOptions.IgnoreCase); myMatch = myRegex.Match(sMoviePageContents); if (myMatch.Success) { movie.Title = Utils.UnHTML(myMatch.Groups[1].ToString()); } //Get runtime myRegex = new Regex(Runtime, RegexOptions.IgnoreCase); myMatch = myRegex.Match(sMoviePageContents); if (myMatch.Success) { string time = Utils.UnHTML(myMatch.Groups[1].ToString()); //ADVD reports time in x hours y mins format //Try to convert it to minutes string strRegex = @"(\d) h.* (\d*) m.*"; myRegex = new Regex(strRegex, RegexOptions.IgnoreCase); myMatch = myRegex.Match(time); { if (myMatch.Success) { int hrs = int.Parse( myMatch.Groups[1].ToString() ); int minutes = int.Parse( myMatch.Groups[2].ToString() ); time = ((hrs * 60) + minutes).ToString(); } } movie.Runtime = time; } //Get backdrops string backdrops = ""; myRegex = new Regex(Backdrop, RegexOptions.IgnoreCase); foreach (Match m in myRegex.Matches(sMoviePageContents)) { backdrops += m.Groups[1].ToString() + "|"; } backdrops = backdrops.Trim(); movie.Backdrops = Utils.SubStrings(backdrops, "|"); if (!string.IsNullOrEmpty(backdrops)) movie.BackdropURL = movie.Backdrops[0]; movie.TMDB_ID = sLocalID; } catch (Exception ex) { Utils.Logger(Tag + "Ooops, encountered exception: " + Utils.GetAllErrorDetails(ex)); } return Utils.SerializeObject(movie); }