/// <summary> /// Download IMDB info for a movie. For existing movie using IMDBid from database. /// </summary> public static bool RefreshIMDB(IMDB.IProgress progress, ref IMDBMovie currentMovie, bool fuzzyMatching, bool getActors, bool addToDatabase) { if (currentMovie.Title != string.Empty || currentMovie.SearchString != string.Empty) { Log.Info("RefreshIMDB() - Refreshing MovieInfo for {0}-{1}", currentMovie.Title, currentMovie.SearchString); } string strMovieName = currentMovie.SearchString; string strFileName = string.Empty; string path = currentMovie.Path; string filename = currentMovie.File; _foldercheck = Util.Utils.IsFolderDedicatedMovieFolder(path); if (path != string.Empty) { if (path.EndsWith(@"\")) { path = path.Substring(0, path.Length - 1); currentMovie.Path = path; } if (filename.StartsWith(@"\")) { filename = filename.Substring(1); currentMovie.File = filename; } strFileName = path + @"\" + filename; } else { strFileName = filename; } if ((strMovieName == string.Empty) || (strMovieName == Strings.Unknown)) { strMovieName = currentMovie.Title; if ((strMovieName == string.Empty) || (strMovieName == Strings.Unknown)) { if (strFileName == string.Empty) { return true; } if (Util.Utils.IsDVD(strFileName)) { // DVD string strDrive = strFileName.Substring(0, 2); currentMovie.DVDLabel = Util.Utils.GetDriveName(strDrive); strMovieName = currentMovie.DVDLabel; } else if (strFileName.ToUpper().IndexOf(@"\VIDEO_TS\VIDEO_TS.IFO") >= 0) { // DVD folder string dvdFolder = strFileName.Substring(0, strFileName.ToUpper().IndexOf(@"\VIDEO_TS\VIDEO_TS.IFO")); currentMovie.DVDLabel = Path.GetFileName(dvdFolder); strMovieName = currentMovie.DVDLabel; } else if (strFileName.ToUpper().IndexOf(@"\BDMV\INDEX.BDMV") >= 0) { // BD folder string bdFolder = strFileName.Substring(0, strFileName.ToUpper().IndexOf(@"\BDMV\INDEX.BDMV")); currentMovie.DVDLabel = Path.GetFileName(bdFolder); strMovieName = currentMovie.DVDLabel; } else { // Movie - Folder title and new ->remove CDx from name using (Settings xmlreader = new MPSettings()) { bool preferFileName = xmlreader.GetValueAsBool("moviedatabase", "preferfilenameforsearch", false); if (_foldercheck && !preferFileName) { strMovieName = Path.GetFileName(Path.GetDirectoryName(strFileName)); } else { strMovieName = Path.GetFileNameWithoutExtension(strFileName); } // Test pattern (CD, DISC(K), Part, X-Y...) and remove it from filename var pattern = Util.Utils.StackExpression(); for (int i = 0; i < pattern.Length; i++) { if (_foldercheck == false && pattern[i].IsMatch(strMovieName)) { strMovieName = pattern[i].Replace(strMovieName, ""); } } } } } if ((strMovieName == string.Empty) || (strMovieName == Strings.Unknown)) { return true; } } if (currentMovie.ID == -1 && addToDatabase) { currentMovie.ID = VideoDatabase.AddMovieFile(strFileName); } currentMovie.SearchString = strMovieName; if (currentMovie.ID >= 0 || !addToDatabase) { if (!Win32API.IsConnectedToInternet()) { return false; } IMDBFetcher fetcher = new IMDBFetcher(progress); fetcher.Movie = currentMovie; fetcher._getActors = getActors; int selectedMovie = -1; do { if (!fetcher.Fetch(strMovieName)) { return false; } if (fuzzyMatching) { IMDB tmpImdb = new IMDB(); selectedMovie = fetcher.FuzzyMatch(tmpImdb.GetSearchString(fetcher.MovieName)); if (selectedMovie == -1 && fetcher.Count > 0) { if (!fetcher.OnSelectMovie(fetcher, out selectedMovie)) { return false; } if (selectedMovie == -1) { if (!fetcher.OnRequestMovieTitle(fetcher, out strMovieName)) { return false; } if (strMovieName == string.Empty) { return false; } } } else if (selectedMovie == -1) { if (!fetcher.OnMovieNotFound(fetcher)) { return false; } if (!fetcher.OnRequestMovieTitle(fetcher, out strMovieName)) { return false; } if (strMovieName == string.Empty) { return false; } } } else { if (fetcher.Count > 0) { // EPG - one result, get movie without ask if (fetcher.Count == 1 && !addToDatabase) { selectedMovie = 0; break; } int iMoviesFound = fetcher.Count; //GEMX 28.03.08: There should always be a choice to enter the movie manually // in case the 1 and only found name is wrong if (iMoviesFound > 0) { if (!fetcher.OnSelectMovie(fetcher, out selectedMovie)) { return false; } if (selectedMovie < 0) { if (!fetcher.OnRequestMovieTitle(fetcher, out strMovieName)) { return false; } if (strMovieName == string.Empty) { return false; } } } } else { if (!fetcher.OnMovieNotFound(fetcher)) { return false; } if (!fetcher.OnRequestMovieTitle(fetcher, out strMovieName)) { return false; } if (strMovieName == string.Empty) { return false; } } } } while (selectedMovie < 0); if (!fetcher.FetchDetails(selectedMovie, ref currentMovie, addToDatabase)) { return false; } IMDBMovie movieDetails = fetcher.Movie; if (movieDetails != null) { Log.Info("RefreshIMDB() - Found movie and added info for: {0} (Year: {1})", movieDetails.Title, movieDetails.Year); movieDetails.SearchString = strMovieName; currentMovie = movieDetails; return true; } if (fetcher.Movie == null) { fetcher.Movie = currentMovie; } return fetcher.OnDetailsNotFound(fetcher); } return false; }