protected void OnPlayBD(String drive, int parentId)
        {
            ISelectBDHandler selectBDHandler;

            if (GlobalServiceProvider.IsRegistered <ISelectBDHandler>())
            {
                selectBDHandler = GlobalServiceProvider.Get <ISelectBDHandler>();
            }
            else
            {
                selectBDHandler = new SelectBDHandler();
                GlobalServiceProvider.Add <ISelectBDHandler>(selectBDHandler);
            }
            selectBDHandler.OnPlayBD(drive, GetID);
        }
    // Changed - cover for movies with the same name
    public void SetIMDBThumbs(IList items, bool markWatchedFiles)
    {
      try
      {
        GUIListItem pItem;
        ISelectBDHandler selectBdHandler;
        bool dedicatedMovieFolderChecked = false;
        bool isDedicatedMovieFolder = false;
        
        if (GlobalServiceProvider.IsRegistered<ISelectBDHandler>())
        {
          selectBdHandler = GlobalServiceProvider.Get<ISelectBDHandler>();
        }
        else
        {
          selectBdHandler = new SelectBDHandler();
          GlobalServiceProvider.Add<ISelectBDHandler>(selectBdHandler);
        }

        for (int x = 0; x < items.Count; x++)
        {
          string strThumb = string.Empty;
          pItem = (GUIListItem)items[x];
          string file = string.Empty;
          bool isFolderPinProtected = (pItem.IsFolder && IsFolderPinProtected(pItem.Path));
          IMDBMovie movie = pItem.AlbumInfoTag as IMDBMovie;

          if (movie == null)
          {
            IMDBMovie.SetMovieData(pItem);
            movie = pItem.AlbumInfoTag as IMDBMovie;
          }

          // Check for everymovieinitsownfolder only once for all items (defined share is the same for all)
          if (!dedicatedMovieFolderChecked && !string.IsNullOrEmpty(pItem.Path))
          {
            if (!pItem.IsRemote && !VirtualDirectories.Instance.Movies.IsRootShare(pItem.Path))
            {
              dedicatedMovieFolderChecked = true;
              isDedicatedMovieFolder = Util.Utils.IsFolderDedicatedMovieFolder(pItem.Path);
            }
          }

          // Skip DVD & BD backup folder
          if (pItem.IsFolder && !pItem.IsBdDvdFolder)
          {
            if (pItem.Label == "..")
            {
              continue;
            }

            // If this is enabled you'll see the thumb of the first movie in that dir - but if you put serveral movies into that dir you'll be irritated...          
            if (!pItem.IsRemote && isDedicatedMovieFolder)
            {
              string[] strFiles = null;

              try
              {
                strFiles = Directory.GetFiles(pItem.Path);
              }
              catch (Exception) { }

              if (strFiles != null)
              {
                for (int i = 0; i < strFiles.Length; ++i)
                {
                  string extension = Path.GetExtension(strFiles[i]);

                  if (VirtualDirectory.IsImageFile(extension))
                  {
                    if (DaemonTools.IsEnabled)
                    {
                      file = strFiles[i];
                      break;
                    }
                    continue;
                  }
                  if (VirtualDirectory.IsValidExtension(strFiles[i], Util.Utils.VideoExtensions, false))
                  {
                    // Skip hidden files
                    if ((File.GetAttributes(strFiles[i]) & FileAttributes.Hidden) == FileAttributes.Hidden)
                    {
                      continue;
                    }
                    file = strFiles[i];
                    break;
                  }
                }
              }
            }
          }
          // Check for DVD folder
          else if (pItem.IsBdDvdFolder && IsDvdDirectory(pItem.Path))
          {
            file = GetFolderVideoFile(pItem.Path);
          }
          // Check for BD folder
          else if (pItem.IsBdDvdFolder && selectBdHandler.IsBDDirectory(pItem.Path))
          {
            file = selectBdHandler.GetFolderVideoFile(pItem.Path);
          }
          else if (!pItem.IsFolder ||
                   (pItem.IsFolder && VirtualDirectory.IsImageFile(Path.GetExtension(pItem.Path).ToLowerInvariant())))
          {
            file = pItem.Path;
          }
          else
          {
            continue;
          }

          if (!string.IsNullOrEmpty(file))
          {
            int id = movie.ID;

            // Set thumb for movies
            if (id > 0 && !movie.IsEmpty)
            {
              if (Util.Utils.IsDVD(pItem.Path))
              {
                pItem.Label = String.Format("({0}:) {1}", pItem.Path.Substring(0, 1), movie.Title);
              }

              string titleExt = movie.Title + "{" + id + "}";
              strThumb = Util.Utils.GetCoverArt(Thumbs.MovieTitle, titleExt);
            }

            if (!Util.Utils.FileExistsInCache(strThumb) || string.IsNullOrEmpty(strThumb))
            {
              string fPic = string.Empty;
              string fPicTbn = string.Empty;
              string path = pItem.Path;
              Util.Utils.RemoveStackEndings(ref path);
              Util.Utils.RemoveStackEndings(ref file);
              string jpgExt = ".jpg";
              string tbnExt = ".tbn";
              string folderJpg = @"\folder.jpg";

              if (pItem.IsBdDvdFolder)
              {
                fPic = string.Concat(pItem.Path,@"\", Path.GetFileNameWithoutExtension(path), jpgExt);
                fPicTbn = string.Concat(pItem.Path, @"\", Path.GetFileNameWithoutExtension(path), tbnExt);
              }
              else
              {
                fPic = Path.ChangeExtension(file, jpgExt);
                fPicTbn = Path.ChangeExtension(file, tbnExt);
              }

              if (File.Exists(fPic))
              {
                strThumb = fPic;
              }
              else if (File.Exists(fPicTbn))
              {
                strThumb = fPicTbn;
              }
              else
              {
                if (!pItem.IsFolder && isDedicatedMovieFolder)
                {
                  fPic = Path.GetDirectoryName(pItem.Path) + folderJpg;

                  if (File.Exists(fPic))
                  {
                    strThumb = fPic;
                  }
                  else
                  {
                    continue;
                  }
                }
                else
                {
                  continue;
                }
              }
            }
            
            pItem.ThumbnailImage = strThumb;
            pItem.IconImageBig = strThumb;
            pItem.IconImage = strThumb;

            strThumb = Util.Utils.ConvertToLargeCoverArt(strThumb);
            
            if (Util.Utils.FileExistsInCache(strThumb))
            {
              pItem.ThumbnailImage = strThumb;
            }
            
            movie = null;
          } // <-- file == empty
        } // of for (int x = 0; x < items.Count; ++x)
      }
      catch (ThreadAbortException)
      {
        // Will be logged in thread main code
      }
      catch (Exception ex)
      {
        Log.Error("SelectDVDHandler: SetIMDbThumbs: {0}", ex.Message);
      }
    }
Example #3
0
 /// <summary>
 /// Get/Set BDHandler interface from/to registered services.
 /// </summary>
 /// <returns>BDHandler interface</returns>
 public static ISelectBDHandler GetSelectBDHandler()
 {
   ISelectBDHandler selectBDHandler;
   if (GlobalServiceProvider.IsRegistered<ISelectBDHandler>())
   {
     selectBDHandler = GlobalServiceProvider.Get<ISelectBDHandler>();
   }
   else
   {
     selectBDHandler = new SelectBDHandler();
     GlobalServiceProvider.Add<ISelectBDHandler>(selectBDHandler);
   }
   return selectBDHandler;
 }
Example #4
0
    private void RefreshMediaInfo(GUIListItem item)
    {
      if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.STOPPING)
      {
        return;
      }
      
      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);

        GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_REFRESH_MEDIAINFO, 0, 0, 0, 0, 0, 0);
        GUIWindowManager.SendMessage(msg);
      }
    }
Example #5
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;
      }
    }
 protected void OnPlayBD(String drive, int parentId)
 {
   ISelectBDHandler selectBDHandler;
   if (GlobalServiceProvider.IsRegistered<ISelectBDHandler>())
   {
     selectBDHandler = GlobalServiceProvider.Get<ISelectBDHandler>();
   }
   else
   {
     selectBDHandler = new SelectBDHandler();
     GlobalServiceProvider.Add<ISelectBDHandler>(selectBDHandler);
   }
   selectBDHandler.OnPlayBD(drive, GetID);
 }
        // Changed - cover for movies with the same name
        public void SetIMDBThumbs(IList items, bool markWatchedFiles)
        {
            try
            {
                GUIListItem      pItem;
                ISelectBDHandler selectBdHandler;
                bool             dedicatedMovieFolderChecked = false;
                bool             isDedicatedMovieFolder      = false;

                if (GlobalServiceProvider.IsRegistered <ISelectBDHandler>())
                {
                    selectBdHandler = GlobalServiceProvider.Get <ISelectBDHandler>();
                }
                else
                {
                    selectBdHandler = new SelectBDHandler();
                    GlobalServiceProvider.Add <ISelectBDHandler>(selectBdHandler);
                }

                for (int x = 0; x < items.Count; x++)
                {
                    string strThumb = string.Empty;
                    pItem = (GUIListItem)items[x];
                    string    file = string.Empty;
                    bool      isFolderPinProtected = (pItem.IsFolder && IsFolderPinProtected(pItem.Path));
                    IMDBMovie movie = pItem.AlbumInfoTag as IMDBMovie;

                    if (movie == null)
                    {
                        IMDBMovie.SetMovieData(pItem);
                        movie = pItem.AlbumInfoTag as IMDBMovie;
                    }

                    // Check for everymovieinitsownfolder only once for all items (defined share is the same for all)
                    if (!dedicatedMovieFolderChecked && !string.IsNullOrEmpty(pItem.Path))
                    {
                        if (!pItem.IsRemote && !VirtualDirectories.Instance.Movies.IsRootShare(pItem.Path))
                        {
                            dedicatedMovieFolderChecked = true;
                            isDedicatedMovieFolder      = Util.Utils.IsFolderDedicatedMovieFolder(pItem.Path);
                        }
                    }

                    // Skip DVD & BD backup folder
                    if (pItem.IsFolder && !pItem.IsBdDvdFolder)
                    {
                        if (pItem.Label == "..")
                        {
                            continue;
                        }

                        if (isFolderPinProtected)
                        {
                            // hide maybe rated content
                            Util.Utils.SetDefaultIcons(pItem);
                            continue;
                        }

                        // If this is enabled you'll see the thumb of the first movie in that dir - but if you put serveral movies into that dir you'll be irritated...
                        if (!pItem.IsRemote && isDedicatedMovieFolder)
                        {
                            string[] strFiles = null;

                            try
                            {
                                strFiles = Directory.GetFiles(pItem.Path);
                            }
                            catch (Exception) { }

                            if (strFiles != null)
                            {
                                for (int i = 0; i < strFiles.Length; ++i)
                                {
                                    string extension = Path.GetExtension(strFiles[i]);

                                    if (VirtualDirectory.IsImageFile(extension))
                                    {
                                        if (DaemonTools.IsEnabled)
                                        {
                                            file = strFiles[i];
                                            break;
                                        }
                                        continue;
                                    }
                                    if (VirtualDirectory.IsValidExtension(strFiles[i], Util.Utils.VideoExtensions, false))
                                    {
                                        // Skip hidden files
                                        if ((File.GetAttributes(strFiles[i]) & FileAttributes.Hidden) == FileAttributes.Hidden)
                                        {
                                            continue;
                                        }
                                        file = strFiles[i];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    // Check for DVD folder
                    else if (pItem.IsBdDvdFolder && IsDvdDirectory(pItem.Path))
                    {
                        file = GetFolderVideoFile(pItem.Path);
                    }
                    // Check for BD folder
                    else if (pItem.IsBdDvdFolder && selectBdHandler.IsBDDirectory(pItem.Path))
                    {
                        file = selectBdHandler.GetFolderVideoFile(pItem.Path);
                    }
                    else if (!pItem.IsFolder ||
                             (pItem.IsFolder && VirtualDirectory.IsImageFile(Path.GetExtension(pItem.Path).ToLower())))
                    {
                        file = pItem.Path;
                    }
                    else
                    {
                        continue;
                    }

                    if (!string.IsNullOrEmpty(file))
                    {
                        int id = movie.ID;

                        // Set thumb for movies
                        if (id > 0 && !movie.IsEmpty)
                        {
                            if (Util.Utils.IsDVD(pItem.Path))
                            {
                                pItem.Label = String.Format("({0}:) {1}", pItem.Path.Substring(0, 1), movie.Title);
                            }

                            string titleExt = movie.Title + "{" + id + "}";
                            strThumb = Util.Utils.GetCoverArt(Thumbs.MovieTitle, titleExt);
                        }

                        if (!Util.Utils.FileExistsInCache(strThumb) || string.IsNullOrEmpty(strThumb))
                        {
                            string fPic    = string.Empty;
                            string fPicTbn = string.Empty;
                            string path    = pItem.Path;
                            Util.Utils.RemoveStackEndings(ref path);
                            Util.Utils.RemoveStackEndings(ref file);
                            string jpgExt    = ".jpg";
                            string tbnExt    = ".tbn";
                            string folderJpg = @"\folder.jpg";

                            if (pItem.IsBdDvdFolder)
                            {
                                fPic    = string.Concat(pItem.Path, @"\", Path.GetFileNameWithoutExtension(path), jpgExt);
                                fPicTbn = string.Concat(pItem.Path, @"\", Path.GetFileNameWithoutExtension(path), tbnExt);
                            }
                            else
                            {
                                fPic    = Path.ChangeExtension(file, jpgExt);
                                fPicTbn = Path.ChangeExtension(file, tbnExt);
                            }

                            if (File.Exists(fPic))
                            {
                                strThumb = fPic;
                            }
                            else if (File.Exists(fPicTbn))
                            {
                                strThumb = fPicTbn;
                            }
                            else
                            {
                                if (!pItem.IsFolder && isDedicatedMovieFolder)
                                {
                                    fPic = Path.GetDirectoryName(pItem.Path) + folderJpg;

                                    if (File.Exists(fPic))
                                    {
                                        strThumb = fPic;
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }

                        pItem.ThumbnailImage = strThumb;
                        pItem.IconImageBig   = strThumb;
                        pItem.IconImage      = strThumb;

                        strThumb = Util.Utils.ConvertToLargeCoverArt(strThumb);

                        if (Util.Utils.FileExistsInCache(strThumb))
                        {
                            pItem.ThumbnailImage = strThumb;
                        }

                        movie = null;
                    } // <-- file == empty
                }     // of for (int x = 0; x < items.Count; ++x)
            }
            catch (ThreadAbortException)
            {
                // Will be logged in thread main code
            }
            catch (Exception ex)
            {
                Log.Error("SelectDVDHandler: SetIMDbThumbs: {0}", ex.Message);
            }
        }
Example #8
0
    /// <summary>
    /// Examines the current playing movie and fills in all the properties for the skin.
    /// For movies it will look in the video database for any IMDB info
    /// For record TV programs it will look in the TVDatabase for recording info 
    /// </summary>
    /// <param name="fileName">Filename of the current playing movie</param>
    /// <remarks>
    /// Function will fill in the following properties for TV programs
    /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year, #Play.Current.Channel,
    /// 
    /// Function will fill in the following properties for movies
    /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year
    /// #Play.Current.Director, #cast, #dvdlabel, #imdbnumber, #Play.Current.Plot, #Play.Current.PlotOutline, #rating, #tagline, #votes, #credits
    /// </remarks>
    private void SetCurrentFile(string fileName)
    {
      // Clear all player properties and the audio / video properties
      GUIPropertyManager.RemovePlayerProperties();
      GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", string.Empty);
      GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", string.Empty);
      GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", string.Empty);
      GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", string.Empty);
      GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", string.Empty);
      GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", string.Empty);

      // Preset title and file
      GUIPropertyManager.SetProperty("#Play.Current.Title", Util.Utils.GetFilename(fileName));
      GUIPropertyManager.SetProperty("#Play.Current.File", Util.Utils.GetFileNameWithExtension(fileName));

      // Set audio / video properties
      if ((g_Player.IsVideo || g_Player.IsDVD) && !g_Player.IsTV && g_Player.MediaInfo != null)
      {
        GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", Util.Utils.MakeFileName(g_Player.MediaInfo.VideoCodec));
        GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", g_Player.MediaInfo.VideoResolution);
        GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", Util.Utils.MakeFileName(g_Player.MediaInfo.AudioCodec));
        GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", g_Player.MediaInfo.AudioChannelsFriendly);
        GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", g_Player.MediaInfo.HasSubtitles.ToString());
        GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", g_Player.MediaInfo.AspectRatio);
      }

      // Set the properties and thumb path for movies played with the tv plugin
      if (g_Player.IsTVRecording)
      {
        // Set the thumb path to the tv recorded thumbs cache or to the channel logo
        string thumb = string.Format("{0}\\{1}{2}", Thumbs.TVRecorded, Path.ChangeExtension(Util.Utils.SplitFilename(g_Player.currentFileName), null), Util.Utils.GetThumbExtension());
        if (!Util.Utils.FileExistsInCache(thumb))
          thumb = Util.Utils.GetCoverArt(Thumbs.TVChannel, GUIPropertyManager.GetProperty("#TV.RecordedTV.Channel"));
        GUIPropertyManager.SetProperty("#Play.Current.Thumb", thumb);

        // Set the properties to the #TV.Recorded properties
        GUIPropertyManager.SetProperty("#Play.Current.Title", GUIPropertyManager.GetProperty("#TV.RecordedTV.Title"));
        GUIPropertyManager.SetProperty("#Play.Current.Plot", GUIPropertyManager.GetProperty("#TV.RecordedTV.Description"));
        GUIPropertyManager.SetProperty("#Play.Current.Genre", GUIPropertyManager.GetProperty("#TV.RecordedTV.Genre"));
        GUIPropertyManager.SetProperty("#Play.Current.Channel", GUIPropertyManager.GetProperty("#TV.RecordedTV.Channel"));
        return;
      }

      // Set title and file for DVD
      if (g_Player.IsDVD)
      {
        // for dvd's the file is in the form c:\media\movies\the matrix\video_ts\video_ts.ifo
        // first strip the \video_ts\video_ts.ifo
        string lowPath = fileName.ToLowerInvariant();
        int index = lowPath.IndexOf("video_ts/");
        if (index < 0)
        {
          index = lowPath.IndexOf(@"video_ts\");
        }
        if (index >= 0)
        {
          fileName = fileName.Substring(0, index);
          fileName = Util.Utils.RemoveTrailingSlash(fileName);

          // get the name by stripping the first part : c:\media\movies
          string strName = fileName;
          int pos = fileName.LastIndexOfAny(new char[] {'\\', '/'});
          if (pos >= 0 && pos + 1 < fileName.Length - 1)
          {
            strName = fileName.Substring(pos + 1);
          }

          // get the name when play DVD directly from Drive letter
          List<GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt();
          for (int i = rootDrives.Count - 1; i >= 0; i--)
          {
            GUIListItem itemDVDroot = (GUIListItem)rootDrives[i];
            string itemDVD = Path.GetPathRoot(itemDVDroot.Path);
            itemDVD = Util.Utils.RemoveTrailingSlash(itemDVD);
            if (itemDVD == strName && !String.IsNullOrEmpty(itemDVDroot.DVDLabel)) //cd or dvd drive
            {
              strName = itemDVDroot.DVDLabel;
            }
          }

          GUIPropertyManager.SetProperty("#Play.Current.Title", strName);
          GUIPropertyManager.SetProperty("#Play.Current.File", strName);

          // construct full filename as imdb info is stored...
          fileName += @"\VIDEO_TS\VIDEO_TS.IFO";
        }
      }

      // Get the BD handler
      ISelectBDHandler selectBdHandler;
      if (GlobalServiceProvider.IsRegistered<ISelectBDHandler>())
      {
        selectBdHandler = GlobalServiceProvider.Get<ISelectBDHandler>();
      }
      else
      {
        selectBdHandler = new SelectBDHandler();
        GlobalServiceProvider.Add<ISelectBDHandler>(selectBdHandler);
      }

      // Adapt filename for image files
      if (Util.Utils.IsISOImage(fileName))
      {
        fileName = DaemonTools.MountedIsoFile;
      }


      // -------------------------------------------------------
      // Try to set the properties and the thumb path in 5 steps

      bool movieInfoFound = false;
      bool thumbInfoFound = false;

      // Step 1 ------------------------------- -------------------------
      // Try to set the properties and thumb path from the video database
      IMDBMovie movie = new IMDBMovie();
      string name = fileName;
      if (fileName.ToLowerInvariant().Contains(".mpls")) // BD folder title check (playlist)
      {
        int index = fileName.ToLowerInvariant().LastIndexOf(@"\playlist");
        name = fileName.Remove(index) + @"\index.bdmv";
      }
      if (VideoDatabase.HasMovieInfo(name))
      {
        // Set the properties (incuding cover thumb) from the movie info
        VideoDatabase.GetMovieInfo(name, ref movie);
        if (movie.ThumbURL.ToLowerInvariant().StartsWith("file://"))
          movie.ThumbURL = movie.ThumbURL.Substring(7);
        movie.SetPlayProperties(true);
        movieInfoFound = true;
        if (!string.IsNullOrEmpty(movie.ThumbURL))
        {
          thumbInfoFound = true;
          return;
        }
      }

      // Step 2 --------------------------------------------------------
      // Try to set the properties and the thumb path from the .nfo file
      string path = string.Empty;
      int pathIndex = 0;
          
      if (fileName.ToUpperInvariant().Contains(@"\BDMV"))
      {
        pathIndex = fileName.ToUpperInvariant().LastIndexOf(@"\BDMV");
        path = fileName.Remove(pathIndex);
      }
      else if (fileName.ToUpperInvariant().Contains(@"\VIDEO_TS\"))
      {
        pathIndex = fileName.ToUpperInvariant().LastIndexOf(@"\VIDEO_TS\");
        path = fileName.Remove(pathIndex);
      }
      else if (!String.IsNullOrEmpty(fileName))
      {
        path = Path.GetDirectoryName(fileName);
      }
          
      IMDBMovie.FetchMovieNfo(path, fileName, ref movie);
      if (!movie.IsEmpty)
      {
        // Set the properties (incuding cover thumb) from the .nfo file
        movie.SetPlayProperties(true);
        movieInfoFound = true;
        if (!string.IsNullOrEmpty(movie.ThumbURL))
        {
          thumbInfoFound = true;
          return;
        }
      }

      // Step 3 -------------------------------------
      // Try to set the properties from the .xml file
      if (File.Exists(Path.ChangeExtension(fileName, ".xml")))
      {
        MatroskaTagInfo info = MatroskaTagHandler.Fetch(Path.ChangeExtension(fileName, ".xml"));
        if (info != null)
        {
          // Set properties from the .xml file
          movieInfoFound = true;
          movie.Title = info.Title;
          movie.Plot = info.Description;
          movie.Genre = info.Genre;
          if (thumbInfoFound)
          {
            // take previously found thumb
            movie.ThumbURL = GUIPropertyManager.GetProperty("#Play.Current.Thumb");
          }
          else
          {
            // take channel logo (better than nothing, but do not set thumbInfoFound)
            movie.ThumbURL = Util.Utils.GetCoverArt(Thumbs.TVChannel, info.ChannelName);
          }
          movie.SetPlayProperties(true);
          GUIPropertyManager.SetProperty("#Play.Current.Channel", info.ChannelName);
        }
      }

      // Step 4 ------------------------------------------------------------
      // If nothing else helps, try to set the thumb path from the file name
      if (!thumbInfoFound)
      {
        GUIListItem item = new GUIListItem();
        item.IsFolder = false;
        item.Path = fileName;
        Util.Utils.SetThumbnails(ref item);
        if (!string.IsNullOrEmpty(item.ThumbnailImage))
          GUIPropertyManager.SetProperty("#Play.Current.Thumb", item.ThumbnailImage);
      }

      // Step 5 --------------------------------
      // All is done if the movie info was found
      if (movieInfoFound)
        return;

      // Fallback ----------------------------------------------
      // If no movie info could be found, set at least the title
      if (!movieInfoFound && g_Player.IsTV && g_Player.IsTimeShifting)
      {
        // Set the title for live TV
        GUIPropertyManager.SetProperty("#Play.Current.Title", GUIPropertyManager.GetProperty("#TV.View.title"));
        return;
      }

      if (!movieInfoFound && VirtualDirectory.IsImageFile(Path.GetExtension(fileName)))
      {
        // Set the title for images
        string title = Util.Utils.GetFilename(fileName, true);
        GUIPropertyManager.SetProperty("#Play.Current.Title", title);
        return;
      }

      if (fileName.ToLowerInvariant().Contains("index.bdmv"))
      {
        // Set the title for BDs 
        string title = selectBdHandler.GetDiscTitle(fileName);
        if (String.IsNullOrEmpty(title))
        {
          // get the name when play BD directly from Drive letter
          List<GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt();
          title = Path.GetPathRoot(fileName);
          title = Util.Utils.RemoveTrailingSlash(title);

          for (int i = rootDrives.Count - 1; i >= 0; i--)
          {
            GUIListItem itemBDroot = (GUIListItem)rootDrives[i];
            string itemBD = Path.GetPathRoot(itemBDroot.Path);
            itemBD = Util.Utils.RemoveTrailingSlash(itemBD);
            if (itemBD == title && !String.IsNullOrEmpty(itemBDroot.DVDLabel))
            {
              title = itemBDroot.DVDLabel;
            }
          }
        }
        GUIPropertyManager.SetProperty("#Play.Current.Title", title);
      }
      else if (fileName.ToLowerInvariant().Contains(".mpls"))
      {
        // Set the title for BD playlist
        string title = selectBdHandler.GetDiscTitle(fileName);
        if (String.IsNullOrEmpty(title))
        {
          // get the name when play BD directly from Drive letter
          List<GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt();
          title = Path.GetPathRoot(fileName);
          title = Util.Utils.RemoveTrailingSlash(title);

          for (int i = rootDrives.Count - 1; i >= 0; i--)
          {
            GUIListItem itemBDroot = (GUIListItem)rootDrives[i];
            string itemBD = Path.GetPathRoot(itemBDroot.Path);
            itemBD = Util.Utils.RemoveTrailingSlash(itemBD);
            if (itemBD == title && !String.IsNullOrEmpty(itemBDroot.DVDLabel))
            {
              title = itemBDroot.DVDLabel;
            }
          }
        }
        GUIPropertyManager.SetProperty("#Play.Current.Title", title);
      }
    }
Example #9
0
        /// <summary>
        /// Examines the current playing movie and fills in all the properties for the skin.
        /// For movies it will look in the video database for any IMDB info
        /// For record TV programs it will look in the TVDatabase for recording info
        /// </summary>
        /// <param name="fileName">Filename of the current playing movie</param>
        /// <remarks>
        /// Function will fill in the following properties for TV programs
        /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year, #Play.Current.Channel,
        ///
        /// Function will fill in the following properties for movies
        /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year
        /// #Play.Current.Director, #cast, #dvdlabel, #imdbnumber, #Play.Current.Plot, #Play.Current.PlotOutline, #rating, #tagline, #votes, #credits
        /// </remarks>
        private void SetCurrentFile(string fileName)
        {
            // Clear all player properties and the audio / video properties
            GUIPropertyManager.RemovePlayerProperties();
            GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", string.Empty);

            // Preset title and file
            GUIPropertyManager.SetProperty("#Play.Current.Title", Util.Utils.GetFilename(fileName));
            GUIPropertyManager.SetProperty("#Play.Current.File", Util.Utils.GetFileNameWithExtension(fileName));

            // Set audio / video properties
            if ((g_Player.IsVideo || g_Player.IsDVD) && !g_Player.IsTV && g_Player.MediaInfo != null)
            {
                GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", Util.Utils.MakeFileName(g_Player.MediaInfo.VideoCodec));
                GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", g_Player.MediaInfo.VideoResolution);
                GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", Util.Utils.MakeFileName(g_Player.MediaInfo.AudioCodec));
                GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", g_Player.MediaInfo.AudioChannelsFriendly);
                GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", g_Player.MediaInfo.HasSubtitles.ToString());
                GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", g_Player.MediaInfo.AspectRatio);
            }

            // Set the properties and thumb path for movies played with the tv plugin
            if (g_Player.IsTVRecording)
            {
                // Set the thumb path to the tv recorded thumbs cache or to the channel logo
                string thumb = string.Format("{0}\\{1}{2}", Thumbs.TVRecorded, Path.ChangeExtension(Util.Utils.SplitFilename(g_Player.currentFileName), null), Util.Utils.GetThumbExtension());
                if (!Util.Utils.FileExistsInCache(thumb))
                {
                    thumb = Util.Utils.GetCoverArt(Thumbs.TVChannel, GUIPropertyManager.GetProperty("#TV.RecordedTV.Channel"));
                }
                GUIPropertyManager.SetProperty("#Play.Current.Thumb", thumb);

                // Set the properties to the #TV.Recorded properties
                GUIPropertyManager.SetProperty("#Play.Current.Title", GUIPropertyManager.GetProperty("#TV.RecordedTV.Title"));
                GUIPropertyManager.SetProperty("#Play.Current.Plot", GUIPropertyManager.GetProperty("#TV.RecordedTV.Description"));
                GUIPropertyManager.SetProperty("#Play.Current.Genre", GUIPropertyManager.GetProperty("#TV.RecordedTV.Genre"));
                GUIPropertyManager.SetProperty("#Play.Current.Channel", GUIPropertyManager.GetProperty("#TV.RecordedTV.Channel"));
                return;
            }

            // Set title and file for DVD
            if (g_Player.IsDVD)
            {
                // for dvd's the file is in the form c:\media\movies\the matrix\video_ts\video_ts.ifo
                // first strip the \video_ts\video_ts.ifo
                string lowPath = fileName.ToLowerInvariant();
                int    index   = lowPath.IndexOf("video_ts/");
                if (index < 0)
                {
                    index = lowPath.IndexOf(@"video_ts\");
                }
                if (index >= 0)
                {
                    fileName = fileName.Substring(0, index);
                    fileName = Util.Utils.RemoveTrailingSlash(fileName);

                    // get the name by stripping the first part : c:\media\movies
                    string strName = fileName;
                    int    pos     = fileName.LastIndexOfAny(new char[] { '\\', '/' });
                    if (pos >= 0 && pos + 1 < fileName.Length - 1)
                    {
                        strName = fileName.Substring(pos + 1);
                    }

                    // get the name when play DVD directly from Drive letter
                    List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt();
                    for (int i = rootDrives.Count - 1; i >= 0; i--)
                    {
                        GUIListItem itemDVDroot = (GUIListItem)rootDrives[i];
                        string      itemDVD     = Path.GetPathRoot(itemDVDroot.Path);
                        itemDVD = Util.Utils.RemoveTrailingSlash(itemDVD);
                        if (itemDVD == strName && !String.IsNullOrEmpty(itemDVDroot.DVDLabel)) //cd or dvd drive
                        {
                            strName = itemDVDroot.DVDLabel;
                        }
                    }

                    GUIPropertyManager.SetProperty("#Play.Current.Title", strName);
                    GUIPropertyManager.SetProperty("#Play.Current.File", strName);

                    // construct full filename as imdb info is stored...
                    fileName += @"\VIDEO_TS\VIDEO_TS.IFO";
                }
            }

            // Get the BD handler
            ISelectBDHandler selectBdHandler;

            if (GlobalServiceProvider.IsRegistered <ISelectBDHandler>())
            {
                selectBdHandler = GlobalServiceProvider.Get <ISelectBDHandler>();
            }
            else
            {
                selectBdHandler = new SelectBDHandler();
                GlobalServiceProvider.Add <ISelectBDHandler>(selectBdHandler);
            }

            // Adapt filename for image files
            if (Util.Utils.IsISOImage(fileName))
            {
                fileName = DaemonTools.MountedIsoFile;
            }


            // -------------------------------------------------------
            // Try to set the properties and the thumb path in 5 steps

            bool movieInfoFound = false;
            bool thumbInfoFound = false;

            // Step 1 ------------------------------- -------------------------
            // Try to set the properties and thumb path from the video database
            IMDBMovie movie = new IMDBMovie();
            string    name  = fileName;

            if (fileName.ToLowerInvariant().Contains(".mpls")) // BD folder title check (playlist)
            {
                int index = fileName.ToLowerInvariant().LastIndexOf(@"\playlist");
                name = fileName.Remove(index) + @"\index.bdmv";
            }
            if (VideoDatabase.HasMovieInfo(name))
            {
                // Set the properties (incuding cover thumb) from the movie info
                VideoDatabase.GetMovieInfo(name, ref movie);
                if (movie.ThumbURL.ToLowerInvariant().StartsWith("file://"))
                {
                    movie.ThumbURL = movie.ThumbURL.Substring(7);
                }
                movie.SetPlayProperties(true);
                movieInfoFound = true;
                if (!string.IsNullOrEmpty(movie.ThumbURL))
                {
                    thumbInfoFound = true;
                    return;
                }
            }

            // Step 2 --------------------------------------------------------
            // Try to set the properties and the thumb path from the .nfo file
            string path      = string.Empty;
            int    pathIndex = 0;

            if (fileName.ToUpperInvariant().Contains(@"\BDMV"))
            {
                pathIndex = fileName.ToUpperInvariant().LastIndexOf(@"\BDMV");
                path      = fileName.Remove(pathIndex);
            }
            else if (fileName.ToUpperInvariant().Contains(@"\VIDEO_TS\"))
            {
                pathIndex = fileName.ToUpperInvariant().LastIndexOf(@"\VIDEO_TS\");
                path      = fileName.Remove(pathIndex);
            }
            else if (!String.IsNullOrEmpty(fileName))
            {
                path = Path.GetDirectoryName(fileName);
            }

            IMDBMovie.FetchMovieNfo(path, fileName, ref movie);
            if (!movie.IsEmpty)
            {
                // Set the properties (incuding cover thumb) from the .nfo file
                movie.SetPlayProperties(true);
                movieInfoFound = true;
                if (!string.IsNullOrEmpty(movie.ThumbURL))
                {
                    thumbInfoFound = true;
                    return;
                }
            }

            // Step 3 -------------------------------------
            // Try to set the properties from the .xml file
            if (File.Exists(Path.ChangeExtension(fileName, ".xml")))
            {
                MatroskaTagInfo info = MatroskaTagHandler.Fetch(Path.ChangeExtension(fileName, ".xml"));
                if (info != null)
                {
                    // Set properties from the .xml file
                    movieInfoFound = true;
                    movie.Title    = info.Title;
                    movie.Plot     = info.Description;
                    movie.Genre    = info.Genre;
                    if (thumbInfoFound)
                    {
                        // take previously found thumb
                        movie.ThumbURL = GUIPropertyManager.GetProperty("#Play.Current.Thumb");
                    }
                    else
                    {
                        // take channel logo (better than nothing, but do not set thumbInfoFound)
                        movie.ThumbURL = Util.Utils.GetCoverArt(Thumbs.TVChannel, info.ChannelName);
                    }
                    movie.SetPlayProperties(true);
                    GUIPropertyManager.SetProperty("#Play.Current.Channel", info.ChannelName);
                }
            }

            // Step 4 ------------------------------------------------------------
            // If nothing else helps, try to set the thumb path from the file name
            if (!thumbInfoFound)
            {
                GUIListItem item = new GUIListItem();
                item.IsFolder = false;
                item.Path     = fileName;
                Util.Utils.SetThumbnails(ref item);
                if (!string.IsNullOrEmpty(item.ThumbnailImage))
                {
                    GUIPropertyManager.SetProperty("#Play.Current.Thumb", item.ThumbnailImage);
                }
            }

            // Step 5 --------------------------------
            // All is done if the movie info was found
            if (movieInfoFound)
            {
                return;
            }

            // Fallback ----------------------------------------------
            // If no movie info could be found, set at least the title
            if (!movieInfoFound && g_Player.IsTV && g_Player.IsTimeShifting)
            {
                // Set the title for live TV
                GUIPropertyManager.SetProperty("#Play.Current.Title", GUIPropertyManager.GetProperty("#TV.View.title"));
                return;
            }

            if (!movieInfoFound && VirtualDirectory.IsImageFile(Path.GetExtension(fileName)))
            {
                // Set the title for images
                string title = Util.Utils.GetFilename(fileName, true);
                GUIPropertyManager.SetProperty("#Play.Current.Title", title);
                return;
            }

            if (fileName.ToLowerInvariant().Contains("index.bdmv"))
            {
                // Set the title for BDs
                string title = selectBdHandler.GetDiscTitle(fileName);
                if (String.IsNullOrEmpty(title))
                {
                    // get the name when play BD directly from Drive letter
                    List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt();
                    title = Path.GetPathRoot(fileName);
                    title = Util.Utils.RemoveTrailingSlash(title);

                    for (int i = rootDrives.Count - 1; i >= 0; i--)
                    {
                        GUIListItem itemBDroot = (GUIListItem)rootDrives[i];
                        string      itemBD     = Path.GetPathRoot(itemBDroot.Path);
                        itemBD = Util.Utils.RemoveTrailingSlash(itemBD);
                        if (itemBD == title && !String.IsNullOrEmpty(itemBDroot.DVDLabel))
                        {
                            title = itemBDroot.DVDLabel;
                        }
                    }
                }
                GUIPropertyManager.SetProperty("#Play.Current.Title", title);
            }
            else if (fileName.ToLowerInvariant().Contains(".mpls"))
            {
                // Set the title for BD playlist
                string title = selectBdHandler.GetDiscTitle(fileName);
                if (String.IsNullOrEmpty(title))
                {
                    // get the name when play BD directly from Drive letter
                    List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt();
                    title = Path.GetPathRoot(fileName);
                    title = Util.Utils.RemoveTrailingSlash(title);

                    for (int i = rootDrives.Count - 1; i >= 0; i--)
                    {
                        GUIListItem itemBDroot = (GUIListItem)rootDrives[i];
                        string      itemBD     = Path.GetPathRoot(itemBDroot.Path);
                        itemBD = Util.Utils.RemoveTrailingSlash(itemBD);
                        if (itemBD == title && !String.IsNullOrEmpty(itemBDroot.DVDLabel))
                        {
                            title = itemBDroot.DVDLabel;
                        }
                    }
                }
                GUIPropertyManager.SetProperty("#Play.Current.Title", title);
            }
        }
Example #10
0
    /// <summary>
    /// Examines the current playing movie and fills in all the #tags for the skin.
    /// For movies it will look in the video database for any IMDB info
    /// For record TV programs it will look in the TVDatabase for recording info 
    /// </summary>
    /// <param name="fileName">Filename of the current playing movie</param>
    /// <remarks>
    /// Function will fill in the following tags for TV programs
    /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year, #Play.Current.Channel,
    /// 
    /// Function will fill in the following tags for movies
    /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year
    /// #Play.Current.Director, #cast, #dvdlabel, #imdbnumber, #Play.Current.Plot, #Play.Current.PlotOutline, #rating, #tagline, #votes, #credits
    /// </remarks>
    private void SetCurrentFile(string fileName)
    {
      GUIPropertyManager.RemovePlayerProperties();
      GUIPropertyManager.SetProperty("#Play.Current.Title", Util.Utils.GetFilename(fileName));
      GUIPropertyManager.SetProperty("#Play.Current.File", Util.Utils.GetFileNameWithExtension(fileName));
      GUIPropertyManager.SetProperty("#Play.Current.Thumb", string.Empty);
      GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", string.Empty);
      GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", string.Empty);
      GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", string.Empty);
      GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", string.Empty);
      GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", string.Empty);
      GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", string.Empty);

      if ((g_Player.IsVideo || g_Player.IsDVD) && !g_Player.IsTV && g_Player.MediaInfo != null)
      {
        GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture",
                                       Util.Utils.MakeFileName(g_Player.MediaInfo.VideoCodec));
        GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", g_Player.MediaInfo.VideoResolution);
        GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture",
                                       Util.Utils.MakeFileName(g_Player.MediaInfo.AudioCodec));
        GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", g_Player.MediaInfo.AudioChannelsFriendly);
        GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", g_Player.MediaInfo.HasSubtitles.ToString());
        GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", g_Player.MediaInfo.AspectRatio);
      }

      if (g_Player.IsDVD)
      {
        // for dvd's the file is in the form c:\media\movies\the matrix\video_ts\video_ts.ifo
        // first strip the \video_ts\video_ts.ifo
        string lowPath = fileName.ToLower();
        int index = lowPath.IndexOf("video_ts/");
        if (index < 0)
        {
          index = lowPath.IndexOf(@"video_ts\");
        }
        if (index >= 0)
        {
          fileName = fileName.Substring(0, index);
          fileName = Util.Utils.RemoveTrailingSlash(fileName);

          // get the name by stripping the first part : c:\media\movies
          string strName = fileName;
          int pos = fileName.LastIndexOfAny(new char[] {'\\', '/'});
          if (pos >= 0 && pos + 1 < fileName.Length - 1)
          {
            strName = fileName.Substring(pos + 1);
          }

          // get the name when play DVD directly from Drive letter
          List<GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt();
          for (int i = rootDrives.Count - 1; i >= 0; i--)
          {
            GUIListItem itemDVDroot = (GUIListItem)rootDrives[i];
            string itemDVD = Path.GetPathRoot(itemDVDroot.Path);
            itemDVD = Util.Utils.RemoveTrailingSlash(itemDVD);
            if (itemDVD == strName && !String.IsNullOrEmpty(itemDVDroot.DVDLabel)) //cd or dvd drive
            {
              strName = itemDVDroot.DVDLabel;
            }
          }

          GUIPropertyManager.SetProperty("#Play.Current.Title", strName);
          GUIPropertyManager.SetProperty("#Play.Current.File", strName);

          // construct full filename as imdb info is stored...
          fileName += @"\VIDEO_TS\VIDEO_TS.IFO";
        }
      }

      bool isLive = g_Player.IsTimeShifting;
      string extension = Util.Utils.GetFileExtension(fileName).ToLower();
      if (extension.Equals(".sbe") || extension.Equals(".dvr-ms") ||
          (extension.Equals(".ts") && !isLive || g_Player.IsTVRecording))
      {
        // this is a recorded movie.
        // check the TVDatabase for the description,genre,title,...
        if (g_Player.currentTitle != "")
        {
          GUIPropertyManager.SetProperty("#Play.Current.Title", g_Player.currentTitle);
          GUIPropertyManager.SetProperty("#Play.Current.Plot",
                                         g_Player.currentTitle + "\n" + g_Player.currentDescription);
          GUIPropertyManager.SetProperty("#Play.Current.PlotOutline", g_Player.currentDescription);
        }
      }

      /*if (fileName.Substring(0, 4) == "rtsp")
      {
          GUIPropertyManager.SetProperty("#Play.Current.Title", g_Player.currentTitle);
          GUIPropertyManager.SetProperty("#Play.Current.Plot", g_Player.currentTitle + "\n" + g_Player.currentDescription);
          GUIPropertyManager.SetProperty("#Play.Current.PlotOutline", g_Player.currentDescription);
      }*/


      IMDBMovie movieDetails = new IMDBMovie();
      bool bMovieInfoFound = false;
      
      ISelectBDHandler selectBdHandler;
      if (GlobalServiceProvider.IsRegistered<ISelectBDHandler>())
      {
        selectBdHandler = GlobalServiceProvider.Get<ISelectBDHandler>();
      }
      else
      {
        selectBdHandler = new SelectBDHandler();
        GlobalServiceProvider.Add<ISelectBDHandler>(selectBdHandler);
      }
      
      bool playingRemoteUrl = Util.Utils.IsRemoteUrl(fileName);
      if (!g_Player.IsTVRecording && !playingRemoteUrl)
      {
        // Check if we play image file to search db with the proper filename
        if (Util.Utils.IsISOImage(fileName))
        {
          fileName = DaemonTools.MountedIsoFile;
        }

        if (VideoDatabase.HasMovieInfo(fileName))
        {
          VideoDatabase.GetMovieInfo(fileName, ref movieDetails);
          bMovieInfoFound = true;
        }
        else if (File.Exists(Path.ChangeExtension(fileName, ".xml")))
        {
          MatroskaTagInfo info = MatroskaTagHandler.Fetch(Path.ChangeExtension(fileName, ".xml"));
          movieDetails.Title = info.title;
          movieDetails.Plot = info.description;
          movieDetails.Genre = info.genre;
          GUIPropertyManager.SetProperty("#Play.Current.Channel", info.channelName);
          string logo = Util.Utils.GetCoverArt(Thumbs.TVChannel, info.channelName);
          if (!Util.Utils.FileExistsInCache(logo))
          {
            logo = "defaultVideoBig.png";
          }
          GUIPropertyManager.SetProperty("#Play.Current.Thumb", logo);
          _thumbLogo = logo;
          bMovieInfoFound = true;
        }
        else // Nfo support
        {
          string path = string.Empty;
          int pathIndex = 0;
          
          if (fileName.ToUpperInvariant().Contains(@"\BDMV"))
          {
            pathIndex = fileName.ToUpperInvariant().LastIndexOf(@"\BDMV");
            path = fileName.Remove(pathIndex);
          }
          else if (fileName.ToUpperInvariant().Contains(@"\VIDEO_TS\"))
          {
            pathIndex = fileName.ToUpperInvariant().LastIndexOf(@"\VIDEO_TS\");
            path = fileName.Remove(pathIndex);
          }
          else
          {
            path = Path.GetDirectoryName(fileName);
          }
          
          IMDBMovie.FetchMovieNfo(path, fileName, ref movieDetails);

          if (!movieDetails.IsEmpty)
          {
            bMovieInfoFound = true;
          }
        }
        if (bMovieInfoFound)
        {
          movieDetails.SetPlayProperties(true);
        }
        else
        {
          GUIListItem item = new GUIListItem();
          item.IsFolder = false;
          item.Path = fileName;
          Util.Utils.SetThumbnails(ref item);
          GUIPropertyManager.SetProperty("#Play.Current.Thumb", item.ThumbnailImage);

          // Image file check to set title for OSD (non db)
          if (VirtualDirectory.IsImageFile(Path.GetExtension(fileName)))
          {
            string title = Util.Utils.GetFilename(fileName, true);
            GUIPropertyManager.SetProperty("#Play.Current.Title", title);
          }
          else if (fileName.ToLower().Contains("index.bdmv")) // BD folder title check
          {
            string title = selectBdHandler.GetBDFolderName(fileName);
            // get the name when play BD directly from Drive letter
            if (String.IsNullOrEmpty(title))
            {
              List<GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt();
              title = Path.GetPathRoot(fileName);
              title = Util.Utils.RemoveTrailingSlash(title);

              for (int i = rootDrives.Count - 1; i >= 0; i--)
              {
                GUIListItem itemBDroot = (GUIListItem)rootDrives[i];
                string itemBD = Path.GetPathRoot(itemBDroot.Path);
                itemBD = Util.Utils.RemoveTrailingSlash(itemBD);
                if (itemBD == title && !String.IsNullOrEmpty(itemBDroot.DVDLabel)) //cd or dvd drive
                {
                  title = itemBDroot.DVDLabel;
                }
              }
            }
            GUIPropertyManager.SetProperty("#Play.Current.Title", title);
          }
          else if (fileName.ToLower().Contains(".mpls")) // BD folder title check (playlist)
          {
            // Check if index.bdmv is in the VDB
            int index = fileName.ToLower().LastIndexOf(@"\playlist");
            string name = fileName.Remove(index);
            name = name + @"\index.bdmv";
            if (VideoDatabase.HasMovieInfo(name))
            {
              VideoDatabase.GetMovieInfo(name, ref movieDetails);
              movieDetails.SetPlayProperties();
            }
            else
            {
              string title = selectBdHandler.GetBDFolderName(fileName);
              // get the name when play BD directly from Drive letter
              if (String.IsNullOrEmpty(title))
              {
                List<GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt();
                title = Path.GetPathRoot(fileName);
                title = Util.Utils.RemoveTrailingSlash(title);

                for (int i = rootDrives.Count - 1; i >= 0; i--)
                {
                  GUIListItem itemBDroot = (GUIListItem)rootDrives[i];
                  string itemBD = Path.GetPathRoot(itemBDroot.Path);
                  itemBD = Util.Utils.RemoveTrailingSlash(itemBD);
                  if (itemBD == title && !String.IsNullOrEmpty(itemBDroot.DVDLabel)) //cd or dvd drive
                  {
                    title = itemBDroot.DVDLabel;
                  }
                }
              }
              GUIPropertyManager.SetProperty("#Play.Current.Title", title);
            }
          }
        }
      }
      else if (g_Player.IsTV && g_Player.IsTimeShifting)
      {
        GUIPropertyManager.SetProperty("#Play.Current.Title", GUIPropertyManager.GetProperty("#TV.View.channel"));
        GUIPropertyManager.SetProperty("#Play.Current.Genre", GUIPropertyManager.GetProperty("#TV.View.title"));
      }
      else
      {
        GUIListItem item = new GUIListItem();
        item.IsFolder = false;
        item.Path = fileName;
        Util.Utils.SetThumbnails(ref item);
        GUIPropertyManager.SetProperty("#Play.Current.Thumb", item.ThumbnailImage);
      }
      _thumbLogo = GUIPropertyManager.GetProperty("#Play.Current.Thumb");
    }
Example #11
0
    private void RefreshMediaInfo(GUIListItem item)
    {
      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();
      }
    }
Example #12
0
        /// <summary>
        /// Examines the current playing movie and fills in all the #tags for the skin.
        /// For movies it will look in the video database for any IMDB info
        /// For record TV programs it will look in the TVDatabase for recording info
        /// </summary>
        /// <param name="fileName">Filename of the current playing movie</param>
        /// <remarks>
        /// Function will fill in the following tags for TV programs
        /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year, #Play.Current.Channel,
        ///
        /// Function will fill in the following tags for movies
        /// #Play.Current.Title, #Play.Current.Plot, #Play.Current.PlotOutline #Play.Current.File, #Play.Current.Thumb, #Play.Current.Year
        /// #Play.Current.Director, #cast, #dvdlabel, #imdbnumber, #Play.Current.Plot, #Play.Current.PlotOutline, #rating, #tagline, #votes, #credits
        /// </remarks>
        private void SetCurrentFile(string fileName)
        {
            GUIPropertyManager.RemovePlayerProperties();
            GUIPropertyManager.SetProperty("#Play.Current.Title", Util.Utils.GetFilename(fileName));
            GUIPropertyManager.SetProperty("#Play.Current.File", Util.Utils.GetFileNameWithExtension(fileName));
            GUIPropertyManager.SetProperty("#Play.Current.Thumb", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", string.Empty);
            GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", string.Empty);

            if ((g_Player.IsVideo || g_Player.IsDVD) && !g_Player.IsTV && g_Player.MediaInfo != null)
            {
                GUIPropertyManager.SetProperty("#Play.Current.VideoCodec.Texture",
                                               Util.Utils.MakeFileName(g_Player.MediaInfo.VideoCodec));
                GUIPropertyManager.SetProperty("#Play.Current.VideoResolution", g_Player.MediaInfo.VideoResolution);
                GUIPropertyManager.SetProperty("#Play.Current.AudioCodec.Texture",
                                               Util.Utils.MakeFileName(g_Player.MediaInfo.AudioCodec));
                GUIPropertyManager.SetProperty("#Play.Current.AudioChannels", g_Player.MediaInfo.AudioChannelsFriendly);
                GUIPropertyManager.SetProperty("#Play.Current.HasSubtitles", g_Player.MediaInfo.HasSubtitles.ToString());
                GUIPropertyManager.SetProperty("#Play.Current.AspectRatio", g_Player.MediaInfo.AspectRatio);
            }

            if (g_Player.IsDVD)
            {
                // for dvd's the file is in the form c:\media\movies\the matrix\video_ts\video_ts.ifo
                // first strip the \video_ts\video_ts.ifo
                string lowPath = fileName.ToLowerInvariant();
                int    index   = lowPath.IndexOf("video_ts/");
                if (index < 0)
                {
                    index = lowPath.IndexOf(@"video_ts\");
                }
                if (index >= 0)
                {
                    fileName = fileName.Substring(0, index);
                    fileName = Util.Utils.RemoveTrailingSlash(fileName);

                    // get the name by stripping the first part : c:\media\movies
                    string strName = fileName;
                    int    pos     = fileName.LastIndexOfAny(new char[] { '\\', '/' });
                    if (pos >= 0 && pos + 1 < fileName.Length - 1)
                    {
                        strName = fileName.Substring(pos + 1);
                    }

                    // get the name when play DVD directly from Drive letter
                    List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt();
                    for (int i = rootDrives.Count - 1; i >= 0; i--)
                    {
                        GUIListItem itemDVDroot = (GUIListItem)rootDrives[i];
                        string      itemDVD     = Path.GetPathRoot(itemDVDroot.Path);
                        itemDVD = Util.Utils.RemoveTrailingSlash(itemDVD);
                        if (itemDVD == strName && !String.IsNullOrEmpty(itemDVDroot.DVDLabel)) //cd or dvd drive
                        {
                            strName = itemDVDroot.DVDLabel;
                        }
                    }

                    GUIPropertyManager.SetProperty("#Play.Current.Title", strName);
                    GUIPropertyManager.SetProperty("#Play.Current.File", strName);

                    // construct full filename as imdb info is stored...
                    fileName += @"\VIDEO_TS\VIDEO_TS.IFO";
                }
            }

            bool   isLive    = g_Player.IsTimeShifting;
            string extension = Util.Utils.GetFileExtension(fileName).ToLowerInvariant();

            if (extension.Equals(".sbe") || extension.Equals(".dvr-ms") ||
                (extension.Equals(".ts") && !isLive || g_Player.IsTVRecording))
            {
                // this is a recorded movie.
                // check the TVDatabase for the description,genre,title,...
                if (g_Player.currentTitle != "")
                {
                    GUIPropertyManager.SetProperty("#Play.Current.Title", g_Player.currentTitle);
                    GUIPropertyManager.SetProperty("#Play.Current.Plot",
                                                   g_Player.currentTitle + "\n" + g_Player.currentDescription);
                    GUIPropertyManager.SetProperty("#Play.Current.PlotOutline", g_Player.currentDescription);
                }
            }

            /*if (fileName.Substring(0, 4) == "rtsp")
             * {
             *  GUIPropertyManager.SetProperty("#Play.Current.Title", g_Player.currentTitle);
             *  GUIPropertyManager.SetProperty("#Play.Current.Plot", g_Player.currentTitle + "\n" + g_Player.currentDescription);
             *  GUIPropertyManager.SetProperty("#Play.Current.PlotOutline", g_Player.currentDescription);
             * }*/


            IMDBMovie movieDetails    = new IMDBMovie();
            bool      bMovieInfoFound = false;

            ISelectBDHandler selectBdHandler;

            if (GlobalServiceProvider.IsRegistered <ISelectBDHandler>())
            {
                selectBdHandler = GlobalServiceProvider.Get <ISelectBDHandler>();
            }
            else
            {
                selectBdHandler = new SelectBDHandler();
                GlobalServiceProvider.Add <ISelectBDHandler>(selectBdHandler);
            }

            bool playingRemoteUrl = Util.Utils.IsRemoteUrl(fileName);

            if (!g_Player.IsTVRecording && !playingRemoteUrl)
            {
                // Check if we play image file to search db with the proper filename
                if (Util.Utils.IsISOImage(fileName))
                {
                    fileName = DaemonTools.MountedIsoFile;
                }

                if (VideoDatabase.HasMovieInfo(fileName))
                {
                    VideoDatabase.GetMovieInfo(fileName, ref movieDetails);
                    bMovieInfoFound = true;
                }
                else if (File.Exists(Path.ChangeExtension(fileName, ".xml")))
                {
                    MatroskaTagInfo info = MatroskaTagHandler.Fetch(Path.ChangeExtension(fileName, ".xml"));
                    movieDetails.Title = info.title;
                    movieDetails.Plot  = info.description;
                    movieDetails.Genre = info.genre;
                    GUIPropertyManager.SetProperty("#Play.Current.Channel", info.channelName);
                    string logo = Util.Utils.GetCoverArt(Thumbs.TVChannel, info.channelName);
                    if (!Util.Utils.FileExistsInCache(logo))
                    {
                        logo = "defaultVideoBig.png";
                    }
                    GUIPropertyManager.SetProperty("#Play.Current.Thumb", logo);
                    _thumbLogo      = logo;
                    bMovieInfoFound = true;
                }
                else // Nfo support
                {
                    string path      = string.Empty;
                    int    pathIndex = 0;

                    if (fileName.ToUpperInvariant().Contains(@"\BDMV"))
                    {
                        pathIndex = fileName.ToUpperInvariant().LastIndexOf(@"\BDMV");
                        path      = fileName.Remove(pathIndex);
                    }
                    else if (fileName.ToUpperInvariant().Contains(@"\VIDEO_TS\"))
                    {
                        pathIndex = fileName.ToUpperInvariant().LastIndexOf(@"\VIDEO_TS\");
                        path      = fileName.Remove(pathIndex);
                    }
                    else if (!String.IsNullOrEmpty(fileName))
                    {
                        path = Path.GetDirectoryName(fileName);
                    }

                    IMDBMovie.FetchMovieNfo(path, fileName, ref movieDetails);

                    if (!movieDetails.IsEmpty)
                    {
                        bMovieInfoFound = true;
                    }
                }
                if (bMovieInfoFound)
                {
                    movieDetails.SetPlayProperties(true);
                }
                else
                {
                    GUIListItem item = new GUIListItem();
                    item.IsFolder = false;
                    item.Path     = fileName;
                    Util.Utils.SetThumbnails(ref item);
                    GUIPropertyManager.SetProperty("#Play.Current.Thumb", item.ThumbnailImage);

                    // Image file check to set title for OSD (non db)
                    if (VirtualDirectory.IsImageFile(Path.GetExtension(fileName)))
                    {
                        string title = Util.Utils.GetFilename(fileName, true);
                        GUIPropertyManager.SetProperty("#Play.Current.Title", title);
                    }
                    else if (fileName.ToLowerInvariant().Contains("index.bdmv")) // BD folder title check
                    {
                        string title = selectBdHandler.GetDiscTitle(fileName);
                        // get the name when play BD directly from Drive letter
                        if (String.IsNullOrEmpty(title))
                        {
                            List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt();
                            title = Path.GetPathRoot(fileName);
                            title = Util.Utils.RemoveTrailingSlash(title);

                            for (int i = rootDrives.Count - 1; i >= 0; i--)
                            {
                                GUIListItem itemBDroot = (GUIListItem)rootDrives[i];
                                string      itemBD     = Path.GetPathRoot(itemBDroot.Path);
                                itemBD = Util.Utils.RemoveTrailingSlash(itemBD);
                                if (itemBD == title && !String.IsNullOrEmpty(itemBDroot.DVDLabel)) //cd or dvd drive
                                {
                                    title = itemBDroot.DVDLabel;
                                }
                            }
                        }
                        GUIPropertyManager.SetProperty("#Play.Current.Title", title);
                    }
                    else if (fileName.ToLowerInvariant().Contains(".mpls")) // BD folder title check (playlist)
                    {
                        // Check if index.bdmv is in the VDB
                        int    index = fileName.ToLowerInvariant().LastIndexOf(@"\playlist");
                        string name  = fileName.Remove(index);
                        name = name + @"\index.bdmv";
                        if (VideoDatabase.HasMovieInfo(name))
                        {
                            VideoDatabase.GetMovieInfo(name, ref movieDetails);
                            movieDetails.SetPlayProperties();
                        }
                        else
                        {
                            string title = selectBdHandler.GetDiscTitle(fileName);
                            // get the name when play BD directly from Drive letter
                            if (String.IsNullOrEmpty(title))
                            {
                                List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt();
                                title = Path.GetPathRoot(fileName);
                                title = Util.Utils.RemoveTrailingSlash(title);

                                for (int i = rootDrives.Count - 1; i >= 0; i--)
                                {
                                    GUIListItem itemBDroot = (GUIListItem)rootDrives[i];
                                    string      itemBD     = Path.GetPathRoot(itemBDroot.Path);
                                    itemBD = Util.Utils.RemoveTrailingSlash(itemBD);
                                    if (itemBD == title && !String.IsNullOrEmpty(itemBDroot.DVDLabel)) //cd or dvd drive
                                    {
                                        title = itemBDroot.DVDLabel;
                                    }
                                }
                            }
                            GUIPropertyManager.SetProperty("#Play.Current.Title", title);
                        }
                    }
                }
            }
            else if (g_Player.IsTV && g_Player.IsTimeShifting)
            {
                GUIPropertyManager.SetProperty("#Play.Current.Title", GUIPropertyManager.GetProperty("#TV.View.channel"));
                GUIPropertyManager.SetProperty("#Play.Current.Genre", GUIPropertyManager.GetProperty("#TV.View.title"));
            }
            else
            {
                GUIListItem item = new GUIListItem();
                item.IsFolder = false;
                item.Path     = fileName;
                Util.Utils.SetThumbnails(ref item);
                GUIPropertyManager.SetProperty("#Play.Current.Thumb", item.ThumbnailImage);
            }
            _thumbLogo = GUIPropertyManager.GetProperty("#Play.Current.Thumb");
        }
    // Changed - cover for movies with the same name
    public void SetIMDBThumbs(IList items, bool markWatchedFiles)
    {
      try 
      {
        GUIListItem pItem;
        IMDBMovie movieDetails = new IMDBMovie();
		    //bool eachMovieHasDedicatedFolder = false;
        ISelectBDHandler selectBdHandler;
        
        if (GlobalServiceProvider.IsRegistered<ISelectBDHandler>())
        {
          selectBdHandler = GlobalServiceProvider.Get<ISelectBDHandler>();
        }
        else
        {
          selectBdHandler = new SelectBDHandler();
          GlobalServiceProvider.Add<ISelectBDHandler>(selectBdHandler);
        }

        for (int x = 0; x < items.Count; x++)
        {
          string strThumb = string.Empty;
          pItem = (GUIListItem)items[x];
          string file = string.Empty;
          bool isFolderPinProtected = (pItem.IsFolder && IsFolderPinProtected(pItem.Path));
          
          // Skip DVD & BD backup folder
          if (pItem.IsFolder && !pItem.IsBdDvdFolder)
          {
            if (pItem.Label == "..")
            {
              continue;
            }

            if (isFolderPinProtected)
            {
              // hide maybe rated content
              Util.Utils.SetDefaultIcons(pItem);
              continue;
            }

            // If this is enabled you'll see the thumb of the first movie in that dir - but if you put serveral movies into that dir you'll be irritated...          
            if (!pItem.IsRemote && Util.Utils.IsFolderDedicatedMovieFolder(pItem.Path))
            {
              string[] strFiles = null;
                
              try
              {
                strFiles = Directory.GetFiles(pItem.Path);
              }
              catch (Exception) { }
                
              if (strFiles != null)
              {
                for (int i = 0; i < strFiles.Length; ++i)
                {
                  string extensionension = Path.GetExtension(strFiles[i]);
                    
                  if (VirtualDirectory.IsImageFile(extensionension))
                  {
                    if (DaemonTools.IsEnabled)
                    {
                      file = strFiles[i];
                      break;
                    }
                    continue;
                  }
                  if (VirtualDirectory.IsValidExtension(strFiles[i], Util.Utils.VideoExtensions, false))
                  {
                    // Skip hidden files
                    if ((File.GetAttributes(strFiles[i]) & FileAttributes.Hidden) == FileAttributes.Hidden)
                    {
                      continue;
                    }
                    file =  strFiles[i];
                    break;
                  }
                }
              }
            }
          }
          // If folder is DVD backup folder then take it for watched status
          else if (pItem.IsFolder && IsDvdDirectory(pItem.Path))
          {
            file = GetFolderVideoFile(pItem.Path);
          }
            // Check for BD folder
          else if (pItem.IsFolder && selectBdHandler.IsBDDirectory(pItem.Path))
          {
            file = selectBdHandler.GetFolderVideoFile(pItem.Path);
          }
          else if (!pItem.IsFolder ||
                   (pItem.IsFolder && VirtualDirectory.IsImageFile(Path.GetExtension(pItem.Path).ToLower())))
          {
            file = pItem.Path;
          }
          else
          {
            continue;
          }

          if (!string.IsNullOrEmpty(file))
          {
            int id = VideoDatabase.GetMovieInfo(file, ref movieDetails);
            
            // Set thumb for movies
            if (id >= 0)
            {
              if (Util.Utils.IsDVD(pItem.Path))
              {
                pItem.Label = String.Format("({0}:) {1}", pItem.Path.Substring(0, 1), movieDetails.Title);
              }

              string titleExt = movieDetails.Title + "{" + movieDetails.ID + "}";
              strThumb = Util.Utils.GetCoverArt(Thumbs.MovieTitle, titleExt);
            }
            
            if (!Util.Utils.FileExistsInCache(strThumb) || string.IsNullOrEmpty(strThumb))
            {
              string fPic = string.Empty;
              string fPicTbn = string.Empty;
              string path = pItem.Path;
              Util.Utils.RemoveStackEndings(ref path);
              Util.Utils.RemoveStackEndings(ref file);
                
              if (pItem.IsBdDvdFolder)
              {
                fPic = path + @"\" + Path.GetFileNameWithoutExtension(path)+ ".jpg";
                fPicTbn = path + @"\" + Path.GetFileNameWithoutExtension(path) + ".tbn";
              }
              else
              {
                fPic = Path.ChangeExtension(file, ".jpg");
                fPicTbn = Path.ChangeExtension(file, ".tbn");
              }
                
              if (File.Exists(fPic))
              {
                strThumb = fPic;
              }
              else if (File.Exists(fPicTbn))
              {
                strThumb = fPicTbn;
              }
              else
              {
                continue;
              }
            }

            pItem.ThumbnailImage = strThumb;
            pItem.IconImageBig = strThumb;
            pItem.IconImage = strThumb;

            strThumb = Util.Utils.ConvertToLargeCoverArt(strThumb);
            if (Util.Utils.FileExistsInCache(strThumb))
            {
              pItem.ThumbnailImage = strThumb;
            }
          } // <-- file == empty
        } // of for (int x = 0; x < items.Count; ++x)
      }
      catch (Exception){}
    }