public IMDBEnumerator(IMDB t) { _t = t; }
private void FindActor() { _imdb = new IMDB(); string line1 = GUILocalizeStrings.Get(197); ; //Querying IMDB info. string line2 = string.Empty; string line3 = string.Empty; OnProgress(line1, line2, line3, -1); _imdb.FindActor(_actor); }
public override void OnAdded() { base.OnAdded(); _imdb = new IMDB(this); // _currentFolder = null; g_Player.PlayBackStopped += new g_Player.StoppedHandler(OnPlayBackStopped); g_Player.PlayBackEnded += new g_Player.EndedHandler(OnPlayBackEnded); g_Player.PlayBackStarted += new g_Player.StartedHandler(OnPlayBackStarted); g_Player.PlayBackChanged += new g_Player.ChangedHandler(OnPlayBackChanged); GUIWindowManager.Receivers += new SendMessageHandler(GUIWindowManager_OnNewMessage); LoadSettings(); }
public static bool FetchMovieActors(IMDB.IProgress progress, IMDBMovie details) { IMDBFetcher fetcher = new IMDBFetcher(progress); fetcher._movieDetails = details; return fetcher.FetchActors(); }
/// <summary> /// Downloads actor info. /// Movie details can be empty (it is used to help update role for movie if role is empty) /// </summary> /// <param name="progress"></param> /// <param name="details"></param> /// <param name="actor"></param> /// <param name="actorId"></param> public static IMDBActor FetchMovieActor(IMDB.IProgress progress, IMDBMovie details, string actor, int actorId) { if (actor == string.Empty) return null; IMDBFetcher fetcher = new IMDBFetcher(progress); fetcher._movieDetails = details; // Find actor IMDB imdb = new IMDB(); // Don't search for actor if name is IMDBactorId (little speed up) if (!VideoDatabase.CheckActorImdbId(actor)) { imdb = fetcher.FindActor(actor); // Check for results if (imdb.Count > 0) { int i = 0; // If more than 1, invoke selection if (imdb.Count > 1) { if (!fetcher.OnSelectActor(fetcher, out i)) { return null; } } // Fetch actor details return fetcher.FetchActorDetails(actor, actorId, i); } } else // Direct get actor details (by actorImdbId) as name { fetcher._imdb.SetIMDBActor("http://www.imdb.com/name/" + actor, actor); return fetcher.FetchActorDetails(actor, actorId, 0); } return null; }
public static bool GetInfoFromIMDB(IMDB.IProgress progress, ref IMDBMovie movieDetails, bool isFuzzyMatching, bool getActors) { string file; string path = movieDetails.Path; string filename = movieDetails.File; if (path != string.Empty) { if (path.EndsWith(@"\")) { path = path.Substring(0, path.Length - 1); movieDetails.Path = path; } if (filename.StartsWith(@"\")) { filename = filename.Substring(1); movieDetails.File = filename; } file = path + Path.DirectorySeparatorChar + filename; } else { file = filename; } bool addToDB = true; int id = movieDetails.ID; if (id < 0) { if (File.Exists(file)) { id = VideoDatabase.AddMovieFile(file); VirtualDirectory dir = new VirtualDirectory(); dir.SetExtensions(Util.Utils.VideoExtensions); // Thumb creation spam no2 causing this call // // Temporary disable thumbcreation // using (Settings xmlreader = new MPSettings()) { _currentCreateVideoThumbs = xmlreader.GetValueAsBool("thumbnails", "tvrecordedondemand", true); } using (Settings xmlwriter = new MPSettings()) { xmlwriter.SetValueAsBool("thumbnails", "tvrecordedondemand", false); } List<GUIListItem> items = dir.GetDirectoryUnProtectedExt(path, true); foreach (GUIListItem item in items) { if (item.IsFolder) { continue; } if (Util.Utils.ShouldStack(item.Path, file) && item.Path != file) { string strPath, strFileName; DatabaseUtility.Split(item.Path, out strPath, out strFileName); DatabaseUtility.RemoveInvalidChars(ref strPath); DatabaseUtility.RemoveInvalidChars(ref strFileName); int pathId = VideoDatabase.AddPath(strPath); VideoDatabase.AddFile(id, pathId, strFileName); } } // Restore thumbcreation setting using (Settings xmlwriter = new MPSettings()) { xmlwriter.SetValueAsBool("thumbnails", "tvrecordedondemand", _currentCreateVideoThumbs); } movieDetails.ID = id; } else { Log.Info("File doesn't exists. So no info is stored in db."); getActors = false; addToDB = false; } } if (RefreshIMDB(progress, ref movieDetails, isFuzzyMatching, getActors, addToDB)) { if (movieDetails != null) { return true; } } return false; }
public IMDBFetcher(IMDB.IProgress progress) { _imdb = new IMDB(this); _progress = progress; }
/// <summary> /// Download IMDB info for all movies in a collection of paths /// </summary> public static bool ScanIMDB(IMDB.IProgress progress, ArrayList paths, bool fuzzyMatching, bool skipExisting, bool getActors, bool refreshDBonly) { bool success = true; ArrayList availableFiles = new ArrayList(); foreach (string path in paths) // Caution - Thumb creation spam no1 starts in CountFiles { VideoDatabase.GetVideoFiles(path, ref availableFiles); } if (progress != null) { progress.OnScanStart(availableFiles.Count); } int count = 1; foreach (string file in availableFiles) { if ((progress != null) && (!progress.OnScanIterating(count))) { success = false; break; } // Test pattern (CD, DISK, Part, X-Y...) and extrude last digit as set number check // Lets kill double check for the same movie if it consists from more than one file int digit = 0; // Only first file in set will proceed (cd1, part1, dvd1...) var pattern = Util.Utils.StackExpression(); for (int i = 0; i < pattern.Length; i++) { if (pattern[i].IsMatch(file)) { digit = Convert.ToInt16(pattern[i].Match(file).Groups["digit"].Value); } } try { IMDBMovie movieDetails = new IMDBMovie(); int id = VideoDatabase.GetMovieInfo(file, ref movieDetails); if (refreshDBonly && id != -1 && digit < 2) { string path, filename; Util.Utils.Split(file, out path, out filename); movieDetails.Path = path; movieDetails.File = filename; // Caution - Thumb creation spam no2 starts in GetInfoFromIMDB GetInfoFromIMDB(progress, ref movieDetails, fuzzyMatching, getActors); } else { if ((!skipExisting || id == -1) && refreshDBonly == false && digit < 2) { string path, filename; Util.Utils.Split(file, out path, out filename); movieDetails.Path = path; movieDetails.File = filename; // Caution - Thumb creation spam no2 starts in GetInfoFromIMDB GetInfoFromIMDB(progress, ref movieDetails, fuzzyMatching, getActors); } } } catch (Exception ex) { Log.Error("Scan IMDB err:{0} src:{1}, stack:{2}, ", ex.Message, ex.Source, ex.StackTrace); success = false; break; } if ((progress != null) && (!progress.OnScanIterated(count++))) { success = false; break; } } if (progress != null) { progress.OnScanEnd(); } return success; }
/// <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; }
/// <summary> /// Download IMDB info for videofile (file must be with full path) /// </summary> /// <param name="progress"></param> /// <param name="file"></param> /// <param name="fuzzyMatching"></param> /// <param name="skipExisting"></param> /// <param name="getActors"></param> /// <param name="refreshDBonly"></param> /// <returns></returns> public static bool ScanIMDB(IMDB.IProgress progress, string file, bool fuzzyMatching, bool skipExisting, bool getActors, bool refreshDBonly) { bool success = true; if (progress != null) { progress.OnScanStart(1); } int digit = 0; // Only first file in set will proceed (cd1, part1, dvd1...) var pattern = Util.Utils.StackExpression(); int stackSequence = 0; // seq 0 = [x-y], seq 1 = CD1, Part1.... for (int i = 0; i < pattern.Length; i++) { if (pattern[i].IsMatch(file)) { digit = Convert.ToInt16(pattern[i].Match(file).Groups["digit"].Value); } } try { IMDBMovie movieDetails = new IMDBMovie(); int id = VideoDatabase.GetMovieInfo(file, ref movieDetails); if (refreshDBonly && id != -1 && digit < 2) { string path, filename; Util.Utils.Split(file, out path, out filename); movieDetails.Path = path; movieDetails.File = filename; // Caution - Thumb creation spam no2 starts in GetInfoFromIMDB GetInfoFromIMDB(progress, ref movieDetails, fuzzyMatching, getActors); } else { if ((!skipExisting || id == -1) && refreshDBonly == false && digit < 2) { string path, filename; Util.Utils.Split(file, out path, out filename); movieDetails.Path = path; movieDetails.File = filename; // Caution - Thumb creation spam no2 starts in GetInfoFromIMDB GetInfoFromIMDB(progress, ref movieDetails, fuzzyMatching, getActors); } else if (digit > 1) // Add DVD or BD stack folders to existing movie { string path, filename; string tmpPath = string.Empty; DatabaseUtility.Split(file, out path, out filename); if (path.ToUpperInvariant().Contains(@"\VIDEO_TS") || path.ToUpperInvariant().Contains(@"\BDMV")) { try { if (stackSequence == 0) { string strReplace = "[" + digit; int stackIndex = path.LastIndexOf(strReplace); tmpPath = path.Remove(stackIndex, 2); tmpPath = tmpPath.Insert(stackIndex, "[1"); } else { int stackIndex = path.LastIndexOf(digit.ToString()); tmpPath = path.Remove(stackIndex, 1); tmpPath = tmpPath.Insert(stackIndex, "1"); } int movieId = VideoDatabase.GetMovieId(tmpPath + filename); int pathId = VideoDatabase.AddPath(path); VideoDatabase.AddFile(movieId, pathId, filename); } catch (Exception) { } } } } } catch (Exception ex) { Log.Error("Scan IMDB err:{0} src:{1}, stack:{2}, ", ex.Message, ex.Source, ex.StackTrace); success = false; } if (progress != null) { progress.OnScanEnd(); } return success; }
private void FetchActorsInMovie(bool updateMovieInfo) { ArrayList actors = new ArrayList(); if (_movieDetails == null) { return; } // Check for IMDBid if (VideoDatabase.CheckMovieImdbId(_movieDetails.IMDBNumber)) { // Returns nm1234567 as actor name (IMDB actorID) IMDB imdbActors = new IMDB(); imdbActors.GetIMDBMovieActorsList(_movieDetails.IMDBNumber, ref actors); } else { return; } if (actors.Count > 0) { // Clean old actors for movie VideoDatabase.RemoveActorsForMovie(_movieDetails.ID); for (int i = 0; i < actors.Count; ++i) { string actor = (string)actors[i]; string actorImdbId = string.Empty; string actorName = string.Empty; string role = string.Empty; bool director = false; char[] splitter = { '|' }; string[] temp = actor.Split(splitter); actorName = temp[0]; // Check if actor is movie director if (actorName.StartsWith("*d")) { actorName = actorName.Replace("*d", string.Empty); director = true; } actorImdbId = temp[1]; role = temp[2]; // Add actor and link actor to movie int actorId = VideoDatabase.AddActor(actorImdbId, actorName); if (actorId == -1) { continue; } VideoDatabase.AddActorToMovie(_movieDetails.ID, actorId, role); // Update director in movieinfo if (director) { _movieDetails.DirectorID = actorId; _movieDetails.Director = actorName; if (updateMovieInfo) { VideoDatabase.SetMovieInfoById(_movieDetails.ID, ref _movieDetails); } } } } }