Repository: xbmc/xbmc
File: xbmc/addons/Scraper.cpp (C++)

Code before:

template<>
bool DetailsFromFileItem<CVideoInfoTag>(const CFileItem& item, CVideoInfoTag& tag)
{
  if (item.HasVideoInfoTag())
  {
    tag = *item.GetVideoInfoTag();
    return true;
  }
  return false;
}

template<class T>
static bool PythonDetails(const std::string& ID,
                          const std::string& key,
                          const std::string& url,
                          const std::string& action,
                          const std::string& pathSettings,
                          const std::string& identifierType,
                          const std::string& identifier,
                          T& result)
{
  std::stringstream str;
  str << "plugin://" << ID << "?action=" << action << "&" << key << "=" << CURL::Encode(url);
  str << "&pathSettings=" << CURL::Encode(pathSettings);
  str << "&identifierType=" << identifierType << "&identifier=" << identifier;

  CFileItem item(url, false);

  if (!XFILE::CPluginDirectory::GetPluginResult(str.str(), item, false))
    return false;

  return DetailsFromFileItem(item, result);
}

template<class T>
static bool PythonDetails(const std::string& ID,
                          const std::string& key,
                          const std::string& url,
                          const std::string& action,
                          const std::string& pathSettings,
                          T& result)
{
  const std::string identifier;
  const std::string identifierType;
  return PythonDetails(ID, key, url, action, pathSettings, identifierType, identifier, result);
}

// fetch list of matching movies sorted by relevance (may be empty);
// throws CScraperError on error; first called with fFirst set, then unset if first try fails
std::vector<CScraperUrl> CScraper::FindMovie(XFILE::CCurlFile &fcurl,

Review comment (suggestion):
Pass to scrapers as the JSON structure with the name `uniqueIDs`. We can expand on that in the future.

Code after:
}

template<>
bool DetailsFromFileItem<CVideoInfoTag>(const CFileItem& item, CVideoInfoTag& tag)
{
  if (item.HasVideoInfoTag())
  {
    tag = *item.GetVideoInfoTag();
    return true;
  }
  return false;
}

template<class T>
static bool PythonDetails(const std::string& ID,
                          const std::string& key,
                          const std::string& url,
                          const std::string& action,
                          const std::string& pathSettings,
                          const std::unordered_map<std::string, std::string>& uniqueIDs,
                          T& result)
{
  CVariant ids;
  for (const auto& [identifierType, identifier] : uniqueIDs)
    ids[identifierType] = identifier;
  std::string uids;
  CJSONVariantWriter::Write(ids, uids, true);
  std::stringstream str;
  str << "plugin://" << ID << "?action=" << action << "&" << key << "=" << CURL::Encode(url);
  str << "&pathSettings=" << CURL::Encode(pathSettings);
  if (!uniqueIDs.empty())
    str << "&uniqueIDs=" << CURL::Encode(uids);

  CFileItem item(url, false);

  if (!XFILE::CPluginDirectory::GetPluginResult(str.str(), item, false))
    return false;

  return DetailsFromFileItem(item, result);
}

template<class T>
static bool PythonDetails(const std::string& ID,
                          const std::string& key,
                          const std::string& url,
                          const std::string& action,
                          const std::string& pathSettings,
                          T& result)
{
  const std::unordered_map<std::string, std::string> ids;
  return PythonDetails(ID, key, url, action, pathSettings, ids, result);