Permalink
Browse files

[runtime] drop m_strRuntime and update the video database to use m_du…

…ration instead
  • Loading branch information...
Jonathan Marshall
Jonathan Marshall committed Nov 2, 2012
1 parent a8a5b31 commit d1e806a0945aa79846f87936a2da6c6890adef47
Showing with 31 additions and 13 deletions.
  1. +23 −0 xbmc/video/VideoDatabase.cpp
  2. +4 −4 xbmc/video/VideoDatabase.h
  3. +4 −8 xbmc/video/VideoInfoTag.cpp
  4. +0 −1 xbmc/video/VideoInfoTag.h
@@ -4258,6 +4258,29 @@ bool CVideoDatabase::UpdateOldVersion(int iVersion)
"DELETE FROM tag WHERE idTag=old.idTag AND idTag NOT IN (SELECT DISTINCT idTag FROM taglinks); "
"END");
}
if (iVersion < 74)
{ // update the runtime columns
vector< pair<string, int> > tables;
tables.push_back(make_pair("movie", VIDEODB_ID_RUNTIME));
tables.push_back(make_pair("episode", VIDEODB_ID_EPISODE_RUNTIME));
tables.push_back(make_pair("mvideo", VIDEODB_ID_MUSICVIDEO_RUNTIME));
for (vector< pair<string, int> >::iterator i = tables.begin(); i != tables.end(); ++i)
{
CStdString sql = PrepareSQL("select id%s,c%02d from %s where c%02d != ''", i->first.c_str(), i->second, (i->first=="mvideo")?"musicvideo":i->first.c_str(), i->second);
m_pDS->query(sql.c_str());
vector< pair<int, int> > videos;
while (!m_pDS->eof())
{
int duration = CVideoInfoTag::GetDurationFromMinuteString(m_pDS->fv(1).get_asString());
if (duration)
videos.push_back(make_pair(m_pDS->fv(0).get_asInt(), duration));
m_pDS->next();
}
m_pDS->close();
for (vector< pair<int, int> >::iterator j = videos.begin(); j != videos.end(); ++j)
m_pDS->exec(PrepareSQL("update %s set c%02d=%d where id%s=%d", (i->first=="mvideo")?"musicvideo":i->first.c_str(), i->second, j->second, i->first.c_str(), j->first));
}
}
// always recreate the view after any table change
CreateViews();
return true;
@@ -175,7 +175,7 @@ const struct SDbTableOffsets
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_xml) },
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strIMDBNumber) },
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strSortTitle) },
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strRuntime) },
{ VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_duration) },
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strMPAARating) },
{ VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iTop250) },
{ VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_genre) },
@@ -274,7 +274,7 @@ const struct SDbTableOffsets DbEpisodeOffsets[] =
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_xml) },
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_spoof) },
{ VIDEODB_TYPE_COUNT, my_offsetof(CVideoInfoTag,m_playCount) }, // unused
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strRuntime) },
{ VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_duration) },
{ VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_director) },
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strProductionCode) },
{ VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iSeason) },
@@ -315,7 +315,7 @@ const struct SDbTableOffsets DbMusicVideoOffsets[] =
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_xml) },
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_spoof) },
{ VIDEODB_TYPE_COUNT, my_offsetof(CVideoInfoTag,m_playCount) }, // unused
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strRuntime) },
{ VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_duration) },
{ VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_director) },
{ VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_studio) },
{ VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iYear) },
@@ -805,7 +805,7 @@ class CVideoDatabase : public CDatabase
*/
bool LookupByFolders(const CStdString &path, bool shows = false);

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

@@ -79,7 +79,6 @@ void CVideoInfoTag::Reset()
m_iBookmarkId = -1;
m_iTrack = -1;
m_fanart.m_xml.clear();
m_strRuntime.clear();
m_duration = 0;
m_lastPlayed.Reset();
m_showLink.clear();
@@ -296,7 +295,6 @@ void CVideoInfoTag::Archive(CArchive& ar)
ar << m_strSet;
ar << m_iSetId;
ar << m_tags;
ar << m_strRuntime;
ar << m_duration;
ar << m_strFile;
ar << m_strPath;
@@ -375,7 +373,6 @@ void CVideoInfoTag::Archive(CArchive& ar)
ar >> m_strSet;
ar >> m_iSetId;
ar >> m_tags;
ar >> m_strRuntime;
ar >> m_duration;
ar >> m_strFile;
ar >> m_strPath;
@@ -590,7 +587,9 @@ void CVideoInfoTag::ParseNative(const TiXmlElement* movie, bool prioritise)
XMLUtils::GetString(movie, "outline", m_strPlotOutline);
XMLUtils::GetString(movie, "plot", m_strPlot);
XMLUtils::GetString(movie, "tagline", m_strTagLine);
XMLUtils::GetString(movie, "runtime", m_strRuntime);
CStdString runtime;
if (XMLUtils::GetString(movie, "runtime", runtime))
m_duration = GetDurationFromMinuteString(runtime);
XMLUtils::GetString(movie, "mpaa", m_strMPAARating);
XMLUtils::GetInt(movie, "playcount", m_playCount);
XMLUtils::GetDate(movie, "lastplayed", m_lastPlayed);
@@ -794,10 +793,7 @@ unsigned int CVideoInfoTag::GetDuration() const
if (m_streamDetails.GetVideoDuration() > 0)
return m_streamDetails.GetVideoDuration();

if (m_duration)
return m_duration;

return GetDurationFromMinuteString(m_strRuntime);
return m_duration;
}

unsigned int CVideoInfoTag::GetDurationFromMinuteString(const std::string &runtime)
@@ -108,7 +108,6 @@ class CVideoInfoTag : public IArchivable, public ISerializable, public ISortable
CStdString m_strSet;
int m_iSetId;
std::vector<std::string> m_tags;
CStdString m_strRuntime;
CStdString m_strFile;
CStdString m_strPath;
CStdString m_strIMDBNumber;

0 comments on commit d1e806a

Please sign in to comment.