コード例 #1
0
        private void ShowInfo(GUIListItem item)
        {
            if (item == null)
            {
                return;
            }

            try
            {
                NewMovie newmovie = item.AlbumInfoTag as NewMovie;
                if (newmovie != null)
                {
                    if (newmovie.MovieDetails != null)
                    {
                        IMDBMovie movie = (IMDBMovie)newmovie.MovieDetails;
                        // Open video info screen
                        GUIVideoInfo videoInfo = (GUIVideoInfo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIDEO_INFO);
                        videoInfo.Movie = movie;

                        GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_VIDEO_INFO);
                    }
                }
            }
            catch (System.Exception ex)
            {
                logger.Error("ShowInfo: " + ex.ToString());
            }
        }
コード例 #2
0
        private void FillProperties(GUIListItem item)
        {
            if (item == null)
            {
                ClearProperties();
                return;
            }

            NewMovie movie = null;

            if (item.AlbumInfoTag != null)
            {
                movie = item.AlbumInfoTag as NewMovie;
                Utils.SetProperty("#importer.title", movie.Title);
                Utils.SetProperty("#importer.file", movie.MovieDetails.File);
                Utils.SetProperty("#importer.path", movie.MovieDetails.Path);
                Utils.SetProperty("#importer.status", movie.Status.ToString().ToLowerInvariant());
                Utils.SetProperty("#importer.textstatus", Utils.GetStatus(movie.Status));
                Utils.SetProperty("#importer.progress", movie.Progress);
                Utils.SetProperty("#importer.view", viewLevel.ToString().ToLowerInvariant());
                Utils.SetProperty("#importer.hasnearest", movie.HasNearest ? "true" : "false");
                if (movie.Selected > -1 && movie.Selected < movie.GrabberMovies.Count)
                {
                    Utils.SetProperty("#importer.selected", movie.GrabberMovies[movie.Selected].Title);
                }
                FillMovieProperties(movie.MovieDetails);
            }

            if (viewLevel == Utils.ViewLevel.Movies)
            {
                FillGrabberProperties(ref item, movie);
            }
        }
コード例 #3
0
        private void UpdateFiles()
        {
            if (facadeLayout == null)
            {
                return;
            }

            if (videoImporter == null)
            {
                return;
            }

            if (facadeLayout.Count != videoImporter.MovieList.Count)
            {
                LoadList(null);
                return;
            }

            if (videoImporter.MovieList.Count > 0)
            {
                for (int i = 0; i < facadeLayout.Count; ++i)
                {
                    GUIListItem item  = facadeLayout[i];
                    NewMovie    movie = videoImporter.MovieList[i]; // item.AlbumInfoTag as NewMovie;
                    item.Label        = movie.Title;
                    item.Label2       = Utils.GetStatus(movie.Status);
                    item.AlbumInfoTag = movie;
                    SetStatus(ref item, movie);
                }
            }
            else
            {
                GUIListItem _item = GetSelectedItem();
                if (_item == null)
                {
                    return;
                }

                if (videoImporter.IsScanning)
                {
                    _item.Label = Translation.IMDBScanning;
                    _item.TVTag = Utils.ItemType.Search;
                }
                else
                {
                    _item.Label = Translation.FilesNotFound;
                    _item.TVTag = Utils.ItemType.Rescan;
                }
                _item.Label2   = string.Empty;
                _item.IsFolder = true;
                SetStatus(ref _item);
            }
            FillProperties(GetSelectedItem());
        }
コード例 #4
0
        private void RenameInMovieList(string filename, string newfilename)
        {
            lock (((ICollection)movielist).SyncRoot)
            {
                NewMovie newmovie = movielist.FirstOrDefault(x => x.FileName == filename);
                if (newmovie != null)
                {
                    newmovie.NewFileName = newfilename;

                    logger.Debug("Watcher rename file {0} -> {1} in the file list.", filename, newfilename);
                    Utils.UpdateImporterProperties(movielist.Count, HasUnComplete());
                }
            }
        }
コード例 #5
0
        private void RemoveFromMovieList(string filename)
        {
            lock (((ICollection)movielist).SyncRoot)
            {
                NewMovie newmovie = movielist.FirstOrDefault(x => x.FileName == filename);
                if (newmovie != null)
                {
                    newmovie.Fetcher.CancelFetch();
                    Thread.Sleep(100);
                    newmovie.Status = Utils.ImporterStatus.NONE;
                    movielist.Remove(newmovie);

                    logger.Debug("Watcher remove {0} from the file list.", filename);
                    Utils.UpdateImporterProperties(movielist.Count, HasUnComplete());
                }
            }
        }
コード例 #6
0
        private void ProcessQueue()
        {
            try
            {
                while (true)
                {
                    Thread.Sleep(1000);
                    if (movielist.Count == 0)
                    {
                        continue;
                    }

                    lock (((ICollection)movielist).SyncRoot)
                    {
                        if (movielist.Count(m => m.IsGettingInfo) == 0)
                        {
                            NewMovie movie = movielist.FirstOrDefault(m => m.Status == Utils.ImporterStatus.QUEUED_IMDB);
                            if (movie != null)
                            {
                                logger.Debug("Starting search IMDB info for {0} - {1}.", movie.MovieDetails.SearchString, movie.FileName);
                                movie.StartFetch();
                            }
                            else
                            {
                                movie = movielist.FirstOrDefault(m => m.Status == Utils.ImporterStatus.QUEUED_INFO);
                                if (movie != null)
                                {
                                    logger.Debug("Starting fetch IMDB details for {0}: {1} - {2}.", movie.Selected, movie.MovieDetails.SearchString, movie.FileName);
                                    movie.StartFetchDetails();
                                }
                            }
                        }
                    }
                    Utils.UpdateImporterProperties(movielist.Count, HasUnComplete());
                }
            }
            catch (ThreadAbortException)
            {
            }
        }
コード例 #7
0
        private void FillGrabberProperties(ref GUIListItem item, NewMovie movie)
        {
            if (item == null)
            {
                return;
            }
            if (movie == null)
            {
                return;
            }

            if (item.ItemId > -1 && item.ItemId < movie.GrabberMovies.Count)
            {
                Utils.SetProperty("#importer.grabber.title", movie.GrabberMovies[item.ItemId].GrabberTitle);
                Utils.SetProperty("#importer.grabber.year", movie.GrabberMovies[item.ItemId].GrabberYear);
                Utils.SetProperty("#importer.grabber.imdbtitle", movie.GrabberMovies[item.ItemId].GrabberIMDBTitle);
                Utils.SetProperty("#importer.grabber.imdbyear", movie.GrabberMovies[item.ItemId].GrabberIMDBYear);
                Utils.SetProperty("#importer.grabber.imdbid", movie.GrabberMovies[item.ItemId].GrabberIMDBId);
                Utils.SetProperty("#importer.grabber.distance", movie.GrabberMovies[item.ItemId].Distance.ToString());
                Utils.SetProperty("#importer.grabber.nearest", movie.GrabberMovies[item.ItemId].IsNearest ? "true" : "false");
                Utils.SetProperty("#importer.grabber.equals", movie.GrabberMovies[item.ItemId].IsEquals ? "true" : "false");
            }
        }
コード例 #8
0
        private void AddToMovieList(string filename)
        {
            lock (((ICollection)movielist).SyncRoot)
            {
                NewMovie newmovie = movielist.FirstOrDefault(x => x.FileName == filename);
                if (newmovie == null)
                {
                    newmovie = ShouldStack(filename);
                    if (newmovie != null)
                    {
                        logger.Debug("Stacked file {0} skip.", filename);
                        return;
                    }

                    newmovie          = new NewMovie(filename);
                    newmovie.FileName = filename;
                    newmovie.Status   = Utils.ImporterStatus.QUEUED_IMDB;
                    movielist.Add(newmovie);

                    logger.Debug("Add new file {0} to IMDB fetch queue.", filename);
                    Utils.UpdateImporterProperties(movielist.Count, HasUnComplete());
                }
            }
        }
コード例 #9
0
        private void SetStatus(ref GUIListItem item, NewMovie movie)
        {
            if (movie == null)
            {
                SetStatus(ref item);
                return;
            }

            // Movie items ...
            if (item == null)
            {
                return;
            }

            // Complete
            item.IsPlayed = (movie.Status == Utils.ImporterStatus.COMPLETE);

            // Download
            if (viewLevel == Utils.ViewLevel.Movies)
            {
                if (movie.Selected == item.ItemId)
                {
                    item.IsDownloading = !(movie.Status == Utils.ImporterStatus.COMPLETE);
                }
                else
                {
                    item.IsDownloading = false;
                }
            }

            // Progress
            if (movie.ProgressPercent > 0)
            {
                if (viewLevel == Utils.ViewLevel.Movies)
                {
                    if (movie.Selected == item.ItemId)
                    {
                        item.HasProgressBar        = true;
                        item.ProgressBarPercentage = movie.ProgressPercent;
                    }
                    else
                    {
                        item.HasProgressBar = false;
                    }
                }
                else
                {
                    item.HasProgressBar        = true;
                    item.ProgressBarPercentage = movie.ProgressPercent;
                }
            }
            else
            {
                item.HasProgressBar = false;
            }

            // Icon
            if (viewLevel == Utils.ViewLevel.Movies && (movie.IsScanning || movie.IsComplete))
            {
                if (movie.Selected == item.ItemId)
                {
                    item.IconImage = Utils.GetIcon(movie.Status);
                }
                else
                {
                    item.IconImage = Utils.GetIcon(Utils.ImporterStatus.SKIP);
                }
            }
            else
            {
                item.IconImage = Utils.GetIcon(movie.Status);
            }
            item.IconImageBig   = item.IconImage;
            item.ThumbnailImage = item.IconImage;
        }
コード例 #10
0
        private void UpdateMovies()
        {
            if (facadeLayout == null)
            {
                return;
            }

            if (videoImporter == null)
            {
                return;
            }
            if (videoImporter.MovieList == null)
            {
                return;
            }

            GUIListItem item = GetSelectedItem();

            if (facadeLayout.Count != videoImporter.MovieList.Count)
            {
                LoadList(item);
                return;
            }

            if (item == null)
            {
                return;
            }

            NewMovie newmovie = item.AlbumInfoTag as NewMovie;

            if (newmovie != null)
            {
                if (newmovie.GrabberMovies != null && newmovie.GrabberMovies.Count > 0)
                {
                    for (int i = 0; i < newmovie.GrabberMovies.Count; ++i)
                    {
                        GUIListItem _item = facadeLayout[i];
                        _item.Label  = newmovie.GrabberMovies[i].Title;
                        _item.Label2 = newmovie.Fetcher[i].Database;
                        _item.TVTag  = Utils.ItemType.IMDB;
                        SetStatus(ref _item, newmovie);
                    }
                }
                else
                {
                    if (newmovie.IsScanning)
                    {
                        item.Label  = Translation.IMDBScanning;
                        item.Label2 = string.Empty;
                        item.TVTag  = Utils.ItemType.Search;
                    }
                    else
                    {
                        item.Label  = Translation.IMDBNotFound;
                        item.Label2 = string.Empty;
                        item.TVTag  = Utils.ItemType.Research;
                    }
                    SetStatus(ref item, newmovie);
                }
            }
            else
            {
                item.Label  = Translation.IMDBNotFound;
                item.Label2 = string.Empty;
                item.TVTag  = Utils.ItemType.Research;
                SetStatus(ref item);
            }
        }
コード例 #11
0
        private void LoadList(GUIListItem item)
        {
            if (facadeLayout == null)
            {
                return;
            }

            if (videoImporter == null)
            {
                return;
            }

            int    newSelectedIndex = parentSelectedIndex;
            int    oldSelectedIndex = facadeLayout.SelectedListItemIndex;
            int    count            = 1;
            string module           = Translation.Base;

            GUIListItem _item = null;

            facadeLayout.CurrentLayout = CurrentLayout;
            facadeLayout.Clear();

            if (item == null) // Files
            {
                viewLevel  = Utils.ViewLevel.Files;
                parentItem = null;

                if (videoImporter.MovieList.Count > 0)
                {
                    foreach (NewMovie movie in videoImporter.MovieList)
                    {
                        _item                 = new GUIListItem();
                        _item.Label           = movie.Title;
                        _item.Label2          = Utils.GetStatus(movie.Status);
                        _item.TVTag           = Utils.ItemType.File;
                        _item.AlbumInfoTag    = movie;
                        _item.IsFolder        = true;
                        _item.OnItemSelected += OnItemSelected;
                        SetStatus(ref _item, movie);
                        facadeLayout.Add(_item);
                    }
                    count = videoImporter.MovieList.Count;
                }
                else
                {
                    _item = new GUIListItem();
                    if (videoImporter.IsScanning)
                    {
                        _item.Label = Translation.IMDBScanning;
                        _item.TVTag = Utils.ItemType.Search;
                    }
                    else
                    {
                        _item.Label = Translation.FilesNotFound;
                        _item.TVTag = Utils.ItemType.Rescan;
                    }
                    _item.Label2          = string.Empty;
                    _item.IsFolder        = true;
                    _item.OnItemSelected += OnItemSelected;
                    SetStatus(ref _item);
                    facadeLayout.Add(_item);
                }
            }
            else
            {
                // module = module + ": " + item.Label;
                // module = item.Label;
                module = Translation.Movie;

                viewLevel           = Utils.ViewLevel.Movies;
                parentItem          = item;
                parentSelectedIndex = oldSelectedIndex;
                newSelectedIndex    = 0;

                NewMovie newmovie = item.AlbumInfoTag as NewMovie;
                if (newmovie != null)
                {
                    if (newmovie.GrabberMovies.Count > 0)
                    {
                        for (int i = 0; i < newmovie.GrabberMovies.Count; ++i)
                        {
                            _item                 = new GUIListItem();
                            _item.ItemId          = i;
                            _item.Label           = newmovie.GrabberMovies[i].Title;
                            _item.Label2          = newmovie.Fetcher[i].Database;
                            _item.TVTag           = Utils.ItemType.IMDB;
                            _item.AlbumInfoTag    = newmovie;
                            _item.OnItemSelected += OnItemSelected;
                            SetStatus(ref _item, newmovie);
                            facadeLayout.Add(_item);
                        }
                        count = newmovie.GrabberMovies.Count;

                        /*
                         * if (newmovie.IsScanning)
                         * {
                         * _item = new GUIListItem();
                         * _item.ItemId = -1;
                         * _item.Label = Translation.Stop;
                         * _item.Label2 = string.Empty;
                         * _item.TVTag = Utils.ItemType.Stop;
                         * _item.AlbumInfoTag = newmovie;
                         * _item.OnItemSelected += OnItemSelected;
                         * SetStatus(ref _item);
                         * facadeLayout.Add(_item);
                         * }
                         */
                    }
                    else
                    {
                        _item = new GUIListItem();
                        if (newmovie.IsScanning)
                        {
                            _item.Label = Translation.IMDBScanning;
                            _item.TVTag = Utils.ItemType.Search;
                        }
                        else
                        {
                            _item.Label = Translation.IMDBNotFound;
                            _item.TVTag = Utils.ItemType.Research;
                        }
                        _item.Label2          = string.Empty;
                        _item.OnItemSelected += OnItemSelected;
                        _item.AlbumInfoTag    = newmovie;
                        SetStatus(ref _item, newmovie);
                        facadeLayout.Add(_item);
                    }
                }
                else
                {
                    _item                 = new GUIListItem();
                    _item.Label           = Translation.IMDBNotFound;
                    _item.Label2          = string.Empty;
                    _item.TVTag           = Utils.ItemType.Research;
                    _item.OnItemSelected += OnItemSelected;
                    SetStatus(ref _item);
                    facadeLayout.Add(_item);
                }
            }
            facadeLayout.SelectedListItemIndex = newSelectedIndex;
            FillProperties(GetSelectedItem());

            Utils.SetProperty("#currentmodule", module);
            Utils.SetProperty("#itemcount", count.ToString());
        }
コード例 #12
0
        protected override void OnShowContextMenu()
        {
            GUIListItem item = GetSelectedItem();

            if (item == null)
            {
                return;
            }

            NewMovie movie = item.AlbumInfoTag as NewMovie;

            if (movie == null)
            {
                return;
            }

            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(498);          // Menu

            dlg.AddLocalizedString(6032); // Search by title
            if (viewLevel == Utils.ViewLevel.Files)
            {
            }
            else if (movie.Status == Utils.ImporterStatus.COMPLETE)
            {
                dlg.AddLocalizedString(368); //IMDB
            }

            dlg.DoModal(GetID);

            if (dlg.SelectedId == -1)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case 6032: // Search by title
                string moviename = movie.SearchTitle;
                if (moviename == "unknown")
                {
                    moviename = MediaPortal.Util.Utils.GetFilename(movie.FileName, true);
                }
                if (VirtualKeyboard.GetKeyboard(ref moviename, GetID))
                {
                    if (!string.IsNullOrEmpty(moviename))
                    {
                        movie.SearchTitle = moviename;
                        movie.Status      = Utils.ImporterStatus.QUEUED_IMDB;
                        if (viewLevel == Utils.ViewLevel.Files)
                        {
                            SetStatus(ref item, movie);
                        }
                        else
                        {
                            item.Label = Translation.IMDBScanning;
                            item.TVTag = Utils.ItemType.Search;
                            SetStatus(ref item);
                        }
                    }
                }
                break;

            case 368: // IMDB
                ShowInfo(item);
                break;
            }
        }
コード例 #13
0
        protected override void OnClick(int iItem)
        {
            GUIListItem item = GetSelectedItem();

            if (item == null)
            {
                return;
            }

            Utils.ItemType _itemType;
            if (item.TVTag == null)
            {
                return;
            }

            _itemType = (Utils.ItemType)item.TVTag;
            if (_itemType == Utils.ItemType.Rescan)
            {
                item.Label = Translation.IMDBScanning;
                item.TVTag = Utils.ItemType.Search;
                SetStatus(ref item);
                videoImporter.RestartImporter();
                return;
            }

            if (item.IsFolder)
            {
                LoadList(item);
            }
            else
            {
                if (_itemType == Utils.ItemType.Research)
                {
                    NewMovie movie = parentItem.AlbumInfoTag as NewMovie;
                    if (movie != null)
                    {
                        movie.Status = Utils.ImporterStatus.QUEUED_IMDB;
                        item.Label   = Translation.IMDBScanning;
                        item.TVTag   = Utils.ItemType.Search;
                        SetStatus(ref item);
                    }
                }

                /*
                 * else if (_itemType == Utils.ItemType.Stop)
                 * {
                 * NewMovie movie = parentItem.AlbumInfoTag as NewMovie;
                 * if (movie != null)
                 * {
                 *  movie.StopFetchhDetails();
                 *  movie.Status = Utils.ImporterStatus.WAITING;
                 * }
                 * }
                 */
                else
                {
                    NewMovie movie = item.AlbumInfoTag as NewMovie;
                    if (movie != null)
                    {
                        if (movie.Status == Utils.ImporterStatus.COMPLETE)
                        {
                            ShowInfo(item);
                        }
                        else if (SelectYesNo(item.Label))
                        {
                            movie.Selected = item.ItemId;
                            movie.Status   = Utils.ImporterStatus.QUEUED_INFO;
                            SetStatus(ref item, movie);
                        }
                    }
                }
            }
        }