/// <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 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; }