Repository: xbmc/xbmc
File: xbmc/video/VideoInfoScanner.cpp (C++)

Code before:
using KODI::MESSAGING::HELPERS::DialogResponse;
using KODI::UTILITY::CDigest;

namespace
{
void ProcessEpisodeRange(int first,
                         int last,
                         VIDEO::EPISODE& episode,
                         VIDEO::EPISODELIST& episodeList,
                         const std::string& regex)
{
  if (first <= last)
  {
    for (int e = first; e <= last; ++e)
    {
      episode.iEpisode = e;
      CLog::LogF(LOGDEBUG, "VideoInfoScanner: Adding multipart episode {} [{}]", episode.iEpisode,
                 regex);
      episodeList.push_back(episode);
    }
  }
  else
  {
    // SxxEaa-SxxEbb or Eaa-Ebb is backwards - bb<aa
    CLog::LogF(LOGDEBUG, "VideoInfoScanner: Removing season {}, episode {} as range backwards",
               episode.iSeason, episode.iEpisode);
    episodeList.pop_back();
  }
}
} // namespace

namespace KODI::VIDEO
{

CVideoInfoScanner::CVideoInfoScanner()
  : m_advancedSettings(CServiceBroker::GetSettingsComponent()->GetAdvancedSettings())
{
  m_bStop = false;
  m_scanAll = false;

  const auto settings = CServiceBroker::GetSettingsComponent()->GetSettings();

  m_ignoreVideoVersions = settings->GetBool(CSettings::SETTING_VIDEOLIBRARY_IGNOREVIDEOVERSIONS);
  m_ignoreVideoExtras = settings->GetBool(CSettings::SETTING_VIDEOLIBRARY_IGNOREVIDEOEXTRAS);
}

CVideoInfoScanner::~CVideoInfoScanner()
{
  // Clear cache for all used scrapers
  for (auto& [_, scraper] : m_scraperCache)
    scraper->ClearCache();

Review comment (bug):
More helpful log:
```suggestion
    CLog::LogF(LOGDEBUG, "VideoInfoScanner: Removing season {}, episode {} as range {}-{} is backwards",
               episode.iSeason, episode.iEpisode, first, last);
```

Code after:
using KODI::MESSAGING::HELPERS::DialogResponse;
using KODI::UTILITY::CDigest;

namespace
{
void ProcessEpisodeRange(int first,
                         int last,
                         VIDEO::EPISODE& episode,
                         VIDEO::EPISODELIST& episodeList,
                         const std::string& regex)
{
  if (first <= last)
  {
    for (int e = first; e <= last; ++e)
    {
      episode.iEpisode = e;
      CLog::LogF(LOGDEBUG, "VideoInfoScanner: Adding multipart episode {} [{}]", episode.iEpisode,
                 regex);
      episodeList.push_back(episode);
    }
  }
  else if (!episodeList.empty())
  {
    // SxxEaa-SxxEbb or Eaa-Ebb is backwards - bb<aa
    CLog::LogF(LOGDEBUG,
               "VideoInfoScanner: Removing season {}, episode {} as range {}-{} is backwards",
               episode.iSeason, episode.iEpisode, episodeList.back().iEpisode, last);
    episodeList.pop_back();
  }
}
} // namespace

namespace KODI::VIDEO
{

CVideoInfoScanner::CVideoInfoScanner()
  : m_advancedSettings(CServiceBroker::GetSettingsComponent()->GetAdvancedSettings())
{
  m_bStop = false;
  m_scanAll = false;

  const auto settings = CServiceBroker::GetSettingsComponent()->GetSettings();

  m_ignoreVideoVersions = settings->GetBool(CSettings::SETTING_VIDEOLIBRARY_IGNOREVIDEOVERSIONS);
  m_ignoreVideoExtras = settings->GetBool(CSettings::SETTING_VIDEOLIBRARY_IGNOREVIDEOEXTRAS);
}

CVideoInfoScanner::~CVideoInfoScanner()
{
  // Clear cache for all used scrapers
  for (auto& [_, scraper] : m_scraperCache)