public void GetVideoFiles(string path, ref ArrayList availableFiles)
    {
      //
      // Count the files in the current directory
      //
      try
      {
        VirtualDirectory dir = new VirtualDirectory();
        dir.SetExtensions(Util.Utils.VideoExtensions);
        ArrayList imagePath = new ArrayList();
        
        // Thumbs creation spam no1 causing this call
        //
        // Temporary disable thumbcreation
        //
        using (Settings xmlReaderWriter = new MPSettings())
        {
          _currentCreateVideoThumbs = xmlReaderWriter.GetValueAsBool("thumbnails", "tvrecordedondemand", true);
          xmlReaderWriter.SetValueAsBool("thumbnails", "tvrecordedondemand", false);
        }

        List<GUIListItem> items = dir.GetDirectoryUnProtectedExt(path, true);
        
        foreach (GUIListItem item in items)
        {
          if (item.IsFolder)
          {
            if (item.Label != "..")
            {
              if (item.Path.ToUpperInvariant().IndexOf(@"\VIDEO_TS") >= 0)
              {
                string strFile = String.Format(@"{0}\VIDEO_TS.IFO", item.Path);
                availableFiles.Add(strFile);
              }
              else if (item.Path.ToUpperInvariant().IndexOf(@"\BDMV") >= 0)
              {
                string strFile = String.Format(@"{0}\index.bdmv", item.Path);
                availableFiles.Add(strFile);
              }
              else
              {
                GetVideoFiles(item.Path, ref availableFiles);
              }
            }
          }
          else
          {
            bool skipDuplicate = false;

            if (VirtualDirectory.IsImageFile(Path.GetExtension(item.Path)))
            {
              string filePath = Path.GetDirectoryName(item.Path) + @"\" + Path.GetFileNameWithoutExtension(item.Path);

              if (!imagePath.Contains(filePath))
              {
                imagePath.Add(filePath);
              }
              else
              {
                skipDuplicate = true;
              }
            }
            if (!skipDuplicate)
            {
              string extension = Path.GetExtension(item.Path);

              if (extension != null && extension.ToUpperInvariant() != @".IFO" && extension.ToUpperInvariant() != ".BDMV")
              {
                availableFiles.Add(item.Path);
              }
            }
          }
        }
      }
      catch (Exception e)
      {
        Log.Info("VideoDatabase: Exception counting video files:{0}", e);
      }
      finally
      {
        // Restore thumbcreation setting
        using (Settings xmlwriter = new MPSettings())
        {
          xmlwriter.SetValueAsBool("thumbnails", "tvrecordedondemand", _currentCreateVideoThumbs);
        }
      }
    }
示例#2
0
    private static void AddVideoFiles(string path, ref ArrayList availableFiles)
    {
      //
      // Count the files in the current directory
      //
      bool currentCreateVideoThumbs = false;

      try
      {
        VirtualDirectory dir = new VirtualDirectory();
        dir.SetExtensions(Util.Utils.VideoExtensions);
        // Temporary disable thumbcreation
        using (Profile.Settings xmlreader = new MPSettings())
        {
          currentCreateVideoThumbs = xmlreader.GetValueAsBool("thumbnails", "videoondemand", true);
        }
        using (Profile.Settings xmlwriter = new MPSettings())
        {
          xmlwriter.SetValueAsBool("thumbnails", "videoondemand", false);
        }

        List<GUIListItem> items = dir.GetDirectoryUnProtectedExt(path, true);

        foreach (GUIListItem item in items)
        {
          if (item.IsFolder)
          {
            if (item.Label != "..")
            {
              if (item.Path.ToUpperInvariant().IndexOf("VIDEO_TS") >= 0)
              {
                string strFile = String.Format(@"{0}\VIDEO_TS.IFO", item.Path);
                availableFiles.Add(strFile);
              }
              if (item.Path.ToUpperInvariant().IndexOf("BDMV") >= 0)
              {
                string strFile = String.Format(@"{0}\index.bdmv", item.Path);
                availableFiles.Add(strFile);
              }
              else
              {
                AddVideoFiles(item.Path, ref availableFiles);
              }
            }
          }
          else
          {
            availableFiles.Add(item.Path);
          }
        }
      }
      catch (Exception e)
      {
        Log.Info("Exception counting files:{0}", e);
        // Ignore
      }
      finally
      {
        // Restore thumbcreation setting
        using (Profile.Settings xmlwriter = new MPSettings())
        {
          xmlwriter.SetValueAsBool("thumbnails", "videoondemand", currentCreateVideoThumbs);
        }
      }
    }
示例#3
0
 private void ListFilesForUpdateMediaInfo(GUIListItem item, ref List<GUIListItem> itemlist)
 {
   if (item != null)
   {
     // Process the list of files found in the directory.
     VirtualDirectory virtualDirectory = new VirtualDirectory();
     virtualDirectory.SetExtensions(Util.Utils.VideoExtensions);
     List<GUIListItem> inertItemlist = virtualDirectory.GetDirectoryUnProtectedExt(item.Path, true);
     foreach (GUIListItem subItem in inertItemlist)
     {
       if (!subItem.IsFolder)
       {
         itemlist.Add(subItem);
       }
       else
       {
         if (subItem.Label != "..")
         {
           ListFilesForUpdateMediaInfo(subItem, ref itemlist);
         }
       }
     }
   }
 }
示例#4
0
    public static bool GetInfoFromIMDB(IMDB.IProgress progress, ref IMDBMovie movieDetails, bool isFuzzyMatching,
                                       bool getActors)
    {
      string file;
      string path = movieDetails.Path;
      string filename = movieDetails.File;
      if (path != string.Empty)
      {
        if (path.EndsWith(@"\"))
        {
          path = path.Substring(0, path.Length - 1);
          movieDetails.Path = path;
        }
        if (filename.StartsWith(@"\"))
        {
          filename = filename.Substring(1);
          movieDetails.File = filename;
        }
        file = path + Path.DirectorySeparatorChar + filename;
      }
      else
      {
        file = filename;
      }

      bool addToDB = true;
      int id = movieDetails.ID;
      if (id < 0)
      {
        if (File.Exists(file))
        {
          id = VideoDatabase.AddMovieFile(file);

          VirtualDirectory dir = new VirtualDirectory();
          dir.SetExtensions(Util.Utils.VideoExtensions);
          // Thumb creation spam no2 causing this call
          //
          // Temporary disable thumbcreation
          //
          using (Settings xmlreader = new MPSettings())
          {
            _currentCreateVideoThumbs = xmlreader.GetValueAsBool("thumbnails", "tvrecordedondemand", true);
          }
          using (Settings xmlwriter = new MPSettings())
          {
            xmlwriter.SetValueAsBool("thumbnails", "tvrecordedondemand", false);
          }
          List<GUIListItem> items = dir.GetDirectoryUnProtectedExt(path, true);
          
          foreach (GUIListItem item in items)
          {
            if (item.IsFolder)
            {
              continue;
            }
            if (Util.Utils.ShouldStack(item.Path, file) && item.Path != file)
            {
              string strPath, strFileName;

              DatabaseUtility.Split(item.Path, out strPath, out strFileName);
              DatabaseUtility.RemoveInvalidChars(ref strPath);
              DatabaseUtility.RemoveInvalidChars(ref strFileName);
              int pathId = VideoDatabase.AddPath(strPath);
              VideoDatabase.AddFile(id, pathId, strFileName);
            }
          }
          // Restore thumbcreation setting
          using (Settings xmlwriter = new MPSettings())
          {
            xmlwriter.SetValueAsBool("thumbnails", "tvrecordedondemand", _currentCreateVideoThumbs);
          }

          movieDetails.ID = id;
        }
        else
        {
          Log.Info("File doesn't exists. So no info is stored in db.");
          getActors = false;
          addToDB = false;
        }
      }
      if (RefreshIMDB(progress, ref movieDetails, isFuzzyMatching, getActors, addToDB))
      {
        if (movieDetails != null)
        {
          return true;
        }
      }
      return false;
    }
 private static void CountFiles(string path, ref ArrayList availableFiles)
 {
   //
   // Count the files in the current directory
   //
   try
   {
     VirtualDirectory dir = new VirtualDirectory();
     dir.SetExtensions(Util.Utils.PictureExtensions);
     List<GUIListItem> items = dir.GetDirectoryUnProtectedExt(path, true);
     foreach (GUIListItem item in items)
     {
       if (item.IsFolder)
       {
         if (item.Label != "..")
         {
           CountFiles(item.Path, ref availableFiles);
           CreateThumbsAndAddPictureToDBFolderThread ManualThumbBuilderFolder =
             new CreateThumbsAndAddPictureToDBFolderThread(item.Path);
         }
       }
       else
       {
         availableFiles.Add(item.Path);
       }
     }
   }
   catch (Exception e)
   {
     Log.Info("Exception counting files:{0}", e);
     // Ignore
   }
 }
示例#6
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="path"></param>
    /// <param name="availableFiles"></param>
    private static void CountFiles(string path, ref ArrayList availableFiles)
    {
      //
      // Count the files in the current directory
      //
      try
      {
        VirtualDirectory dir = new VirtualDirectory();
        dir.SetExtensions(Util.Utils.VideoExtensions);
        // Thumbs creation spam no1 causing this call
        //
        // Temporary disable thumbcreation
        //
        using (Settings xmlreader = new MPSettings())
        {
          _currentCreateVideoThumbs = xmlreader.GetValueAsBool("thumbnails", "tvrecordedondemand", true);
        }
        using (Settings xmlwriter = new MPSettings())
        {
          xmlwriter.SetValueAsBool("thumbnails", "tvrecordedondemand", false);
        }

        List<GUIListItem> items = dir.GetDirectoryUnProtectedExt(path, true);
        foreach (GUIListItem item in items)
        {
          if (item.IsFolder)
          {
            if (item.Label != "..")
            {
              if (item.Path.ToLower().IndexOf("video_ts") >= 0)
              {
                string strFile = String.Format(@"{0}\VIDEO_TS.IFO", item.Path);
                availableFiles.Add(strFile);
              }
              else
              {
                CountFiles(item.Path, ref availableFiles);
              }
            }
          }
          else
          {
            availableFiles.Add(item.Path);
          }
        }
      }
      catch (Exception e)
      {
        Log.Info("Exception counting files:{0}", e);
        // Ignore
      }
      finally
      {
        // Restore thumbcreation setting
        using (Settings xmlwriter = new MPSettings())
        {
          xmlwriter.SetValueAsBool("thumbnails", "tvrecordedondemand", _currentCreateVideoThumbs);
        }
      }
    }