Repository: xbmc/xbmc
File: xbmc/utils/URIUtils.cpp (C++)

Code before:
}

std::string URIUtils::GetBlurayFile(const std::string& path)
{
  if (IsBlurayPath(path))
  {
    const CURL url(path);
    const CURL url2(url.GetHostName()); // strip bluray://
    if (url2.IsProtocol("udf"))
      // ISO
      return url2.GetHostName(); // strip udf://
    return AddFileToFolder(url2.Get(), "BDMV", "index.bdmv"); // BDMV
  }
  return std::string{};
}

bool URIUtils::IsOpticalMediaFile(const std::string& file)
{
  const std::string filename{GetFileName(file)};
  return StringUtils::EqualsNoCase(filename, "video_ts.ifo") ||
         (StringUtils::StartsWithNoCase(filename, "vts_") &&
          StringUtils::EndsWithNoCase(filename, "_0.ifo") && filename.length() == 12) ||
         StringUtils::EqualsNoCase(filename, "index.bdmv") ||
         StringUtils::EqualsNoCase(filename, "MovieObject.bdmv") ||
         StringUtils::EqualsNoCase(filename, "INDEX.BDM") ||
         StringUtils::EqualsNoCase(filename, "MOVIEOBJ.BDM");
}

std::string URIUtils::GetBlurayRootPath(const std::string& path)
{
  return AddFileToFolder(GetBlurayPath(path), "root");
}

std::string URIUtils::GetBlurayTitlesPath(const std::string& path)
{
  return AddFileToFolder(GetBlurayPath(path), "root", "titles");
}

std::string URIUtils::GetBlurayEpisodePath(const std::string& path, int season, int episode)
{
  return AddFileToFolder(GetBlurayPath(path), "root", "episode", StringUtils::Format("{}", season),
                         StringUtils::Format("{}", episode));
}

std::string URIUtils::GetBlurayAllEpisodesPath(const std::string& path)
{
  return AddFileToFolder(GetBlurayPath(path), "root", "episode", "all");
}

std::string URIUtils::GetBlurayPlaylistPath(const std::string& path)
{

Review comment (suggestion):
I have seen code checking for exactly this four files elsewhere in this PR. Any chance to consolidate that "files to check lists"?

Like:

```c++
  const std::string filename{GetFileName(file)};
  return IsBDFile(filename) ||
         StringUtils::EqualsNoCase(filename, "video_ts.ifo") ||
         (StringUtils::StartsWithNoCase(filename, "vts_") &&
          StringUtils::EndsWithNoCase(filename, "_0.ifo") && filename.length() == 12);

Code after:
}

std::string URIUtils::GetBlurayFile(const std::string& path)
{
  if (IsBlurayPath(path))
  {
    const CURL url(path);
    const CURL url2(url.GetHostName()); // strip bluray://
    if (url2.IsProtocol("udf"))
      // ISO
      return url2.GetHostName(); // strip udf://
    return AddFileToFolder(url2.Get(), "BDMV", "index.bdmv"); // BDMV
  }
  return std::string{};
}

std::string URIUtils::GetBlurayRootPath(const std::string& path)
{
  return AddFileToFolder(GetBlurayPath(path), "root");
}

std::string URIUtils::GetBlurayTitlesPath(const std::string& path)
{
  return AddFileToFolder(GetBlurayPath(path), "root", "titles");
}

std::string URIUtils::GetBlurayEpisodePath(const std::string& path, int season, int episode)
{
  return AddFileToFolder(GetBlurayPath(path), "root", "episode", std::to_string(season),
                         std::to_string(episode));
}

std::string URIUtils::GetBlurayAllEpisodesPath(const std::string& path)
{
  return AddFileToFolder(GetBlurayPath(path), "root", "episode", "all");
}

std::string URIUtils::GetBlurayPlaylistPath(const std::string& path)
{
  return AddFileToFolder(GetBlurayPath(path), "BDMV", "PLAYLIST", "");
}

std::string URIUtils::GetBlurayPath(const std::string& path)
{
  if (IsBlurayPath(path))
  {
    // Already bluray:// path
    CURL url(path);
    url.SetFileName("");
    return url.Get();
  }