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

Code before:
  auto getScraper = [&](const std::string& scraperID)
  {
    AddonPtr addon;
    if (scraperCache)
    {
      if (auto iter = scraperCache->find(scraperID); iter == scraperCache->end())
      {
        if (CServiceBroker::GetAddonMgr().GetAddon(scraperID, addon,
                                                   ADDON::OnlyEnabled::CHOICE_YES))
        {
          auto scraper = std::dynamic_pointer_cast<CScraper>(addon);
          if (scraper)
            scraperCache->emplace(scraperID, scraper);
          return std::make_pair(true, scraper);
        }
        else
          return std::make_pair(false, ScraperPtr());
      }
      else
        return std::make_pair(true, iter->second);
    }
    else if (CServiceBroker::GetAddonMgr().GetAddon(scraperID, addon,
                                                    ADDON::OnlyEnabled::CHOICE_YES))
    {
      auto scraper = std::dynamic_pointer_cast<CScraper>(addon);
      return std::make_pair(true, scraper);
    }
    else
    {
      return std::make_pair(false, ScraperPtr());
    }
  };

  foundDirectly = false;
  try
  {
    if (strPath.empty() || !m_pDB || !m_pDS)
      return ScraperPtr();

    ScraperPtr scraper;
    std::string strPath2;

    if (URIUtils::IsMultiPath(strPath))
      strPath2 = CMultiPathDirectory::GetFirstPath(strPath);
    else
      strPath2 = strPath;

    std::string strPath1 = URIUtils::GetDirectory(strPath2);
    int idPath = GetPathId(strPath1);

    if (idPath > -1)

Review comment (bug):
reads better this way for me:
```suggestion
auto getScraper = [scraperCache](const std::string& scraperID)
{
  if (scraperCache)
    if (auto iter = scraperCache->find(scraperID); iter != scraperCache->end())
      return std::make_pair(true, iter->second);

  AddonPtr addon;
  const bool found =
      CServiceBroker::GetAddonMgr().GetAddon(scraperID, addon, ADDON::OnlyEnabled::CHOICE_YES);
  auto scraper = found ? std::dynamic_pointer_cast<CScraper>(addon) : nullptr;

  if (scraperCache && found && scraper)
    scraperCache->emplace(scraperID, scraper);

  return std::make_pair(found, scraper);
};
```


Code after:
                                   const std::string& pathSettings)
  {
    if (scraperCache)
    {
      auto key = scraperID + pathSettings;
      if (auto iter = scraperCache->find(key); iter != scraperCache->end())
        return std::make_pair(true, iter->second);
    }

    AddonPtr addon;
    const bool found =
        CServiceBroker::GetAddonMgr().GetAddon(scraperID, addon, ADDON::OnlyEnabled::CHOICE_YES);
    auto scraper = found ? std::dynamic_pointer_cast<CScraper>(addon) : nullptr;

    if (scraper)
    {
      scraper->SetPathSettings(content, pathSettings);
      if (scraperCache)
      {
        auto key = scraperID + pathSettings;
        scraperCache->emplace(std::move(key), scraper);
      }
    }

    return std::make_pair(found, scraper);
  };

  foundDirectly = false;
  try
  {
    if (strPath.empty() || !m_pDB || !m_pDS)
      return ScraperPtr();

    ScraperPtr scraper;
    std::string strPath2;

    if (URIUtils::IsMultiPath(strPath))
      strPath2 = CMultiPathDirectory::GetFirstPath(strPath);
    else
      strPath2 = strPath;

    std::string strPath1 = URIUtils::GetDirectory(strPath2);
    int idPath = GetPathId(strPath1);

    if (idPath > -1)
    {
      std::string strSQL = PrepareSQL(
          "SELECT path.strContent, path.strScraper, path.scanRecursive, path.useFolderNames, "
          "path.strSettings, path.noUpdate, path.exclude, path.allAudio FROM path WHERE idPath=%i",
          idPath);
      m_pDS->query( strSQL );