Example #1
0
/// This method scans all remote shares and determines the latest 3 movies
/// If bUpdateAllMovies is true then IMDB is queried for each and every movie found
//  otherwise queries are limited to the 3 latest movies.
void CMediaMonitor::Scan(bool bUpdateAllMovies)
{
  MOVIELIST movies;
  GetSharedMovies(g_settings.m_vecMyVideoShares, movies);

  // sort files by creation date
  sort(movies.begin(), movies.end(), CMediaMonitor::SortMoviesByDateAndTime );

  // remove duplicates
  FilterDuplicates(movies);

  // Update movies if necessary
  if (bUpdateAllMovies)
  {
    // query imdb for new info
    for (int iMovie = 0; iMovie < (int)movies.size(); iMovie++)
    {
      UpdateObserver(movies[iMovie], 0, false, false);
      Sleep(50);
    }
  }

  // Select the 3 newest files (remove similar filenames from consideration):
  int iLatestMovie = (int) movies.size() - 1;
  int iOlderMovie = iLatestMovie - RECENT_MOVIES;
  for (int iMovie = iLatestMovie; (iMovie >= 0) && (iMovie > iOlderMovie); iMovie--)
  {
    UpdateObserver(movies[iMovie], iLatestMovie - iMovie, false, true);
  }

  movies.clear();
}