コード例 #1
0
void CPVREpgInfoTag::Update(const CPVREpgInfoTag &tag)
{
  SetBroadcastId(tag.BroadcastId());
  SetTitle(tag.Title());
  SetPlotOutline(tag.PlotOutline());
  SetPlot(tag.Plot());
  SetStart(tag.Start());
  SetEnd(tag.End());
  SetGenre(tag.GenreType(), tag.GenreSubType(), tag.Genre());
  SetFirstAired(tag.FirstAired());
  SetParentalRating(tag.ParentalRating());
  SetStarRating(tag.StarRating());
  SetNotify(tag.Notify());
  SetEpisodeNum(tag.EpisodeNum());
  SetEpisodePart(tag.EpisodePart());
  SetEpisodeName(tag.EpisodeName());
}
コード例 #2
0
bool CPVRDatabase::UpdateEpgEntry(const CPVREpgInfoTag &tag, bool bSingleUpdate /* = true */, bool bLastUpdate /* = false */)
{
  int bReturn = false;

  /* invalid tag */
  if (tag.UniqueBroadcastID() <= 0)
  {
    CLog::Log(LOGERROR, "PVRDB - %s - invalid EPG tag", __FUNCTION__);
    return bReturn;
  }

  int iBroadcastId = tag.BroadcastId();
  if (iBroadcastId)
  {
    CStdString strWhereClause = FormatSQL("(BroadcastUid = '%u' OR StartTime = '%s') AND ChannelId = '%u'",
        tag.UniqueBroadcastID(), tag.Start().GetAsDBDateTime().c_str(), tag.ChannelTag()->ChannelID());
    CStdString strValue = GetSingleValue("EpgData", "BroadcastId", strWhereClause);

    if (!strValue.IsEmpty())
      iBroadcastId = atoi(strValue);
  }

  CStdString strQuery;

  if (iBroadcastId < 0)
  {
    strQuery = FormatSQL("INSERT INTO EpgData (ChannelId, StartTime, "
        "EndTime, Title, PlotOutline, Plot, GenreType, GenreSubType, Genre, "
        "FirstAired, ParentalRating, StarRating, Notify, SeriesId, "
        "EpisodeId, EpisodePart, EpisodeName, BroadcastUid) "
        "VALUES (%i, '%s', '%s', '%s', '%s', '%s', %i, %i, '%s', '%s', %i, %i, %i, '%s', '%s', '%s', '%s', %i)\n",
        tag.ChannelTag()->ChannelID(), tag.Start().GetAsDBDateTime().c_str(), tag.End().GetAsDBDateTime().c_str(),
        tag.Title().c_str(), tag.PlotOutline().c_str(), tag.Plot().c_str(), tag.GenreType(), tag.GenreSubType(), tag.Genre(),
        tag.FirstAired().GetAsDBDateTime().c_str(), tag.ParentalRating(), tag.StarRating(), tag.Notify(),
        tag.SeriesNum().c_str(), tag.EpisodeNum().c_str(), tag.EpisodePart().c_str(), tag.EpisodeName().c_str(),
        tag.UniqueBroadcastID());
  }
  else
  {
    strQuery = FormatSQL("REPLACE INTO EpgData (ChannelId, StartTime, "
        "EndTime, Title, PlotOutline, Plot, GenreType, GenreSubType, Genre, "
        "FirstAired, ParentalRating, StarRating, Notify, SeriesId, "
        "EpisodeId, EpisodePart, EpisodeName, BroadcastUid, BroadcastId) "
        "VALUES (%i, '%s', '%s', '%s', '%s', '%s', %i, %i, '%s', '%s', %i, %i, %i, '%s', '%s', '%s', '%s', %i, %i)\n",
        tag.ChannelTag()->ChannelID(), tag.Start().GetAsDBDateTime().c_str(), tag.End().GetAsDBDateTime().c_str(),
        tag.Title().c_str(), tag.PlotOutline().c_str(), tag.Plot().c_str(), tag.GenreType(), tag.GenreSubType(), tag.Genre(),
        tag.FirstAired().GetAsDBDateTime().c_str(), tag.ParentalRating(), tag.StarRating(), tag.Notify(),
        tag.SeriesNum().c_str(), tag.EpisodeNum().c_str(), tag.EpisodePart().c_str(), tag.EpisodeName().c_str(),
        tag.UniqueBroadcastID(), iBroadcastId);
  }

  if (bSingleUpdate)
  {
    bReturn = ExecuteQuery(strQuery);
  }
  else
  {
    bReturn = QueueInsertQuery(strQuery);

    if (bLastUpdate)
      CommitInsertQueries();
  }

  if ((bSingleUpdate || bLastUpdate) && GetEpgDataEnd(tag.ChannelTag()->ChannelID()) > tag.End())
    EraseEpgForChannel(*tag.ChannelTag(), NULL, tag.End());

  return bReturn;
}