Exemplo n.º 1
0
CPVRRecordingsPath::CPVRRecordingsPath(bool bDeleted, bool bRadio,
                       const std::string &strDirectory, const std::string &strTitle,
                       int iSeason, int iEpisode, int iYear,
                       const std::string &strSubtitle, const std::string &strChannelName,
                       const CDateTime &recordingTime, const std::string &strId)
: m_bValid(true),
  m_bRoot(false),
  m_bActive(!bDeleted),
  m_bRadio(bRadio)
{
  std::string strDirectoryN(TrimSlashes(strDirectory));
  if (!strDirectoryN.empty())
    strDirectoryN = StringUtils::Format("%s/", strDirectoryN.c_str());

  std::string strTitleN(strTitle);
  StringUtils::Replace(strTitleN, '/', ' ');

  std::string strSeasonEpisodeN;
  if ((iSeason > -1 && iEpisode > -1 && (iSeason > 0 || iEpisode > 0)))
    strSeasonEpisodeN = StringUtils::Format("s%02de%02d", iSeason, iEpisode);
  if (!strSeasonEpisodeN.empty())
    strSeasonEpisodeN = StringUtils::Format(" %s", strSeasonEpisodeN.c_str());

  std::string strYearN(iYear > 0 ? StringUtils::Format(" (%i)", iYear) : "");

  std::string strSubtitleN;
  if (!strSubtitle.empty())
  {
    strSubtitleN = StringUtils::Format(" %s", strSubtitle.c_str());
    StringUtils::Replace(strSubtitleN, '/', ' ');
  }

  std::string strChannelNameN;
  if (!strChannelName.empty())
  {
    strChannelNameN = StringUtils::Format(" (%s)", strChannelName.c_str());
    StringUtils::Replace(strChannelNameN, '/', ' ');
  }

  m_directoryPath = StringUtils::Format("%s%s%s%s%s",
                                        strDirectoryN.c_str(), strTitleN.c_str(), strSeasonEpisodeN.c_str(),
                                        strYearN.c_str(), strSubtitleN.c_str());
  m_params = StringUtils::Format(", TV%s, %s, %s.pvr", strChannelNameN.c_str(), recordingTime.GetAsSaveString().c_str(), strId.c_str());
  m_path   = StringUtils::Format("pvr://recordings/%s/%s/%s%s", bRadio ? "radio" : "tv", bDeleted ? "deleted" : "active", m_directoryPath.c_str(), m_params.c_str());
}