Пример #1
0
void CMediaMonitor::FilterDuplicates(MOVIELIST& movies)
{
  MOVIELISTITERATOR current = movies.begin();
  MOVIELISTITERATOR previous = current;

  while (current != movies.end())
  {
    if (previous != current)
    {
      // ensure at least less than 75% similar compared to the previous selection
      if (parse_Similar( (*current).strFilepath, (*previous).strFilepath, 75))
      {
        // items are similar, find out which one is more likely to be CD1
        long valueA = parse_AggregateValue((*current).strFilepath);
        long valueB = parse_AggregateValue((*previous).strFilepath);

        if (valueA < valueB)
        {
          *previous = *current;
        }

        current = movies.erase(current);
        continue;
      }
    }

    previous = current;
    current++;
  }
}
Пример #2
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();
}