X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_xbmc;a=blobdiff_plain;f=xbmc%2Fvideo%2FVideoDatabase.cpp;h=f1f767b98b83d52fec44bd3256623bc0741869fa;hp=aa810d93c3c4771a07d67f47e4c5c43e758bffb8;hb=7b90b96f4c5babd995328a34dd52c652a66fd9ae;hpb=45fa6dc78a8aa022e0c7676788eb73345b1e0d8f diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index aa810d9..f1f767b 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -2292,26 +2292,27 @@ int CVideoDatabase::SetDetailsForEpisode(const CStdString& strFilenameAndPath, c SetArtForItem(idEpisode, "episode", artwork); - // query DB for any episodes matching idShow, Season and Episode - CStdString strSQL = PrepareSQL("select files.playCount, files.lastPlayed from episode, files where files.idFile=episode.idFile and episode.c%02d=%i and episode.c%02d=%i AND episode.idShow=%i and episode.idEpisode!=%i and files.playCount > 0",VIDEODB_ID_EPISODE_SEASON, details.m_iSeason, VIDEODB_ID_EPISODE_EPISODE, details.m_iEpisode, idShow, idEpisode); - m_pDS->query(strSQL.c_str()); - - if (!m_pDS->eof()) - { - int playCount = m_pDS->fv("files.playCount").get_asInt(); + if (details.m_iEpisode != -1 && details.m_iSeason != -1) + { // query DB for any episodes matching idShow, Season and Episode + CStdString strSQL = PrepareSQL("select files.playCount, files.lastPlayed from episode, files where files.idFile=episode.idFile and episode.c%02d=%i and episode.c%02d=%i AND episode.idShow=%i and episode.idEpisode!=%i and files.playCount > 0",VIDEODB_ID_EPISODE_SEASON, details.m_iSeason, VIDEODB_ID_EPISODE_EPISODE, details.m_iEpisode, idShow, idEpisode); + m_pDS->query(strSQL.c_str()); - CDateTime lastPlayed; - lastPlayed.SetFromDBDateTime(m_pDS->fv("files.lastPlayed").get_asString()); + if (!m_pDS->eof()) + { + int playCount = m_pDS->fv("files.playCount").get_asInt(); - int idFile = GetFileId(strFilenameAndPath); + CDateTime lastPlayed; + lastPlayed.SetFromDBDateTime(m_pDS->fv("files.lastPlayed").get_asString()); - // update with playCount and lastPlayed - strSQL = PrepareSQL("update files set playCount=%i,lastPlayed='%s' where idFile=%i", playCount, lastPlayed.GetAsDBDateTime().c_str(), idFile); - m_pDS->exec(strSQL.c_str()); - } + int idFile = GetFileId(strFilenameAndPath); - m_pDS->close(); + // update with playCount and lastPlayed + strSQL = PrepareSQL("update files set playCount=%i,lastPlayed='%s' where idFile=%i", playCount, lastPlayed.GetAsDBDateTime().c_str(), idFile); + m_pDS->exec(strSQL.c_str()); + } + m_pDS->close(); + } // and insert the new row CStdString sql = "update episode set " + GetValueString(details, VIDEODB_ID_EPISODE_MIN, VIDEODB_ID_EPISODE_MAX, DbEpisodeOffsets); sql += PrepareSQL(" where idEpisode=%i", idEpisode);