Skip to content
Browse files

videodb: introduce GetFileInfo() to retrieve basic info for non-libra…

…ry files and use it in LoadVideoInfo()
  • Loading branch information...
1 parent 49b7e5c commit 203e7392b24f54d7fb6ad731f1e8ba964fde495d @Montellese committed Aug 20, 2012
Showing with 39 additions and 0 deletions.
  1. +38 −0 xbmc/video/VideoDatabase.cpp
  2. +1 −0 xbmc/video/VideoDatabase.h
View
38 xbmc/video/VideoDatabase.cpp
@@ -1539,6 +1539,8 @@ bool CVideoDatabase::LoadVideoInfo(const CStdString& strFilenameAndPath, CVideoI
CLog::Log(LOGDEBUG,"%s, got music video info!", __FUNCTION__);
CLog::Log(LOGDEBUG," Title = %s", details.m_strTitle.c_str());
}
+ else if (GetFileInfo(strFilenameAndPath, details))
+ CLog::Log(LOGDEBUG,"%s, got file info!", __FUNCTION__);
return !details.IsEmpty();
}
@@ -1835,6 +1837,42 @@ bool CVideoDatabase::GetSetInfo(int idSet, CVideoInfoTag& details)
return false;
}
+bool CVideoDatabase::GetFileInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idFile /* = -1 */)
+{
+ try
+ {
+ if (idFile < 0)
+ idFile = GetFileId(strFilenameAndPath);
+ if (idFile < 0)
+ return false;
+
+ CStdString sql = PrepareSQL("SELECT * FROM files "
+ "JOIN path ON path.idPath = files.idPath "
+ "JOIN bookmark ON bookmark.idFile = files.idFile AND bookmark.type = %i "
+ "WHERE files.idFile = %i", CBookmark::RESUME, idFile);
+ if (!m_pDS->query(sql.c_str()))
+ return false;
+
+ details.m_iFileId = m_pDS->fv("files.idFile").get_asInt();
+ details.m_strPath = m_pDS->fv("path.strPath").get_asString();
+ CStdString strFileName = m_pDS->fv("files.strFilename").get_asString();
+ ConstructPath(details.m_strFileNameAndPath, details.m_strPath, strFileName);
+ details.m_playCount = m_pDS->fv("files.playCount").get_asInt();
+ details.m_lastPlayed.SetFromDBDateTime(m_pDS->fv("files.lastPlayed").get_asString());
+ details.m_dateAdded.SetFromDBDateTime(m_pDS->fv("files.dateAdded").get_asString());
+ details.m_resumePoint.timeInSeconds = m_pDS->fv("bookmark.timeInSeconds").get_asInt();
+ details.m_resumePoint.totalTimeInSeconds = m_pDS->fv("bookmark.totalTimeInSeconds").get_asInt();
+ details.m_resumePoint.type = CBookmark::RESUME;
+
+ return !details.IsEmpty();
+ }
+ catch (...)
+ {
+ CLog::Log(LOGERROR, "%s (%s) failed", __FUNCTION__, strFilenameAndPath.c_str());
+ }
+ return false;
+}
+
void CVideoDatabase::AddGenreAndDirectorsAndStudios(const CVideoInfoTag& details, vector<int>& vecDirectors, vector<int>& vecGenres, vector<int>& vecStudios)
{
// add all directors
View
1 xbmc/video/VideoDatabase.h
@@ -430,6 +430,7 @@ class CVideoDatabase : public CDatabase
bool GetEpisodeInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idEpisode = -1);
bool GetMusicVideoInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idMVideo=-1);
bool GetSetInfo(int idSet, CVideoInfoTag& details);
+ bool GetFileInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idFile = -1);
int GetPathId(const CStdString& strPath);
int GetTvShowId(const CStdString& strPath);

0 comments on commit 203e739

Please sign in to comment.
Something went wrong with that request. Please try again.