a movie signature object that is used as input to a dataprovider.
        public static MovieSignature parseMediaMatch(MovieMatch movieMatch)
        {
            lock (loadingLock) {
              if (signatureBuilders == null) {
                  signatureBuilders = new List<ISignatureBuilder>();
                  signatureBuilders.Add(new HashBuilder());
                  signatureBuilders.Add(new LocalBuilder());
                  signatureBuilders.Add(new BlurayMetaBuilder());
                  signatureBuilders.Add(new MetaServicesBuilder());
                  signatureBuilders.Add(new NfoBuilder());
                  signatureBuilders.Add(new ImdbBuilder());
              }
              }

              MovieSignature movieSignature = new MovieSignature(movieMatch.LocalMedia);
              foreach (ISignatureBuilder builder in signatureBuilders) {
              SignatureBuilderResult result = builder.UpdateSignature(movieSignature);
              // if a builder returns CONCLUSIVE it has updated the signature with
              // what is believed to be accurate data and we can exit the loop
              // Currently only the Hash and Imdb builder can return this status
              if (result == SignatureBuilderResult.CONCLUSIVE)
                  break;
              }

              return movieSignature;
        }
Ejemplo n.º 2
0
        public SignatureBuilderResult UpdateSignature(MovieSignature signature)
        {
            if (MovingPicturesCore.Settings.EnableDiscIdLookup || signature.DiscId == null)
            {
                return(SignatureBuilderResult.INCONCLUSIVE);
            }

            XmlNodeList mdrDVD = GetMovieMetaData(signature.DiscId);

            if (mdrDVD != null)
            {
                // todo: include more information?
                XmlNode nodeTitle = mdrDVD.Item(0).SelectSingleNode("dvdTitle");
                if (nodeTitle != null)
                {
                    string title = removeSuffix(nodeTitle.InnerText);
                    logger.Debug("Lookup DiscId={0}: Title= '{1}'", signature.DiscId, title);
                    signature.Title = removeSuffix(title);
                }
                else
                {
                    logger.Debug("Lookup DiscId={0}: no data available", signature.DiscId);
                }
            }

            return(SignatureBuilderResult.INCONCLUSIVE);
        }
Ejemplo n.º 3
0
        public SignatureBuilderResult UpdateSignature(MovieSignature signature)
        {
            if (signature.LocalMedia[0].IsBluray)
            {
                if (signature.LocalMedia[0].File.Directory.Exists)
                {
                    // verify our meta file exists
                    string metaFilePath = Path.Combine(signature.LocalMedia[0].File.DirectoryName, @"META\DL\bdmt_eng.xml");
                    if (!File.Exists(metaFilePath))
                    {
                        return(SignatureBuilderResult.INCONCLUSIVE);
                    }

                    try {
                        XPathDocument       metaXML   = new XPathDocument(metaFilePath);
                        XPathNavigator      navigator = metaXML.CreateNavigator();
                        XmlNamespaceManager ns        = new XmlNamespaceManager(navigator.NameTable);
                        ns.AddNamespace("", "urn:BDA:bdmv;disclib");
                        ns.AddNamespace("di", "urn:BDA:bdmv;discinfo");
                        navigator.MoveToFirst();
                        XPathNavigator node = navigator.SelectSingleNode("//di:discinfo/di:title/di:name", ns);
                        if (node != null)
                        {
                            string title = node.ToString().Trim();
                            if (title != string.Empty)
                            {
                                signature.Title = title;
                                logger.Debug("Lookup Bluray Metafile={0}: Title= '{1}'", metaFilePath, title);
                                return(SignatureBuilderResult.CONCLUSIVE);
                            }
                        }

                        // node or title not found in metafile
                        logger.Debug("Lookup Bluray Metafile={0}: No Title Found", metaFilePath);
                        return(SignatureBuilderResult.INCONCLUSIVE);
                    }
                    catch (Exception e) {
                        if (e is ThreadAbortException)
                        {
                            throw e;
                        }
                        logger.DebugException("Lookup Bluray Metafile=" + metaFilePath + ".", e);
                    }
                }
            }
            return(SignatureBuilderResult.INCONCLUSIVE);
        }
Ejemplo n.º 4
0
        public SignatureBuilderResult UpdateSignature(MovieSignature signature)
        {
            if (signature.LocalMedia == null)
                return SignatureBuilderResult.INCONCLUSIVE;

            DirectoryInfo dir = new DirectoryInfo(signature.Path);
            string fullPath = signature.LocalMedia[0].FullPath;
            int fileCount = signature.LocalMedia.Count;
            string source = string.Empty;

            if (Utility.isFolderDedicated(dir, fileCount) && (MovingPicturesCore.Settings.PreferFolderName || fileCount > 1) && signature.Folder.Length > 1 || signature.LocalMedia[0].IsVideoDisc) {

                // Use foldername
                source = signature.Folder;

                // If the foldername is a volume use the media label
                if (Utility.IsDriveRoot(source))
                    source = signature.LocalMedia[0].MediaLabel;

            } else {
                // Use filename
                if (fileCount > 1)
                    source = Utility.GetFileNameWithoutExtensionAndStackMarkers(signature.File);
                else
                    source = Path.GetFileNameWithoutExtension(signature.File);
            }

            // Detect IMDb ID in the source string, and put it in the signature on success
            Match match = Regex.Match(source, @"tt\d{7}", RegexOptions.IgnoreCase);
            if (match.Success) signature.ImdbId = match.Value;

            // Execute configured string replacements
            foreach (KeyValuePair<string, string> replacement in replacements)
                source = Regex.Replace(source, replacement.Key, replacement.Value);

            // Remove noise characters/words
            // todo: combine this into replacements when there's a configurable setting for the user
            source = removeNoise(source);

            // Detect year in a title string
            int year;
            signature.Title = extractYearFromTitle(source, out year);
            signature.Year = year;

            return SignatureBuilderResult.INCONCLUSIVE;
        }
        public List<DBMovieInfo> Get(MovieSignature movieSignature)
        {
            List<DBMovieInfo> results = new List<DBMovieInfo>();
            if (movieSignature == null)
                return results;

            string idMovie = getMovieID(movieSignature.File);
            if (idMovie == String.Empty)
                return results;

            DBMovieInfo movie = this.getMovieInfo(idMovie);
            if (movie == null)
                return results;

            results.Add(movie);
            return results;
        }
Ejemplo n.º 6
0
        public SignatureBuilderResult UpdateSignature(MovieSignature signature)
        {
            bool imdbLookup = MovingPicturesCore.Settings.EnableImdbPreSearch;

            // If there's no ImdbId in the signature return the signature immediatly
            if (!imdbLookup || String.IsNullOrEmpty(signature.ImdbId))
            {
                return(SignatureBuilderResult.INCONCLUSIVE);
            }

            // Try to retrieve the IMDb details page
            string detailsPage = getImdbDetailsPage(signature.ImdbId);

            // if we don't have a details page then return the signature
            if (String.IsNullOrEmpty(detailsPage))
            {
                return(SignatureBuilderResult.INCONCLUSIVE);
            }

            // See if we get a Title and Year from the title node
            Regex expr    = new Regex(@"<meta property=""og:title"" content=""([^\(]+?)\((?:TV )?(?:Video )?(\d{4})[\/IVX]*\).*?/>", RegexOptions.IgnoreCase);
            Match details = expr.Match(detailsPage);

            if (details.Success)
            {
                try {
                    signature.Title = details.Groups[1].Value;
                    signature.Year  = int.Parse(details.Groups[2].Value);
                    logger.Debug("Lookup Imdbid={0}: Title='{1}', Year={2}", signature.ImdbId, signature.Title, signature.Year);
                }
                catch (Exception e) {
                    logger.Error("Lookup Imdbid={0}: Failed. {1}", signature.ImdbId, e.Message);
                    return(SignatureBuilderResult.INCONCLUSIVE);
                }
            }
            else
            {
                logger.Debug("Lookup Imdbid={0}: Failed.", signature.ImdbId);
                return(SignatureBuilderResult.INCONCLUSIVE);
            }

            return(SignatureBuilderResult.CONCLUSIVE);
        }
        public List<DBMovieInfo> Get(MovieSignature movieSignature)
        {
            List<DBMovieInfo> results = new List<DBMovieInfo>();
               if (movieSignature == null)
               return results;

               if (movieSignature.ImdbId != null && movieSignature.ImdbId.Trim().Length == 9) {
               DBMovieInfo movie = getMovieInformation(movieSignature.ImdbId.Trim());
               if (movie != null) {
                   results.Add(movie);
                   return results;
               }
               }

               // grab results, if year based search comes up dry, search without a year
               results = Search(movieSignature.Title, movieSignature.Year);
               if (results.Count == 0) results = Search(movieSignature.Title);

               return results;
        }
Ejemplo n.º 8
0
        public SignatureBuilderResult UpdateSignature(MovieSignature signature)
        {
            bool hashLookup = MovingPicturesCore.Settings.EnableHashLookup;

            if (!hashLookup || String.IsNullOrEmpty(signature.MovieHash))
                return SignatureBuilderResult.INCONCLUSIVE;

            List<DBMovieInfo> movie = TheMovieDbProvider.GetMoviesByHashLookup(signature.MovieHash);
            if (movie.Count == 1) {
                signature.Title = movie[0].Title;
                signature.Year = movie[0].Year;
                signature.ImdbId = movie[0].ImdbID;
                logger.Debug("Lookup Hash={0}: Title='{2}', Year={3}, ImdbID={1}", signature.MovieHash, signature.ImdbId, signature.Title, signature.Year);
                return SignatureBuilderResult.CONCLUSIVE;
            }
            else {
                logger.Debug("Lookup Hash={0}: No exact match found. ({1} results)", signature.MovieHash, movie.Count);
                return SignatureBuilderResult.INCONCLUSIVE;
            }
        }
        public SignatureBuilderResult UpdateSignature(MovieSignature signature)
        {
            if (MovingPicturesCore.Settings.EnableDiscIdLookup || signature.DiscId == null)
                return SignatureBuilderResult.INCONCLUSIVE;

            XmlNodeList mdrDVD = GetMovieMetaData(signature.DiscId);
            if (mdrDVD != null) {
                // todo: include more information?
                XmlNode nodeTitle = mdrDVD.Item(0).SelectSingleNode("dvdTitle");
                if (nodeTitle != null) {
                    string title = removeSuffix(nodeTitle.InnerText);
                    logger.Debug("Lookup DiscId={0}: Title= '{1}'", signature.DiscId, title);
                    signature.Title = removeSuffix(title);
                }
                else {
                    logger.Debug("Lookup DiscId={0}: no data available", signature.DiscId);
                }
            }

            return SignatureBuilderResult.INCONCLUSIVE;
        }
        public SignatureBuilderResult UpdateSignature(MovieSignature signature)
        {
            if (signature.LocalMedia[0].IsBluray) {
                if (signature.LocalMedia[0].File.Directory.Exists) {

                    // verify our meta file exists
                    string metaFilePath = Path.Combine(signature.LocalMedia[0].File.DirectoryName, @"META\DL\bdmt_eng.xml");
                    if (!File.Exists(metaFilePath))
                        return SignatureBuilderResult.INCONCLUSIVE;

                    try {
                        XPathDocument metaXML = new XPathDocument(metaFilePath);
                        XPathNavigator navigator = metaXML.CreateNavigator();
                        XmlNamespaceManager ns = new XmlNamespaceManager(navigator.NameTable);
                        ns.AddNamespace("", "urn:BDA:bdmv;disclib");
                        ns.AddNamespace("di", "urn:BDA:bdmv;discinfo");
                        navigator.MoveToFirst();
                        XPathNavigator node = navigator.SelectSingleNode("//di:discinfo/di:title/di:name", ns);
                        if (node != null) {
                            string title = node.ToString().Trim();
                            if (title != string.Empty) {
                                signature.Title = title;
                                logger.Debug("Lookup Bluray Metafile={0}: Title= '{1}'", metaFilePath, title);
                                return SignatureBuilderResult.CONCLUSIVE;
                            }
                        }

                        // node or title not found in metafile
                        logger.Debug("Lookup Bluray Metafile={0}: No Title Found", metaFilePath);
                        return SignatureBuilderResult.INCONCLUSIVE;
                    }
                    catch (Exception e) {
                        if (e is ThreadAbortException)
                            throw e;
                        logger.DebugException("Lookup Bluray Metafile=" + metaFilePath + ".", e);
                    }
                }
            }
            return SignatureBuilderResult.INCONCLUSIVE;
        }
Ejemplo n.º 11
0
        public SignatureBuilderResult UpdateSignature(MovieSignature signature)
        {
            //bool hashLookup = MovingPicturesCore.Settings.EnableHashLookup;

            //if (!hashLookup || String.IsNullOrEmpty(signature.MovieHash))
            //    return SignatureBuilderResult.INCONCLUSIVE;

            //List<DBMovieInfo> movie = TheMovieDbProvider.GetMoviesByHashLookup(signature.MovieHash);
            //if (movie.Count == 1) {
            //    signature.Title = movie[0].Title;
            //    signature.Year = movie[0].Year;
            //    signature.ImdbId = movie[0].ImdbID;
            //    logger.Debug("Lookup Hash={0}: Title='{2}', Year={3}, ImdbID={1}", signature.MovieHash, signature.ImdbId, signature.Title, signature.Year);
            //    return SignatureBuilderResult.CONCLUSIVE;
            //}
            //else {
            //    logger.Debug("Lookup Hash={0}: No exact match found. ({1} results)", signature.MovieHash, movie.Count);
            //    return SignatureBuilderResult.INCONCLUSIVE;
            //}

            return(SignatureBuilderResult.INCONCLUSIVE);
        }
Ejemplo n.º 12
0
        public SignatureBuilderResult UpdateSignature(MovieSignature signature)
        {
            bool scanNFO = MovingPicturesCore.Settings.NfoScannerEnabled;

            // Scan for NFO files
            if (scanNFO && signature.Path != null && signature.LocalMedia != null)
            {
                DirectoryInfo dir = new DirectoryInfo(signature.Path);
                if (Utility.isFolderDedicated(dir, signature.LocalMedia.Count))
                {
                    // Scans base directory for all NFO extensions (Dedicated Folder)
                    signature.ImdbId = fileScanner(dir);
                }
                else
                {
                    // Scans base directory for specific filenames (Shared Folder)
                    string fileName = Utility.GetFileNameWithoutExtensionAndStackMarkers(signature.File);
                    signature.ImdbId = fileScanner(dir, fileName);
                }
            }

            return(SignatureBuilderResult.INCONCLUSIVE);
        }
Ejemplo n.º 13
0
        public SignatureBuilderResult UpdateSignature(MovieSignature signature)
        {
            bool imdbLookup = MovingPicturesCore.Settings.EnableImdbPreSearch;

            // If there's no ImdbId in the signature return the signature immediatly
            if (!imdbLookup | String.IsNullOrEmpty(signature.ImdbId))
                return SignatureBuilderResult.INCONCLUSIVE;

            // Try to retrieve the IMDB details page
            string detailsPage = getImdbDetailsPage(signature.ImdbId);

            // if we don't have a details page then return the signature
            if (String.IsNullOrEmpty(detailsPage))
                return SignatureBuilderResult.INCONCLUSIVE;

            // See if we get a Title and Year from the title node
            Regex expr = new Regex(@"<title>([^\(]+?)\((?:TV )?(?:Video )?(\d{4})[\/IVX]*\).*?</title>", RegexOptions.IgnoreCase);
            Match details = expr.Match(detailsPage);
            if (details.Success) {
                try {
                    signature.Title = details.Groups[1].Value;
                    signature.Year = int.Parse(details.Groups[2].Value);
                    logger.Debug("Lookup Imdbid={0}: Title='{1}', Year={2}", signature.ImdbId, signature.Title, signature.Year);
                }
                catch (Exception e) {
                    logger.Error("Lookup Imdbid={0}: Failed. {1}", signature.ImdbId, e.Message);
                    return SignatureBuilderResult.INCONCLUSIVE;
                }
            }
            else {
                logger.Debug("Lookup Imdbid={0}: Failed.", signature.ImdbId);
                return SignatureBuilderResult.INCONCLUSIVE;
            }

            return SignatureBuilderResult.CONCLUSIVE;
        }
 public List<DBMovieInfo> Get(MovieSignature movieSignature)
 {
     return new List<DBMovieInfo>();
 }
Ejemplo n.º 15
0
        public SignatureBuilderResult UpdateSignature(MovieSignature signature)
        {
            bool scanNFO = MovingPicturesCore.Settings.NfoScannerEnabled;

            // Scan for NFO files
            if (scanNFO && signature.Path != null && signature.LocalMedia != null) {
                DirectoryInfo dir = new DirectoryInfo(signature.Path);
                if (Utility.isFolderDedicated(dir, signature.LocalMedia.Count)) {
                    // Scans base directory for all NFO extensions (Dedicated Folder)
                    signature.ImdbId = fileScanner(dir);
                }
                else {
                    // Scans base directory for specific filenames (Shared Folder)
                    string fileName = Utility.GetFileNameWithoutExtensionAndStackMarkers(signature.File);
                    signature.ImdbId = fileScanner(dir, fileName);
                }
            }

            return SignatureBuilderResult.INCONCLUSIVE;
        }
 private void rescanButton_Click(object sender, EventArgs e)
 {
     MovieSignature signature = new MovieSignature();
     signature.Title = possibleMatchesCombo.Text;
     mediaMatch.Signature = signature;
     MovingPicturesCore.Importer.Reprocess(mediaMatch);
 }
        public List<DBMovieInfo> Get(MovieSignature movieSignature)
        {
            List<DBMovieInfo> results = new List<DBMovieInfo>();
            if (movieSignature == null)
                return results;

            DBMovieInfo movie = null;
            if (movieSignature.ImdbId != null)
                movie = getMovieByImdb(movieSignature.ImdbId);

            if (movie != null)
                results.Add(movie);
            else
                results = getMoviesByTitle(movieSignature.Title);

            return results;
        }
Ejemplo n.º 18
0
        public SignatureBuilderResult UpdateSignature(MovieSignature signature)
        {
            if (signature.LocalMedia == null)
            {
                return(SignatureBuilderResult.INCONCLUSIVE);
            }

            DirectoryInfo dir       = new DirectoryInfo(signature.Path);
            string        fullPath  = signature.LocalMedia[0].FullPath;
            int           fileCount = signature.LocalMedia.Count;
            string        source    = string.Empty;

            if (Utility.isFolderDedicated(dir, fileCount) && (MovingPicturesCore.Settings.PreferFolderName || fileCount > 1) && signature.Folder.Length > 1 || signature.LocalMedia[0].IsVideoDisc)
            {
                // Use foldername
                source = signature.Folder;

                // If the foldername is a volume use the media label
                if (Utility.IsDriveRoot(source))
                {
                    source = signature.LocalMedia[0].MediaLabel;
                }
            }
            else
            {
                // Use filename
                if (fileCount > 1)
                {
                    source = Utility.GetFileNameWithoutExtensionAndStackMarkers(signature.File);
                }
                else
                {
                    source = Path.GetFileNameWithoutExtension(signature.File);
                }
            }

            // Detect IMDb ID in the source string, and put it in the signature on success
            Match match = Regex.Match(source, @"tt\d{7}", RegexOptions.IgnoreCase);

            if (match.Success)
            {
                signature.ImdbId = match.Value;
            }

            // Execute configured string replacements
            foreach (KeyValuePair <string, string> replacement in replacements)
            {
                source = Regex.Replace(source, replacement.Key, replacement.Value);
            }

            // Remove noise characters/words
            // todo: combine this into replacements when there's a configurable setting for the user
            source = removeNoise(source);

            // Detect year in a title string
            int year;

            signature.Title = extractYearFromTitle(source, out year);
            signature.Year  = year;

            return(SignatureBuilderResult.INCONCLUSIVE);
        }
        public List<DBMovieInfo> Get(MovieSignature movieSignature)
        {
            if (scraper == null)
                return null;

            List<DBMovieInfo> rtn = new List<DBMovieInfo>();
            Dictionary<string, string> paramList = new Dictionary<string, string>();
            Dictionary<string, string> results;

            if (movieSignature.Title != null) paramList["search.title"] = movieSignature.Title;
            if (movieSignature.Keywords != null) paramList["search.keywords"] = movieSignature.Keywords;
            if (movieSignature.Year != null) paramList["search.year"] = movieSignature.Year.ToString();
            if (movieSignature.ImdbId != null) paramList["search.imdb_id"] = movieSignature.ImdbId;
            if (movieSignature.DiscId != null) paramList["search.disc_id"] = movieSignature.DiscId;
            if (movieSignature.MovieHash != null) paramList["search.moviehash"] = movieSignature.MovieHash;
            if (movieSignature.Path != null) paramList["search.basepath"] = movieSignature.Path;
            if (movieSignature.Folder != null) paramList["search.foldername"] = movieSignature.Folder;
            if (movieSignature.File != null) paramList["search.filename"] = movieSignature.File;

            //set higher level settings for script to use
            paramList["settings.defaultuseragent"] = MovingPicturesCore.Settings.UserAgent;
            paramList["settings.mepo_data"] = Config.GetFolder(Config.Dir.Config);

            // this variable is the filename without extension (and a second one without stackmarkers)
            if (!String.IsNullOrEmpty(movieSignature.File)) {
                paramList["search.filename_noext"] = Path.GetFileNameWithoutExtension(movieSignature.File);
                paramList["search.clean_filename"] = Utility.GetFileNameWithoutExtensionAndStackMarkers(movieSignature.File);
            }

            results = scraper.Execute("search", paramList);
            if (results == null) {
                logger.Error(Name + " scraper script failed to execute \"search\" node.");
                return rtn;
            }

            int count = 0;
            // The movie result is only valid if the script supplies a unique site
            while (results.ContainsKey("movie[" + count + "].site_id")) {
                string siteId;
                string prefix = "movie[" + count + "].";
                count++;

                // if the result does not yield a site id it's not valid so skip it
                if (!results.TryGetValue(prefix + "site_id", out siteId))
                    continue;

                // if this movie was already added skip it
                if (rtn.Exists(delegate(DBMovieInfo item) { return item.GetSourceMovieInfo(ScriptID).Identifier == siteId; }))
                    continue;

                // if this movie does not have a valid title, don't bother
                if (!results.ContainsKey(prefix + "title"))
                    continue;

                // We passed all checks so create a new movie object
                DBMovieInfo newMovie = new DBMovieInfo();

                // store the site id in the new movie object
                newMovie.GetSourceMovieInfo(ScriptID).Identifier = siteId;

                // Try to store all other fields in the new movie object
                foreach (DBField currField in DBField.GetFieldList(typeof(DBMovieInfo))) {
                    string value;
                    if (results.TryGetValue(prefix + currField.FieldName, out value))
                        currField.SetValue(newMovie, value.Trim());
                }

                // add the movie to our movie results list
                rtn.Add(newMovie);
            }

            return rtn;
        }
        public List<DBMovieInfo> Get(MovieSignature movieSignature)
        {
            List<DBSourceInfo> sources;
            lock (detailSources) sources = new List<DBSourceInfo>(detailSources);

            // Try each datasource (ordered by their priority) to get results
            List<DBMovieInfo> results = new List<DBMovieInfo>();
            foreach (DBSourceInfo currSource in sources) {
                if (currSource.IsDisabled(DataType.DETAILS))
                    continue;

                // if we have reached the minimum number of possible matches required, we are done
                if (results.Count >= MovingPicturesCore.Settings.MinimumMatches &&
                    MovingPicturesCore.Settings.MinimumMatches != 0)
                    break;

                // search with the current provider
                List<DBMovieInfo> newResults = currSource.Provider.Get(movieSignature);

                // tag the results with the current source
                foreach (DBMovieInfo currMovie in newResults)
                    currMovie.PrimarySource = currSource;

                // add results to our total result list and log what we found
                results.AddRange(newResults);
                logger.Debug("SEARCH: Title='{0}', Provider='{1}', Version={2}, Number of Results={3}", movieSignature.Title, currSource.Provider.Name, currSource.Provider.Version, newResults.Count);
            }

            return results;
        }
 public List<DBMovieInfo> Get(MovieSignature movieSignature)
 {
     throw new NotImplementedException();
 }