FetchNfo() public method

public FetchNfo ( ArrayList nfoFiles, bool skipExisting, bool refreshdbOnly ) : void
nfoFiles System.Collections.ArrayList
skipExisting bool
refreshdbOnly bool
return void
Exemplo n.º 1
0
    protected override void OnSearchNew()
    {
      if (_doNotUseDatabase)
      {
        GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
        dlgOk.SetHeading(string.Empty);
        dlgOk.SetLine(1, GUILocalizeStrings.Get(416)); // Not available
        dlgOk.DoModal(GUIWindowManager.ActiveWindow);
        return;
      }

      int maximumShares = 128;
      ArrayList availablePaths = new ArrayList();

      using (Profile.Settings xmlreader = new MPSettings())
      {
        for (int index = 0; index < maximumShares; index++)
        {
          string sharePath = String.Format("sharepath{0}", index);
          string shareDir = xmlreader.GetValueAsString("movies", sharePath, "");
          string shareScan = String.Format("sharescan{0}", index);
          bool shareScanData = xmlreader.GetValueAsBool("movies", shareScan, true);

          if (shareScanData && shareDir != string.Empty)
          {
            availablePaths.Add(shareDir);
          }
        }

        ArrayList nfoFiles = new ArrayList();

        foreach (string availablePath in availablePaths)
        {
          GetNfoFiles(availablePath, ref nfoFiles);
        }

        if (!_useOnlyNfoScraper) // Normal scraper
        {
          // First try nfo files
          IMDBFetcher fetcher = new IMDBFetcher(this);
          fetcher.FetchNfo(nfoFiles, true, false);
          // Then video files without nfo
          IMDBFetcher.ScanIMDB(this, availablePaths, true, true, true, false);
        }
        else
        {
          // Only nfo files
          IMDBFetcher fetcher = new IMDBFetcher(this);
          fetcher.FetchNfo(nfoFiles, true, false);
        }
        
        // Send global message that movie is refreshed/scanned
        GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOINFO_REFRESH, 0, 0, 0, 0, 0, null);
        GUIWindowManager.SendMessage(msg);

        _currentSelectedItem = facadeLayout.SelectedListItemIndex;

        if (_currentSelectedItem > 0)
        {
          _currentSelectedItem--;
        }

        LoadDirectory(_currentFolder);

        if (_currentSelectedItem >= 0)
        {
          GUIControl.SelectItemControl(GetID, facadeLayout.GetID, _currentSelectedItem);
        }
      }
    }
Exemplo n.º 2
0
    protected override void OnShowContextMenu()
    {
      GUIListItem item = facadeLayout.SelectedListItem;
      int itemNo = facadeLayout.SelectedListItemIndex;
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      
      if (dlg == null)
      {
        return;
      }

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

      if (item == null)
      {
        dlg.AddLocalizedString(868); // Reset virtual directory
      }
      else if (item.IsRemote || (item.IsFolder) && (item.Label == "..") && _virtualDirectory.IsShareOfflineDetected())
      {
        dlg.AddLocalizedString(868); // Force reset virtual directory if user want to refresh offline share
      }
      else if (item.IsRemote || (item.IsFolder) && (item.Label == ".."))
      {
        return;
      }
      else
      {
        IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;

        if (!facadeLayout.Focus)
        {
          // Menu button context menuu
          if (!_virtualDirectory.IsRemote(_currentFolder))
          {
            dlg.AddLocalizedString(102); //Scan
            dlg.AddLocalizedString(368); //IMDB
          }
        }
        else
        {
          // DVD & files
          if ((Path.GetFileName(item.Path) != string.Empty) || Util.Utils.IsDVD(item.Path))
          {
            // DVD disc drive
            if (Util.Utils.IsDVD(item.Path))
            {
              if (File.Exists(item.Path + @"\VIDEO_TS\VIDEO_TS.IFO") ||
                  File.Exists(item.Path + @"\BDMV\index.bdmv"))
              {
                dlg.AddLocalizedString(341); //play
              }
              else
              {
                dlg.AddLocalizedString(926); //Queue
                dlg.AddLocalizedString(102); //Scan
              }

              dlg.AddLocalizedString(368); //IMDB
            }
            // Folder
            else if (item.IsFolder)
            {
              bool useMediaInfo = false;

              if (VirtualDirectory.IsImageFile(Path.GetExtension(item.Path)))
              {
                dlg.AddLocalizedString(208); //play
                useMediaInfo = true;
              }

              if (!VirtualDirectory.IsImageFile(Path.GetExtension(item.Path)))
              {
                // Simple folder
                if (!item.IsBdDvdFolder)
                {
                  dlg.AddLocalizedString(1204); // Play All in selected folder
                  dlg.AddLocalizedString(926); //Queue
                  dlg.AddLocalizedString(102); //Scan 
                  dlg.AddLocalizedString(1280); // Scan using nfo files
                }
                // DVD folder
                else if (item.IsBdDvdFolder)
                {
                  useMediaInfo = true;
                  dlg.AddLocalizedString(208); //play             
                  dlg.AddLocalizedString(926); //Queue
                  dlg.AddLocalizedString(368); //IMDB
                  
                  if (movie != null && !movie.IsEmpty)
                  {
                    if (item.IsPlayed)
                    {
                      {
                        dlg.AddLocalizedString(830); //Reset watched status for DVD folder
                      }
                    }
                    else
                    {
                      dlg.AddLocalizedString(1260); // Set watched status
                    }
                  }
                }
              }

              if (!IsFolderPinProtected(item.Path) && _fileMenuEnabled)
              {
                dlg.AddLocalizedString(500); // FileMenu            
              }

              if (useMediaInfo)
              {
                dlg.AddLocalizedString(1264); //Media info
              }
            }
            else
            {
              dlg.AddLocalizedString(208); //Play
              dlg.AddLocalizedString(926); //Queue
              dlg.AddLocalizedString(368); //IMDB

              if (item.IsPlayed)
              {
                dlg.AddLocalizedString(830); //Reset watched status
              }
              else
              {
                dlg.AddLocalizedString(1260); // Set watched status
              }

              if (!IsFolderPinProtected(item.Path) && !item.IsRemote && _fileMenuEnabled)
              {
                dlg.AddLocalizedString(500); // FileMenu
              }
              dlg.AddLocalizedString(1264); //Media info
            }
          }
          else if (Util.Utils.IsNetwork(item.Path)) // Process network root with drive letter
          {
            dlg.AddLocalizedString(1204); // Play All in selected folder
          }
        }
        if (!_mapSettings.Stack)
        {
          dlg.AddLocalizedString(346); //Stack
        }
        else
        {
          dlg.AddLocalizedString(347); //Unstack
        }

        #region Eject/Load

        // CD/DVD/BD
        if (Util.Utils.getDriveType(item.Path) == 5)
        {
          if (item.Path != null)
          {
            var driveInfo = new DriveInfo(Path.GetPathRoot(item.Path));

            // There is no easy way in NET to detect open tray so we will check
            // if media is inside (load will be visible also in case that tray is closed but
            // media is not loaded)
            if (!driveInfo.IsReady)
            {
              dlg.AddLocalizedString(607); //Load  
            }

            dlg.AddLocalizedString(654); //Eject  
          }
        }
        
        // Removable/USB HDD
        if (Util.Utils.IsRemovable(item.Path) || Util.Utils.IsUsbHdd(item.Path))
        {
          dlg.AddLocalizedString(831);
        }

        #endregion

        dlg.AddLocalizedString(1299); // Refresh current directory

        if (_virtualDirectory.IsShareOfflineDetected())
        {
          dlg.AddLocalizedString(868); // Force reset virtual directory if user want to refresh offline share
        }
      }

      dlg.AddLocalizedString(1262); // Update grabber scripts
      dlg.AddLocalizedString(1307); // Update internal grabber scripts
      dlg.AddLocalizedString(1263); // Set default grabber

      if (!item.IsFolder)
      {
        dlg.AddLocalizedString(1984); // Refresh thumb
        if (!_hideWatchedFiles)
        {
          dlg.AddLocalizedString(2498); // Hide watched movies
        }
        else
        {
          dlg.AddLocalizedString(2499); // Unhide watched movies
        }
      }

      if (item.IsFolder && item.Label != "..")
      {
        dlg.AddLocalizedString(1995); // Create 4x4 folder.jpg
        if (_refreshMediaInfoThread != null && _refreshMediaInfoThread.IsAlive)
        {
          dlg.AddLocalizedString(2161); // Abort Update MediaInfo thread in the folder
        }
        else
        {
          dlg.AddLocalizedString(2160); // Update MediaInfo in the folder
        }
      }

      dlg.DoModal(GetID);

      if (dlg.SelectedId == -1)
      {
        return;
      }
      switch (dlg.SelectedId)
      {
        case 368: // IMDB
          OnInfo(itemNo);
          break;

        case 208: // play
          _playClicked = true;
          OnClick(itemNo);
          break;

        case 926: // add to playlist
          OnQueueItem(itemNo);
          break;

        case 136: // show playlist
          GUIWindowManager.ActivateWindow((int)Window.WINDOW_VIDEO_PLAYLIST);
          break;

        case 607: // Load (only CDROM)
          Util.Utils.CloseCDROM(Path.GetPathRoot(item.Path));
          break;

        case 654: // Eject
          if (Util.Utils.getDriveType(item.Path) != 5)
          {
            Util.Utils.EjectCDROM();
          }
          else
          {
            Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
          }

          LoadDirectory(string.Empty);
          break;

        case 341: //Play dvd
          OnPlayDVD(item.Path, GetID);
          break;

        case 346: //Stack
          _mapSettings.Stack = true;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          SaveFolderSettings(_currentFolder);
          break;

        case 347: //Unstack
          _mapSettings.Stack = false;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          SaveFolderSettings(_currentFolder);
          break;

        case 102: //Scan
          if (_doNotUseDatabase)
          {
            GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
            dlgOk.SetHeading(string.Empty);
            dlgOk.SetLine(1, GUILocalizeStrings.Get(416)); // Not available
            dlgOk.DoModal(GUIWindowManager.ActiveWindow);
            return;
          }

          if (facadeLayout.Focus)
          {
            if (item.IsFolder)
            {
              if (item.Label == "..")
              {
                return;
              }
              if (item.IsRemote)
              {
                return;
              }
            }
          }

          if (!_virtualDirectory.RequestPin(item.Path))
          {
            return;
          }
          
          int currentIndex = facadeLayout.SelectedListItemIndex;
          ArrayList scanNfoFiles = new ArrayList();
          GetNfoFiles(item.Path, ref scanNfoFiles);

          if (_useOnlyNfoScraper)
          {
            IMDBFetcher scanFetcher = new IMDBFetcher(this);
            scanFetcher.FetchNfo(scanNfoFiles, true, false);
            // Send global message that movie is refreshed/scanned
            GUIMessage scanNfoMsg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOINFO_REFRESH, 0, 0, 0, 0, 0, null);
            GUIWindowManager.SendMessage(scanNfoMsg);
            LoadDirectory(_currentFolder);
            facadeLayout.SelectedListItemIndex = currentIndex;
          }
          else
          {
            // Try nfo files first
            IMDBFetcher scanFetcher = new IMDBFetcher(this);
            scanFetcher.FetchNfo(scanNfoFiles, true, false);
            // Then the rest
            ArrayList availablePaths = new ArrayList();
            availablePaths.Add(item.Path);
            IMDBFetcher.ScanIMDB(this, availablePaths, _isFuzzyMatching, true, _getActors, false);
            // Send global message that movie is refreshed/scanned
            GUIMessage scanMsg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOINFO_REFRESH, 0, 0, 0, 0, 0, null);
            GUIWindowManager.SendMessage(scanMsg);
            LoadDirectory(_currentFolder);
            facadeLayout.SelectedListItemIndex = currentIndex;
          }
          break;

        case 1280: //Scan using nfo files
          if (_doNotUseDatabase)
          {
            GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
            dlgOk.SetHeading(string.Empty);
            dlgOk.SetLine(1, GUILocalizeStrings.Get(416)); // Not available
            dlgOk.DoModal(GUIWindowManager.ActiveWindow);
            return;
          }

          if (facadeLayout.Focus)
          {
            if (item.IsFolder)
            {
              if (item.Label == "..")
              {
                return;
              }
              if (item.IsRemote)
              {
                return;
              }
            }
          }

          if (!_virtualDirectory.RequestPin(item.Path))
          {
            return;
          }
          
          currentIndex = facadeLayout.SelectedListItemIndex;
          ArrayList nfoFiles = new ArrayList();
          GetNfoFiles(item.Path, ref nfoFiles);
          IMDBFetcher fetcher = new IMDBFetcher(this);
          fetcher.FetchNfo(nfoFiles, true, false);
          // Send global message that movie is refreshed/scanned
          GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOINFO_REFRESH, 0, 0, 0, 0, 0, null);
          GUIWindowManager.SendMessage(msg);
          LoadDirectory(_currentFolder);
          facadeLayout.SelectedListItemIndex = currentIndex;
          break;

        case 830: // Reset watched status
          SetMovieWatchStatus(item.Path, item.IsFolder, false);
          int selectedIndex = facadeLayout.SelectedListItemIndex;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          facadeLayout.SelectedListItemIndex = selectedIndex;
          break;

        case 1260: // Set watched status
          SetMovieWatchStatus(item.Path, item.IsFolder, true);
          selectedIndex = facadeLayout.SelectedListItemIndex;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          facadeLayout.SelectedListItemIndex = selectedIndex;
          break;

        case 500: // File menu
          {
            ShowFileMenu(false);
          }
          break;

        case 831:
          string message = string.Empty;
          
          if (Util.Utils.IsUsbHdd(item.Path) || Util.Utils.IsRemovableUsbDisk(item.Path))
          {
            if (!RemovableDriveHelper.EjectDrive(item.Path, out message))
            {
              GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
              pDlgOK.SetHeading(831);
              pDlgOK.SetLine(1, GUILocalizeStrings.Get(832));
              pDlgOK.SetLine(2, string.Empty);
              pDlgOK.SetLine(3, message);
              pDlgOK.DoModal(GUIWindowManager.ActiveWindow);
            }
            else
            {
              GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
              pDlgOK.SetHeading(831);
              pDlgOK.SetLine(1, GUILocalizeStrings.Get(833));
              pDlgOK.DoModal(GUIWindowManager.ActiveWindow);
            }
          }
          else if (!RemovableDriveHelper.EjectMedia(item.Path, out message))
          {
            GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
            pDlgOK.SetHeading(831);
            pDlgOK.SetLine(1, GUILocalizeStrings.Get(832));
            pDlgOK.SetLine(2, string.Empty);
            pDlgOK.SetLine(3, message);
            pDlgOK.DoModal(GUIWindowManager.ActiveWindow);
          }
          else
          {
            GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
            pDlgOK.SetHeading(831);
            pDlgOK.SetLine(1, GUILocalizeStrings.Get(833));
            pDlgOK.DoModal(GUIWindowManager.ActiveWindow);
          }
          break;

        case 1204: // Play all
          {
            if (!_virtualDirectory.RequestPin(item.Path))
            {
              return;
            }
            OnPlayAll(item.Path);
          }
          break;

        case 1299: // Refresh current directory
          {
            if (facadeLayout.ListLayout.ListItems.Count > 0 && !string.IsNullOrEmpty(_currentFolder))
            {
              facadeLayout.SelectedListItemIndex = 0;
              LoadDirectory(_currentFolder, false);
            }
          }
          break;

        case 868: // Reset V.directory
          {
            ResetShares();

            if (_virtualDirectory.DefaultShare != null && _virtualDirectory.DefaultShare.Path != string.Empty)
            {
              LoadDirectory(_virtualDirectory.DefaultShare.Path, false);
            }
            else
            {
              LoadDirectory(string.Empty, false);
            }
          }
          break;

        case 1262: // Update grabber scripts
          UpdateGrabberScripts(false);
          break;
        case 1307: // Update internal grabber scripts
          UpdateGrabberScripts(true);
          break;
        case 1263: // Set deault grabber script
          SetDefaultGrabber();
          break;
        case 1984: // Refresh video thumb
          Log.Debug("Thumb refresh from context menu: {0}", item.Path);
          if (Util.Utils.FileExistsInCache(item.Path))
          {
            string strThumbPath = Util.Utils.GetVideosThumbPathname(item.Path);

            bool success = Util.VideoThumbCreator.CreateVideoThumb(item.Path, strThumbPath, true, true);
            if (success)
            {
              Log.Debug("Refresh success!");
              if (facadeLayout.ListLayout.ListItems.Count > 0 && !string.IsNullOrEmpty(_currentFolder))
              {
                selectedIndex = facadeLayout.SelectedListItemIndex;
                LoadDirectory(_currentFolder, false);
                facadeLayout.SelectedListItemIndex = selectedIndex;
              }
            }
          }

          break;
        case 2498: // Hide watched movies
          Log.Debug("GUIVideoFiles: Hide watched movies");
          _hideWatchedFiles = true;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          break;
        case 2499: // Unhide watched movies
          Log.Debug("GUIVideoFiles: Unhide watched movies");
          _hideWatchedFiles = false;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          break;
        case 1995: // Create 4x4 folder.jpg
          Log.Debug("Create folder.jpg from context menu: {0}", item.Path);
          CreateFolderThumb(item, true);
          break;
        case 1264: // Get media info (refresh mediainfo and duration)
          RefreshMediaInfo(item);
          break;

        case 2160: // Update mediainfo in all files in the folder
          UpdateMediaInfoInFolder(item);
          break;

        case 2161: // Abort update mediainfo thread in all files in the folder
          if (_refreshMediaInfoThread.IsAlive)
          {
            _refreshMediaInfoThreadAbort = true;
          }
          break;
      }
    }
Exemplo n.º 3
0
    protected override void OnShowContextMenu()
    {
      GUIListItem item = facadeLayout.SelectedListItem;
      int itemNo = facadeLayout.SelectedListItemIndex;
      GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
      
      if (dlg == null)
      {
        return;
      }

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

      if (item == null)
      {
        dlg.AddLocalizedString(868); // Reset virtual directory
      }
      else if (item.IsRemote || (item.IsFolder) && (item.Label == ".."))
      {
        return;
      }
      else
      {
        IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;

        if (!facadeLayout.Focus)
        {
          // Menu button context menuu
          if (!_virtualDirectory.IsRemote(_currentFolder))
          {
            dlg.AddLocalizedString(102); //Scan
            dlg.AddLocalizedString(368); //IMDB
          }
        }
        else
        {
          // DVD & files
          if ((Path.GetFileName(item.Path) != string.Empty) || Util.Utils.IsDVD(item.Path))
          {
            // DVD disc drive
            if (Util.Utils.IsDVD(item.Path))
            {
              if (File.Exists(item.Path + @"\VIDEO_TS\VIDEO_TS.IFO") ||
                  File.Exists(item.Path + @"\BDMV\index.bdmv"))
              {
                dlg.AddLocalizedString(341); //play
              }
              else
              {
                dlg.AddLocalizedString(926); //Queue
                dlg.AddLocalizedString(102); //Scan
              }

              dlg.AddLocalizedString(368); //IMDB
              dlg.AddLocalizedString(654); //Eject
            }
            // Folder
            else if (item.IsFolder)
            {
              bool useMediaInfo = false;

              if (VirtualDirectory.IsImageFile(Path.GetExtension(item.Path)))
              {
                dlg.AddLocalizedString(208); //play
                useMediaInfo = true;
              }

              if (!VirtualDirectory.IsImageFile(Path.GetExtension(item.Path)))
              {
                // Simple folder
                if (!item.IsBdDvdFolder)
                {
                  dlg.AddLocalizedString(1204); // Play All in selected folder
                  dlg.AddLocalizedString(926); //Queue
                  dlg.AddLocalizedString(102); //Scan 
                  dlg.AddLocalizedString(1280); // Scan using nfo files
                }
                // DVD folder
                else if (item.IsBdDvdFolder)
                {
                  useMediaInfo = true;
                  dlg.AddLocalizedString(208); //play             
                  dlg.AddLocalizedString(926); //Queue
                  dlg.AddLocalizedString(368); //IMDB
                  
                  if (movie != null && !movie.IsEmpty)
                  {
                    if (item.IsPlayed)
                    {
                      {
                        dlg.AddLocalizedString(830); //Reset watched status for DVD folder
                      }
                    }
                    else
                    {
                      dlg.AddLocalizedString(1260); // Set watched status
                    }
                  }
                }
              }

              if (Util.Utils.getDriveType(item.Path) == 5)
              {
                dlg.AddLocalizedString(654); //Eject            
              }

              if (!IsFolderPinProtected(item.Path) && _fileMenuEnabled)
              {
                dlg.AddLocalizedString(500); // FileMenu            
              }

              if (useMediaInfo)
              {
                dlg.AddLocalizedString(1264); //Media info
              }
            }
            else
            {
              dlg.AddLocalizedString(208); //Play
              dlg.AddLocalizedString(926); //Queue
              dlg.AddLocalizedString(368); //IMDB

              if (item.IsPlayed)
              {
                dlg.AddLocalizedString(830); //Reset watched status
              }
              else
              {
                dlg.AddLocalizedString(1260); // Set watched status
              }

              if (!IsFolderPinProtected(item.Path) && !item.IsRemote && _fileMenuEnabled)
              {
                dlg.AddLocalizedString(500); // FileMenu
              }
              dlg.AddLocalizedString(1264); //Media info
            }
          }
          else if (Util.Utils.IsNetwork(item.Path)) // Process network root with drive letter
          {
            dlg.AddLocalizedString(1204); // Play All in selected folder
          }
        }
        if (!_mapSettings.Stack)
        {
          dlg.AddLocalizedString(346); //Stack
        }
        else
        {
          dlg.AddLocalizedString(347); //Unstack
        }
        if (Util.Utils.IsRemovable(item.Path))
        {
          dlg.AddLocalizedString(831);
        }

        dlg.AddLocalizedString(1299); // Refresh current directory
        dlg.AddLocalizedString(1262); // Update grabber scripts
        dlg.AddLocalizedString(1307); // Update internal grabber scripts
        dlg.AddLocalizedString(1263); // Set default grabber
      }

      dlg.DoModal(GetID);

      if (dlg.SelectedId == -1)
      {
        return;
      }
      switch (dlg.SelectedId)
      {
        case 368: // IMDB
          OnInfo(itemNo);
          break;

        case 208: // play
          _playClicked = true;
          OnClick(itemNo);
          break;

        case 926: // add to playlist
          OnQueueItem(itemNo);
          break;

        case 136: // show playlist
          GUIWindowManager.ActivateWindow((int)Window.WINDOW_VIDEO_PLAYLIST);
          break;

        case 654: // Eject
          if (Util.Utils.getDriveType(item.Path) != 5)
          {
            Util.Utils.EjectCDROM();
          }
          else
          {
            Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
          }
          LoadDirectory(string.Empty);
          break;

        case 341: //Play dvd
          OnPlayDVD(item.Path, GetID);
          break;

        case 346: //Stack
          _mapSettings.Stack = true;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          break;

        case 347: //Unstack
          _mapSettings.Stack = false;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          break;

        case 102: //Scan
          if (_doNotUseDatabase)
          {
            GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
            dlgOk.SetHeading(string.Empty);
            dlgOk.SetLine(1, GUILocalizeStrings.Get(416)); // Not available
            dlgOk.DoModal(GUIWindowManager.ActiveWindow);
            return;
          }

          if (facadeLayout.Focus)
          {
            if (item.IsFolder)
            {
              if (item.Label == "..")
              {
                return;
              }
              if (item.IsRemote)
              {
                return;
              }
            }
          }

          if (!_virtualDirectory.RequestPin(item.Path))
          {
            return;
          }
          
          int currentIndex = facadeLayout.SelectedListItemIndex;

          if (_useOnlyNfoScraper)
          {
            ArrayList scanNfoFiles = new ArrayList();
            GetNfoFiles(item.Path, ref scanNfoFiles);
            IMDBFetcher scanFetcher = new IMDBFetcher(this);
            scanFetcher.FetchNfo(scanNfoFiles, true, false);
            // Send global message that movie is refreshed/scanned
            GUIMessage scanNfoMsg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOINFO_REFRESH, 0, 0, 0, 0, 0, null);
            GUIWindowManager.SendMessage(scanNfoMsg);
            LoadDirectory(_currentFolder);
            facadeLayout.SelectedListItemIndex = currentIndex;
          }
          else
          {
            ArrayList availablePaths = new ArrayList();
            availablePaths.Add(item.Path);
            IMDBFetcher.ScanIMDB(this, availablePaths, _isFuzzyMatching, _scanSkipExisting, _getActors, false);
            // Send global message that movie is refreshed/scanned
            GUIMessage scanMsg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOINFO_REFRESH, 0, 0, 0, 0, 0, null);
            GUIWindowManager.SendMessage(scanMsg);
            LoadDirectory(_currentFolder);
            facadeLayout.SelectedListItemIndex = currentIndex;
          }
          break;

        case 1280: //Scan using nfo files
          if (_doNotUseDatabase)
          {
            GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
            dlgOk.SetHeading(string.Empty);
            dlgOk.SetLine(1, GUILocalizeStrings.Get(416)); // Not available
            dlgOk.DoModal(GUIWindowManager.ActiveWindow);
            return;
          }

          if (facadeLayout.Focus)
          {
            if (item.IsFolder)
            {
              if (item.Label == "..")
              {
                return;
              }
              if (item.IsRemote)
              {
                return;
              }
            }
          }

          if (!_virtualDirectory.RequestPin(item.Path))
          {
            return;
          }
          
          currentIndex = facadeLayout.SelectedListItemIndex;
          ArrayList nfoFiles = new ArrayList();
          GetNfoFiles(item.Path, ref nfoFiles);
          IMDBFetcher fetcher = new IMDBFetcher(this);
          fetcher.FetchNfo(nfoFiles, true, false);
          // Send global message that movie is refreshed/scanned
          GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOINFO_REFRESH, 0, 0, 0, 0, 0, null);
          GUIWindowManager.SendMessage(msg);
          LoadDirectory(_currentFolder);
          facadeLayout.SelectedListItemIndex = currentIndex;
          break;

        case 830: // Reset watched status
          SetMovieWatchStatus(item.Path, item.IsFolder, false);
          int selectedIndex = facadeLayout.SelectedListItemIndex;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          facadeLayout.SelectedListItemIndex = selectedIndex;
          break;

        case 1260: // Set watched status
          SetMovieWatchStatus(item.Path, item.IsFolder, true);
          selectedIndex = facadeLayout.SelectedListItemIndex;
          LoadDirectory(_currentFolder);
          UpdateButtonStates();
          facadeLayout.SelectedListItemIndex = selectedIndex;
          break;

        case 500: // File menu
          {
            ShowFileMenu(false);
          }
          break;

        case 831:
          string message;

          if (!RemovableDriveHelper.EjectDrive(item.Path, out message))
          {
            GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
            pDlgOK.SetHeading(831);
            pDlgOK.SetLine(1, GUILocalizeStrings.Get(832));
            pDlgOK.SetLine(2, string.Empty);
            pDlgOK.SetLine(3, message);
            pDlgOK.DoModal(GUIWindowManager.ActiveWindow);
          }
          else
          {
            GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
            pDlgOK.SetHeading(831);
            pDlgOK.SetLine(1, GUILocalizeStrings.Get(833));
            pDlgOK.DoModal(GUIWindowManager.ActiveWindow);
          }
          break;

        case 1204: // Play all
          {
            if (!_virtualDirectory.RequestPin(item.Path))
            {
              return;
            }
            OnPlayAll(item.Path);
          }
          break;

        case 1299: // Refresh current directory
          {
            if (facadeLayout.ListLayout.ListItems.Count > 0 && !string.IsNullOrEmpty(_currentFolder))
            {
              facadeLayout.SelectedListItemIndex = 0;
              LoadDirectory(_currentFolder, false);
            }
          }
          break;

        case 868: // Reset V.directory
          {
            ResetShares();

            if (_virtualDirectory.DefaultShare != null && _virtualDirectory.DefaultShare.Path != string.Empty)
            {
              LoadDirectory(_virtualDirectory.DefaultShare.Path, false);
            }
            else
            {
              LoadDirectory(string.Empty, false);
            }
          }
          break;

        case 1262: // Update grabber scripts
          UpdateGrabberScripts(false);
          break;
        case 1307: // Update internal grabber scripts
          UpdateGrabberScripts(true);
          break;
        case 1263: // Set deault grabber script
          SetDefaultGrabber();
          break;
        case 1264: // Get media info (refresh mediainfo and duration)
          if (item != null)
          {
            string file = item.Path;
            SelectDVDHandler sdh = new SelectDVDHandler();
            SelectBDHandler bdh = new SelectBDHandler();

            if (sdh.IsDvdDirectory(item.Path))
            {
              if (File.Exists(item.Path + @"\VIDEO_TS\VIDEO_TS.IFO"))
              {
                file = file + @"\VIDEO_TS\VIDEO_TS.IFO";
              }
            }

            if (bdh.IsBDDirectory(item.Path))
            {
              if (File.Exists(item.Path + @"\BDMV\INDEX.BDMV"))
              {
                file = file + @"\BDMV\INDEX.BDMV";
              }
            }

            ArrayList files = new ArrayList();
            files = AddFileToDatabase(file);
            MovieDuration(files, true);
            int movieId = VideoDatabase.GetMovieId(file);
            IMDBMovie mInfo = new IMDBMovie();
            mInfo.SetMediaInfoProperties(file, true);
            mInfo.SetDurationProperty(movieId);
            IMDBMovie.SetMovieData(item);
            SelectCurrentItem();
          }
          break;
      }
    }
Exemplo n.º 4
0
    // Scan for new movies for selected folder in configuration
    protected override void OnSearchNew()
    {
      int maximumShares = 128;
      ArrayList availablePaths = new ArrayList();
      bool _useOnlyNfoScraper = false;

      using (Profile.Settings xmlreader = new MPSettings())
      {
        _useOnlyNfoScraper = xmlreader.GetValueAsBool("moviedatabase", "useonlynfoscraper", false);

        for (int index = 0; index < maximumShares; index++)
        {
          string sharePath = String.Format("sharepath{0}", index);
          string shareDir = xmlreader.GetValueAsString("movies", sharePath, "");
          string shareScan = String.Format("sharescan{0}", index);
          bool shareScanData = xmlreader.GetValueAsBool("movies", shareScan, true);

          if (shareScanData && shareDir != string.Empty)
          {
            availablePaths.Add(shareDir);
          }
        }

        if (!_useOnlyNfoScraper)
        {
          IMDBFetcher.ScanIMDB(this, availablePaths, true, true, true, false);
        }
        else
        {
          ArrayList nfoFiles = new ArrayList();
          
          foreach (string availablePath in availablePaths)
          {
            GetNfoFiles(availablePath, ref nfoFiles);
          }
          
          IMDBFetcher fetcher = new IMDBFetcher(this);
          fetcher.FetchNfo(nfoFiles, true, false);
        }
        // Send global message that movie is refreshed/scanned
        GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_VIDEOINFO_REFRESH, 0, 0, 0, 0, 0, null);
        GUIWindowManager.SendMessage(msg);
        currentSelectedItem = facadeLayout.SelectedListItemIndex;

        if (currentSelectedItem > 0)
        {
          currentSelectedItem--;
        }

        LoadDirectory(currentFolder);

        if (currentSelectedItem >= 0)
        {
          GUIControl.SelectItemControl(GetID, facadeLayout.GetID, currentSelectedItem);
        }
      }
    }
    // need change for 1.3.0
    private void OnScanDatabase()
    {
      SaveSettings();
      
      ArrayList availablePaths = new ArrayList();
      ArrayList scanShares = new ArrayList();

      foreach (GUIListItem item in lcFolders.ListItems)
      {
        if (item.IsPlayed)
        {
          scanShares.Add(item);
        }
      }

      for (int index = 0; index < _scanShare; index++)
      {
        GUIListItem item = (GUIListItem)scanShares[index];
        string path = item.Path;
        availablePaths.Add(path);
      }
      
      // Clean covers and fanarts (only if refreshexisting cb is checked)
      if (btnRefreshexistingonly.Selected)
      {
        ArrayList movies = new ArrayList();
        VideoDatabase.GetMovies(ref movies);

        foreach (IMDBMovie movie in movies)
        {
          string strFilenameAndPath = string.Empty;

          ArrayList files = new ArrayList();
          VideoDatabase.GetFilesForMovie(movie.ID, ref files);
          strFilenameAndPath = files[0].ToString();
          
          // Delete covers
          FanArt.DeleteCovers(movie.Title, movie.ID);
          // Delete fanarts
          FanArt.DeleteFanarts(movie.ID);
        }
      }
      _conflictFiles = new ArrayList();

      if (!btnUseNfoScraper.Selected)
      {
        IMDBFetcher.ScanIMDB(this, availablePaths, btnNearestmatch.Selected, btnSkipalreadyexisting.Selected, false,
                             btnRefreshexistingonly.Selected);
      }
      else
      {
        ArrayList nfoFiles = new ArrayList();

        foreach (string availablePath in availablePaths)
        {
          GetNfoFiles(availablePath, ref nfoFiles);
        }

        IMDBFetcher fetcher = new IMDBFetcher(this);
        fetcher.FetchNfo(nfoFiles, btnSkipalreadyexisting.Selected, btnRefreshexistingonly.Selected);
      }
    }
    // need change for 1.3.0
    private void OnScanDatabase()
    {
      SaveSettings();
      
      ArrayList availablePaths = new ArrayList();
      ArrayList scanShares = new ArrayList();

      foreach (GUIListItem item in lcFolders.ListItems)
      {
        if (item.IsPlayed)
        {
          scanShares.Add(item);
        }
      }

      for (int index = 0; index < _scanShare; index++)
      {
        GUIListItem item = (GUIListItem)scanShares[index];
        string path = item.Path;
        availablePaths.Add(path);
      }
      
      // Clean covers and fanarts (only if refreshexisting cb is checked)
      if (btnRefreshexistingonly.Selected)
      {
        ArrayList movies = new ArrayList();
        VideoDatabase.GetMovies(ref movies);

        foreach (IMDBMovie movie in movies)
        {
          string strFilenameAndPath = string.Empty;

          ArrayList files = new ArrayList();
          VideoDatabase.GetFilesForMovie(movie.ID, ref files);
          strFilenameAndPath = files[0].ToString();
          
          // Delete covers
          FanArt.DeleteCovers(movie.Title, movie.ID);
          // Delete fanarts
          FanArt.DeleteFanarts(movie.ID);
        }
      }
      _conflictFiles = new ArrayList();
      ArrayList nfoFiles = new ArrayList();

      foreach (string availablePath in availablePaths)
      {
        GetNfoFiles(availablePath, ref nfoFiles);
      }

      if (!btnUseNfoScraper.Selected)
      {
        // Scan only new movies (skip scan existing movies or not refreshing existing)
        if (btnSkipalreadyexisting.Selected && !btnRefreshexistingonly.Selected)
        {
          // First nfo (can speed up scan time)
          IMDBFetcher fetcher = new IMDBFetcher(this);
          fetcher.FetchNfo(nfoFiles, true, false);
          // Then video files (for movies not added by nfo)
          IMDBFetcher.ScanIMDB(this, availablePaths, btnNearestmatch.Selected, true, false, false);

        }
        else // User wants to scan no matter if movies are already in the database (do not use nfo here, user must set that option)
        {
          IMDBFetcher.ScanIMDB(this, availablePaths, btnNearestmatch.Selected, btnSkipalreadyexisting.Selected, false,
                             btnRefreshexistingonly.Selected);
        }
      }
      else // Use only nfo files
      {
        IMDBFetcher fetcher = new IMDBFetcher(this);
        fetcher.FetchNfo(nfoFiles, btnSkipalreadyexisting.Selected, btnRefreshexistingonly.Selected);
      }
    }