Exemplo n.º 1
0
    private void SetMovieDetails(ref IMDBMovie details, int iRow, SQLiteResultSet results)
    {
      if (details == null || iRow < 0 || results == null)
      {
        return;
      }

      double rating = 0;
      Double.TryParse(DatabaseUtility.Get(results, iRow, "movieinfo.fRating"), out rating);
      details.Rating = (float)rating;

      if (details.Rating > 10.0f)
      {
        details.Rating /= 10.0f;
      }

      details.Director = DatabaseUtility.Get(results, iRow, "movieinfo.strDirector").Replace("''", "'");

      // Add directorID
      try
      {
        details.DirectorID = Int32.Parse(DatabaseUtility.Get(results, iRow, "movieinfo.idDirector"));
      }
      catch (Exception)
      {
        details.DirectorID = -1;
      }
      
      details.WritingCredits = DatabaseUtility.Get(results, iRow, "movieinfo.strCredits").Replace("''", "'");
      details.TagLine = DatabaseUtility.Get(results, iRow, "movieinfo.strTagLine").Replace("''", "'");
      details.PlotOutline = DatabaseUtility.Get(results, iRow, "movieinfo.strPlotOutline").Replace("''", "'");
      details.Plot = DatabaseUtility.Get(results, iRow, "movieinfo.strPlot").Replace("''", "'");
      // Added user review
      details.UserReview = DatabaseUtility.Get(results, iRow, "movieinfo.strUserReview").Replace("''", "'");
      details.Votes = DatabaseUtility.Get(results, iRow, "movieinfo.strVotes");
      details.Cast = DatabaseUtility.Get(results, iRow, "movieinfo.strCast").Replace("''", "'");
      details.Year = Int32.Parse(DatabaseUtility.Get(results, iRow, "movieinfo.iYear"));
      details.Genre = DatabaseUtility.Get(results, iRow, "movieinfo.strGenre").Trim();
      details.ThumbURL = DatabaseUtility.Get(results, iRow, "movieinfo.strPictureURL");
      // Fanart
      details.FanartURL = DatabaseUtility.Get(results, iRow, "movieinfo.strFanartURL");
      // Date Added
      details.DateAdded = DatabaseUtility.Get(results, iRow, "movieinfo.dateAdded");
      // Date Watched
      details.DateWatched = DatabaseUtility.Get(results, iRow, "movieinfo.dateWatched");
      details.Title = DatabaseUtility.Get(results, iRow, "movieinfo.strTitle").Replace("''", "'");
      details.Path = DatabaseUtility.Get(results, iRow, "path.strPath");
      details.DVDLabel = DatabaseUtility.Get(results, iRow, "movie.discid");
      details.IMDBNumber = DatabaseUtility.Get(results, iRow, "movieinfo.IMDBID");
      Int32 lMovieId = Int32.Parse(DatabaseUtility.Get(results, iRow, "movieinfo.idMovie"));
      details.SearchString = String.Format("{0}", details.Title);
      details.CDLabel = DatabaseUtility.Get(results, iRow, "path.cdlabel");
      details.MPARating = DatabaseUtility.Get(results, iRow, "movieinfo.mpaa");
      int runtime = 0;
      Int32.TryParse(DatabaseUtility.Get(results, iRow, "movieinfo.runtime"), out runtime);
      details.RunTime = runtime;
      int watched = 0;
      Int32.TryParse(DatabaseUtility.Get(results, iRow, "movieinfo.iswatched"), out watched);
      details.Watched = watched;
      details.ID = lMovieId;
      details.Studios = DatabaseUtility.Get(results, iRow, "movieinfo.studios");
      details.Country = DatabaseUtility.Get(results, iRow, "movieinfo.country");
      details.Language = DatabaseUtility.Get(results, iRow, "movieinfo.language");
      details.LastUpdate = DatabaseUtility.Get(results, iRow, "movieinfo.lastupdate");
      details.SortTitle = DatabaseUtility.Get(results, iRow, "movieinfo.strSortTitle").Replace("''", "'");

      if (string.IsNullOrEmpty(details.Path) && details.ID > 0)
      {
        string strSQL = String.Format(
          "SELECT path.strPath FROM movie,path WHERE path.idpath=movie.idpath AND movie.idMovie = {0}", details.ID);
        results = m_db.Execute(strSQL);
        details.Path = DatabaseUtility.Get(results, 0, "path.strPath");
      }

      if (details.ID > 0)
      {
        int percent = 0;
        int watchedCount = 0;
        GetMovieWatchedStatus(details.ID, out percent, out watchedCount);
        details.WatchedPercent = percent;
        details.WatchedCount = watchedCount;

        string movieFilename = string.Empty;
        ArrayList files = new ArrayList();
        GetFilesForMovie(details.ID, ref files);

        int duration = GetMovieDuration(details.ID);
        details.Duration = duration;

        if (files.Count > 0)
        {
          movieFilename = (string) files[0];
        }

        details.VideoFileName = movieFilename;
        details.VideoFilePath = details.Path;

        VideoFilesMediaInfo mInfo = new VideoFilesMediaInfo();
        GetVideoFilesMediaInfo(movieFilename, ref mInfo, false);
        details.MediaInfo = mInfo;
      }

    }
Exemplo n.º 2
0
    public void SetMediaInfoProperties(string file, bool refresh)
    {
      try 
      {
        VideoFilesMediaInfo mInfo = new VideoFilesMediaInfo();

        VideoDatabase.GetVideoFilesMediaInfo(file, ref mInfo, refresh);

        string hasSubtitles = "false";

        if (mInfo.HasSubtitles)
        {
          hasSubtitles = "true";
        }

        GUIPropertyManager.SetProperty("#VideoCodec", Util.Utils.MakeFileName(mInfo.VideoCodec));
        GUIPropertyManager.SetProperty("#VideoResolution", mInfo.VideoResolution);
        GUIPropertyManager.SetProperty("#AudioCodec", Util.Utils.MakeFileName(mInfo.AudioCodec));
        GUIPropertyManager.SetProperty("#AudioChannels", mInfo.AudioChannels);
        GUIPropertyManager.SetProperty("#HasSubtitles", hasSubtitles);
        GUIPropertyManager.SetProperty("#AspectRatio", mInfo.AspectRatio);
      }
      catch (Exception){}
    }
Exemplo n.º 3
0
 public static void GetVideoFilesMediaInfo(string strFilenameAndPath, ref VideoFilesMediaInfo mediaInfo, bool refresh)
 {
   _database.GetVideoFilesMediaInfo(strFilenameAndPath, ref mediaInfo, refresh);
 }
Exemplo n.º 4
0
    public void GetVideoFilesMediaInfo(string strFilenameAndPath, ref VideoFilesMediaInfo mediaInfo, bool refresh)
    {
      try
      {
        if (strFilenameAndPath == String.Empty || !Util.Utils.IsVideo(strFilenameAndPath))
          return;

        if (strFilenameAndPath.IndexOf("remote:") >= 0 || strFilenameAndPath.IndexOf("http:") >= 0)
          return;

        int fileID = GetFileId(strFilenameAndPath);

        if (fileID < 1)
        {
          return;
        }

        // Get media info from database
        string strSQL = String.Format("SELECT * FROM filesmediainfo WHERE idFile={0}", fileID);
        SQLiteResultSet results = m_db.Execute(strSQL);

        // Set mInfo for files already in db but not scanned before
        if (results.Rows.Count > 0 && refresh) // Only refresh from context menu "Refresh media info" from shares view
        {
          try
          {
            CheckMediaInfo(string.Empty, strFilenameAndPath, -1, fileID, refresh);
            results = m_db.Execute(strSQL);
          }
          catch (Exception) { }
        }

        mediaInfo.VideoCodec = DatabaseUtility.Get(results, 0, "videoCodec");
        mediaInfo.VideoResolution = DatabaseUtility.Get(results, 0, "videoResolution");
        mediaInfo.AspectRatio = DatabaseUtility.Get(results, 0, "aspectRatio");

        int hasSubtitles;
        int.TryParse(DatabaseUtility.Get(results, 0, "hasSubtitles"), out hasSubtitles);

        if (hasSubtitles != 0)
        {
          mediaInfo.HasSubtitles = true;
        }
        else
        {
          mediaInfo.HasSubtitles = false;
        }

        mediaInfo.AudioCodec = DatabaseUtility.Get(results, 0, "audioCodec");
        mediaInfo.AudioChannels = DatabaseUtility.Get(results, 0, "audioChannels");
        mediaInfo.Duration = GetVideoDuration(fileID);
      }
      catch (ThreadAbortException)
      {
        // Will be logged in thread main code
      }
      catch (Exception ex)
      {
        Log.Error("videodatabase mediainfo exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
        Open();
      }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Total video duration in seconds (single or multiple -> stacked file(s))
    /// Also sets duration into videodatabase (movie table) -> full lenght with stacked parts
    /// Parameter refresh force duration update even if data is in the videodatabase
    /// </summary>
    /// <param name="files"></param>
    /// <param name="refresh"></param>
    /// <returns></returns>
    public static int MovieDuration(ArrayList files, bool refresh)
    {
      TotalMovieDuration = 0;

      if (files == null || files.Count == 0)
      {
        return TotalMovieDuration;
      }

      try
      {
        foreach (string file in files)
        {
          int fileID = VideoDatabase.GetFileId(file);
          int tempDuration = VideoDatabase.GetVideoDuration(fileID);

          if (tempDuration > 0 && !refresh)
          {
            TotalMovieDuration += tempDuration;
          }
          else
          {
            VideoFilesMediaInfo mInfo = new VideoFilesMediaInfo();

            if (fileID > -1)
            {
              // Set/update video file duration and media info
              VideoDatabase.GetVideoFilesMediaInfo(file, ref mInfo, refresh);
              TotalMovieDuration += (int) mInfo.Duration;
            }
          }
        }
        // Set movie duration
        VideoDatabase.SetMovieDuration(VideoDatabase.GetMovieId(files[0].ToString()), TotalMovieDuration);
      }
      catch (Exception ex)
      {
        Log.Error("GUIVideoFiles: Movie duration exception: {0}", ex.Message);
      }

      return TotalMovieDuration;
    }
Exemplo n.º 6
0
 public static void GetVideoFilesMediaInfo(string strFilenameAndPath, ref VideoFilesMediaInfo mediaInfo, bool refresh)
 {
     _database.GetVideoFilesMediaInfo(strFilenameAndPath, ref mediaInfo, refresh);
 }
Exemplo n.º 7
0
    /// <summary>
    /// Use only in share view
    /// </summary>
    /// <param name="item"></param>
    public static void SetMovieData(GUIListItem item)
    {
      IMDBMovie info = new IMDBMovie();

      if (item == null)
      {
        return;
      }
      
      try
      {
        string path = string.Empty;
        string fileName = string.Empty;

        if (Util.Utils.IsVideo(item.Path))
        {
          Util.Utils.Split(item.Path, out path, out fileName);
        }
        else
        {
          path = item.Path;
        }

        if (item.Path != ".." && System.IO.File.Exists(item.Path + @"\VIDEO_TS\VIDEO_TS.IFO"))
        {
          fileName = item.Path + @"\VIDEO_TS\VIDEO_TS.IFO";
        }
        else if (item.Path != ".." && System.IO.File.Exists(item.Path + @"\BDMV\index.bdmv"))
        {
          fileName = item.Path + @"\BDMV\index.bdmv";
        }
        else
        {
          fileName = item.Path;
        }

        // Set
        VideoFilesMediaInfo mInfo = new VideoFilesMediaInfo();

        if (path == ".." || string.IsNullOrEmpty(path) || (!Directory.Exists(path) && !Util.Utils.IsVideo(fileName)))
        {
          info.MediaInfo = mInfo;
          item.AlbumInfoTag = info;
          return;
        }

        if (Directory.Exists(path) && !Util.Utils.IsVideo(fileName))
        {
          int rndMovieId = -1;

          VirtualDirectory vDir = new VirtualDirectory();
          string pin = string.Empty;
          vDir.LoadSettings("movies");

          if (!vDir.IsProtectedShare(path, out pin))
          {
            ArrayList mList = new ArrayList();
            VideoDatabase.GetRandomMoviesByPath(path, ref mList, 1);

            if (mList.Count > 0)
            {
              IMDBMovie movieDetails = (IMDBMovie)mList[0];
              mList.Clear();
              rndMovieId = movieDetails.ID;
              if (Util.Utils.IsFolderDedicatedMovieFolder(path))
              {
                VideoDatabase.GetMovieInfoById(rndMovieId,ref info);
                int percent = 0;
                int watchedCount = 0;
                VideoDatabase.GetmovieWatchedStatus(rndMovieId, out percent, out watchedCount);
                info.WatchedPercent = percent;
                info.WatchedCount = watchedCount;
                ArrayList fList = new ArrayList();
                VideoDatabase.GetFilesForMovie(rndMovieId,ref fList);
                if (fList.Count > 0)
                {
                  VideoDatabase.GetVideoFilesMediaInfo((string)fList[0], ref mInfo, false);
                  info.VideoFileName = (string)fList[0];
                }
              }
            }
            else
            {
              // User fanart (only for videos which do not have movie info in db -> not scanned)
              try
              {
                GetUserFanart(item, ref info);
              }
              catch (Exception ex)
              {
                Log.Error("IMDBMovie Set user fanart file property error: {0}", ex.Message);
              }
            }
          }

          info.ID = rndMovieId;
          info.MediaInfo = mInfo;
          item.AlbumInfoTag = info;
          return;
        }

        try
        {
          VideoDatabase.GetMovieInfo(fileName, ref info);

          // Get recording/nfo xml
          if (info.IsEmpty)
          {
            FetchMatroskaInfo(fileName, false, ref info);

            if (info.IsEmpty)
            {
              FetchMovieNfo(path, fileName, ref info);
            }
          }

          VideoDatabase.GetVideoFilesMediaInfo(fileName, ref mInfo, false);
          info.VideoFileName = fileName;

          if (string.IsNullOrEmpty(info.VideoFilePath) || info.VideoFilePath == Strings.Unknown)
          {
            string tmpFile = string.Empty;
            Util.Utils.Split(fileName, out path, out tmpFile);
            info.VideoFilePath = path;
          }

          info.Path = path;
          info.MediaInfo = mInfo;

          if (info.ID > 0)
          {
            info.Duration = VideoDatabase.GetMovieDuration(info.ID);
          }
          else
          {
            ArrayList files = new ArrayList();
            VideoDatabase.GetFilesForMovie(VideoDatabase.GetMovieId(info.VideoFileName), ref files);

            foreach (string file in files)
            {
              info.Duration += VideoDatabase.GetVideoDuration(VideoDatabase.GetFileId(file));
            }
          }

          int percent = 0;
          int watchedCount = 0;
          VideoDatabase.GetmovieWatchedStatus(VideoDatabase.GetMovieId(fileName), out percent, out watchedCount);
          info.WatchedPercent = percent;
          info.WatchedCount = watchedCount;

          // User fanart (only for videos which do not have movie info in db -> not scanned)
          try
          {
            if (info.ID < 1)
            {
              GetUserFanart(item, ref info);
            }
          }
          catch (ThreadAbortException) 
          {
            Log.Debug("IMDBMovie.ThreadAbortException SetMovieData (GetMovieInfo) error.");
          }
          catch (Exception ex)
          {
            Log.Error("IMDBMovie Set user fanart file property error: {0}", ex.Message);
          }

          item.AlbumInfoTag = info;
        }
        catch (ThreadAbortException) 
        {
          Log.Debug("IMDBMovie.ThreadAbortException SetMovieData (GetMovieInfo) error.");
        }
        catch (Exception ex)
        {
          Log.Error("IMDBMovie SetMovieData (GetMovieInfo) error: {0}", ex.Message);
          item.AlbumInfoTag = info;
        }
      }
      catch (ThreadAbortException)
      {
        Log.Debug("IMDBMovie.ThreadAbortException SetMovieData error.");
      }
      catch (Exception ex)
      {
        Log.Error("IMDBMovie SetMovieData error: {0}", ex.Message);
        item.AlbumInfoTag = info;
      }
    }
    private void GetVideoFilesMediaInfo(int movieId, ref VideoFilesMediaInfo mediaInfo)
    {
      try
      {
        if (movieId < 1)
        {
          return;
        }

        int fileID = GetFileId(movieId);

        if (fileID < 1 )
        {
          return;
        }

        // Get media info from database
        string strSQL = String.Format("SELECT * FROM filesmediainfo WHERE idFile={0}", fileID);
        SQLiteResultSet results = m_db.Execute(strSQL);

        mediaInfo.VideoCodec = DatabaseUtility.Get(results, 0, "videoCodec");
        mediaInfo.VideoResolution = DatabaseUtility.Get(results, 0, "videoResolution");
        mediaInfo.AspectRatio = DatabaseUtility.Get(results, 0, "aspectRatio");

        int hasSubtitles;
        int.TryParse(DatabaseUtility.Get(results, 0, "hasSubtitles"), out hasSubtitles);

        if (hasSubtitles != 0)
        {
          mediaInfo.HasSubtitles = true;
        }
        else
        {
          mediaInfo.HasSubtitles = false;
        }

        mediaInfo.AudioCodec = DatabaseUtility.Get(results, 0, "audioCodec");
        mediaInfo.AudioChannels = DatabaseUtility.Get(results, 0, "audioChannels");
        mediaInfo.Duration = GetVideoDuration(fileID);
      }
      catch (ThreadAbortException)
      {
        // Will be logged in thread main code
      }
      catch (Exception ex)
      {
        Log.Error("videodatabase mediainfo exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
        Open();
      }
    }
Exemplo n.º 9
0
    /// <summary>
    /// Use only in share view
    /// </summary>
    /// <param name="item"></param>
    public static void SetMovieData(GUIListItem item)
    {
      IMDBMovie info = new IMDBMovie();

      if (item == null)
      {
        return;
      }
      
      try
      {
        string path = string.Empty;
        string fileName = string.Empty;

        if (Util.Utils.IsVideo(item.Path))
        {
          Util.Utils.Split(item.Path, out path, out fileName);
        }
        else
        {
          path = item.Path;
        }

        if (item.Path != ".." && System.IO.File.Exists(item.Path + @"\VIDEO_TS\VIDEO_TS.IFO"))
        {
          fileName = item.Path + @"\VIDEO_TS\VIDEO_TS.IFO";
        }
        else if (item.Path != ".." && System.IO.File.Exists(item.Path + @"\BDMV\index.bdmv"))
        {
          fileName = item.Path + @"\BDMV\index.bdmv";
        }
        else
        {
          fileName = item.Path;
        }

        // Set
        VideoFilesMediaInfo mInfo = new VideoFilesMediaInfo();

        if (path == ".." || string.IsNullOrEmpty(path) || (!Directory.Exists(path) && !Util.Utils.IsVideo(fileName)))
        {
          info.MediaInfo = mInfo;
          item.AlbumInfoTag = info;
          return;
        }

        if (Directory.Exists(path) && !Util.Utils.IsVideo(fileName))
        {
          int rndMovieId = -1;

          VirtualDirectory vDir = new VirtualDirectory();
          int pin = 0;
          vDir.LoadSettings("movies");

          if (!vDir.IsProtectedShare(path, out pin))
          {
            ArrayList mList = new ArrayList();
            VideoDatabase.GetRandomMoviesByPath(path, ref mList, 1);

            if (mList.Count > 0)
            {
              IMDBMovie movieDetails = (IMDBMovie)mList[0];
              mList.Clear();
              rndMovieId = movieDetails.ID;
            }
          }

          info.ID = rndMovieId;
          info.MediaInfo = mInfo;
          item.AlbumInfoTag = info;
          return;
        }

        try
        {
          VideoDatabase.GetMovieInfo(fileName, ref info);

          // Get recording/nfo xml
          if (info.IsEmpty)
          {
            FetchMatroskaInfo(fileName, false, ref info);

            if (info.IsEmpty)
            {
              FetchMovieNfo(path, fileName, ref info);
            }
          }

          VideoDatabase.GetVideoFilesMediaInfo(fileName, ref mInfo, false);
          info.VideoFileName = fileName;

          if (string.IsNullOrEmpty(info.VideoFilePath) || info.VideoFilePath == Strings.Unknown)
          {
            string tmpFile = string.Empty;
            Util.Utils.Split(fileName, out path, out tmpFile);
            info.VideoFilePath = path;
          }

          info.Path = path;
          info.MediaInfo = mInfo;
          info.Duration = VideoDatabase.GetMovieDuration(info.ID);
          int percent = 0;
          int watchedCount = 0;
          VideoDatabase.GetmovieWatchedStatus(VideoDatabase.GetMovieId(fileName), out percent, out watchedCount);
          info.WatchedPercent = percent;
          info.WatchedCount = watchedCount;
          item.AlbumInfoTag = info;
        }
        catch (Exception ex)
        {
          Log.Error("IMDBMovie SetMovieData (GetMovieInfo) error: {0}", ex.Message);
          item.AlbumInfoTag = info;
        }
      }
      catch (Exception ex)
      {
        Log.Error("IMDBMovie SetMovieData error: {0}", ex.Message);
        item.AlbumInfoTag = info;
      }
    }