Skip to content

Commit

Permalink
videodb: add resumeTimeInSeconds and totalTimeInSeconds to the movie/…
Browse files Browse the repository at this point in the history
…episode/musicvideo view to eliminate extra queries
  • Loading branch information
Montellese committed Jul 6, 2012
1 parent bfafe59 commit 5170759
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
3 changes: 2 additions & 1 deletion xbmc/ThumbLoader.cpp
Expand Up @@ -199,7 +199,8 @@ bool CVideoThumbLoader::LoadItem(CFileItem* pItem)
m_database->Open();

// resume point
if (pItem->HasVideoInfoTag() && pItem->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds == 0)
if (pItem->HasVideoInfoTag() &&
pItem->GetVideoInfoTag()->m_resumePoint.type != CBookmark::RESUME && pItem->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds == 0)
{
if (m_database->GetResumePoint(*pItem->GetVideoInfoTag()))
pItem->SetInvalid();
Expand Down
34 changes: 25 additions & 9 deletions xbmc/video/VideoDatabase.cpp
Expand Up @@ -349,14 +349,18 @@ void CVideoDatabase::CreateViews()
" tvshow.c%02d AS strStudio,"
" tvshow.c%02d AS premiered,"
" tvshow.c%02d AS mpaa,"
" tvshow.c%02d AS strShowPath "
" tvshow.c%02d AS strShowPath, "
" bookmark.timeInSeconds AS resumeTimeInSeconds, "
" bookmark.totalTimeInSeconds AS totalTimeInSeconds "
"FROM episode"
" JOIN files ON"
" files.idFile=episode.idFile"
" JOIN tvshow ON"
" tvshow.idShow=episode.idShow"
" JOIN path ON"
" files.idPath=path.idPath", VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_STUDIOS, VIDEODB_ID_TV_PREMIERED, VIDEODB_ID_TV_MPAA, VIDEODB_ID_TV_BASEPATH);
" files.idPath=path.idPath"
" LEFT JOIN bookmark ON"
" bookmark.idFile=episode.idFile AND bookmark.type=1", VIDEODB_ID_TV_TITLE, VIDEODB_ID_TV_STUDIOS, VIDEODB_ID_TV_PREMIERED, VIDEODB_ID_TV_MPAA, VIDEODB_ID_TV_BASEPATH);
m_pDS->exec(episodeview.c_str());

CLog::Log(LOGINFO, "create tvshowview");
Expand Down Expand Up @@ -388,12 +392,16 @@ void CVideoDatabase::CreateViews()
" path.strPath as strPath,"
" files.playCount as playCount,"
" files.lastPlayed as lastPlayed,"
" files.dateAdded as dateAdded "
" files.dateAdded as dateAdded, "
" bookmark.timeInSeconds AS resumeTimeInSeconds, "
" bookmark.totalTimeInSeconds AS totalTimeInSeconds "
"FROM musicvideo"
" JOIN files ON"
" files.idFile=musicvideo.idFile"
" JOIN path ON"
" path.idPath=files.idPath");
" path.idPath=files.idPath"
" LEFT JOIN bookmark ON"
" bookmark.idFile=musicvideo.idFile AND bookmark.type=1");

CLog::Log(LOGINFO, "create movieview");
m_pDS->exec("DROP VIEW IF EXISTS movieview");
Expand All @@ -403,12 +411,16 @@ void CVideoDatabase::CreateViews()
" path.strPath AS strPath,"
" files.playCount AS playCount,"
" files.lastPlayed AS lastPlayed, "
" files.dateAdded AS dateAdded "
" files.dateAdded AS dateAdded, "
" bookmark.timeInSeconds AS resumeTimeInSeconds, "
" bookmark.totalTimeInSeconds AS totalTimeInSeconds "
"FROM movie"
" JOIN files ON"
" files.idFile=movie.idFile"
" JOIN path ON"
" path.idPath=files.idPath");
" path.idPath=files.idPath"
" LEFT JOIN bookmark ON"
" bookmark.idFile=movie.idFile AND bookmark.type=1");
}

//********************************************************************************************************************************
Expand Down Expand Up @@ -3029,7 +3041,6 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMovie(const dbiplus::sql_record* cons

if (needsCast)
{
GetResumePoint(details);
GetCast("movie", "idMovie", details.m_iDbId, details.m_cast);

castTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis();
Expand Down Expand Up @@ -3131,13 +3142,16 @@ CVideoInfoTag CVideoDatabase::GetDetailsForEpisode(const dbiplus::sql_record* co
details.m_iIdShow = record->at(VIDEODB_DETAILS_EPISODE_TVSHOW_ID).get_asInt();
details.m_strShowPath = record->at(VIDEODB_DETAILS_EPISODE_TVSHOW_PATH).get_asString();

details.m_resumePoint.timeInSeconds = record->at(VIDEODB_DETAILS_EPISODE_RESUME_TIME).get_asInt();
details.m_resumePoint.totalTimeInSeconds = record->at(VIDEODB_DETAILS_EPISODE_TOTAL_TIME).get_asInt();
details.m_resumePoint.type = CBookmark::RESUME;

movieTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis();

GetStreamDetails(details);

if (needsCast)
{
GetResumePoint(details);
GetCast("episode", "idEpisode", details.m_iDbId, details.m_cast);
GetCast("tvshow", "idShow", details.m_iIdShow, details.m_cast);

Expand Down Expand Up @@ -3171,7 +3185,6 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMusicVideo(const dbiplus::sql_record*
movieTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis();

GetStreamDetails(details);
GetResumePoint(details);

details.m_strPictureURL.Parse();
return details;
Expand All @@ -3191,6 +3204,9 @@ void CVideoDatabase::GetCommonDetails(const dbiplus::sql_record* const record, C
details.m_playCount = record->at(VIDEODB_DETAILS_PLAYCOUNT).get_asInt();
details.m_lastPlayed.SetFromDBDateTime(record->at(VIDEODB_DETAILS_LASTPLAYED).get_asString());
details.m_dateAdded.SetFromDBDateTime(record->at(VIDEODB_DETAILS_DATEADDED).get_asString());
details.m_resumePoint.timeInSeconds = record->at(VIDEODB_DETAILS_RESUME_TIME).get_asInt();
details.m_resumePoint.totalTimeInSeconds = record->at(VIDEODB_DETAILS_TOTAL_TIME).get_asInt();
details.m_resumePoint.type = CBookmark::RESUME;
}

void CVideoDatabase::GetCast(const CStdString &table, const CStdString &table_id, int type_id, vector<SActorInfo> &cast)
Expand Down
6 changes: 5 additions & 1 deletion xbmc/video/VideoDatabase.h
Expand Up @@ -73,6 +73,8 @@ namespace VIDEO
#define VIDEODB_DETAILS_PLAYCOUNT VIDEODB_MAX_COLUMNS + 4
#define VIDEODB_DETAILS_LASTPLAYED VIDEODB_MAX_COLUMNS + 5
#define VIDEODB_DETAILS_DATEADDED VIDEODB_MAX_COLUMNS + 6
#define VIDEODB_DETAILS_RESUME_TIME VIDEODB_MAX_COLUMNS + 7
#define VIDEODB_DETAILS_TOTAL_TIME VIDEODB_MAX_COLUMNS + 8

#define VIDEODB_DETAILS_EPISODE_TVSHOW_ID VIDEODB_MAX_COLUMNS + 2
#define VIDEODB_DETAILS_EPISODE_FILE VIDEODB_MAX_COLUMNS + 3
Expand All @@ -85,6 +87,8 @@ namespace VIDEO
#define VIDEODB_DETAILS_EPISODE_TVSHOW_AIRED VIDEODB_MAX_COLUMNS + 10
#define VIDEODB_DETAILS_EPISODE_TVSHOW_MPAA VIDEODB_MAX_COLUMNS + 11
#define VIDEODB_DETAILS_EPISODE_TVSHOW_PATH VIDEODB_MAX_COLUMNS + 12
#define VIDEODB_DETAILS_EPISODE_RESUME_TIME VIDEODB_MAX_COLUMNS + 13
#define VIDEODB_DETAILS_EPISODE_TOTAL_TIME VIDEODB_MAX_COLUMNS + 14

#define VIDEODB_DETAILS_TVSHOW_PATH VIDEODB_MAX_COLUMNS + 1
#define VIDEODB_DETAILS_TVSHOW_DATEADDED VIDEODB_MAX_COLUMNS + 2
Expand Down Expand Up @@ -794,7 +798,7 @@ class CVideoDatabase : public CDatabase
*/
bool LookupByFolders(const CStdString &path, bool shows = false);

virtual int GetMinVersion() const { return 64; };
virtual int GetMinVersion() const { return 65; };
virtual int GetExportVersion() const { return 1; };
const char *GetBaseDBName() const { return "MyVideos"; };

Expand Down

0 comments on commit 5170759

Please sign in to comment.