Beispiel #1
0
        private void GetInfoFromIMDB(ref IMDBMovie movieDetails, bool fuzzyMatch)
        {
            if (movieDetails == null)
            {
                Status = Utils.ImporterStatus.NONE;
                return;
            }

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

            int id = movieDetails.ID;

            if (id < 0)
            {
                logger.Info("Adding file to Database: {0}", file);
                id = VideoDatabase.AddMovieFile(file);
                VirtualDirectory dir = new VirtualDirectory();
                dir.SetExtensions(MediaPortal.Util.Utils.VideoExtensions);
                List <GUIListItem> items = dir.GetDirectoryUnProtectedExt(path, true);

                foreach (GUIListItem item in items)
                {
                    if (item.IsFolder)
                    {
                        continue;
                    }
                    if (MediaPortal.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);
                    }
                }

                movieDetails.ID = id;
                string searchString = movieDetails.SearchString;
                VideoDatabase.SetMovieInfoById(movieDetails.ID, ref movieDetails, true);
                movieDetails.SearchString = searchString;
            }

            /*
             * if (IMDBFetcher.RefreshIMDB(this, ref movieDetails, fuzzyMatch, true, true))
             * {
             * if (movieDetails != null)
             * {
             *  logger.Info("Movie info added:{0}", movieDetails.Title);
             * }
             * }
             */

            if (!Fetcher.FetchDetails(_selected, ref _moviedetails, true))
            {
                Status = Utils.ImporterStatus.NONE;
            }
        }