Skip to content

Commit

Permalink
[runtime] drop m_strRuntime and update the video database to use m_du…
Browse files Browse the repository at this point in the history
…ration instead
  • Loading branch information
Jonathan Marshall committed Nov 25, 2012
1 parent a8a5b31 commit d1e806a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
23 changes: 23 additions & 0 deletions xbmc/video/VideoDatabase.cpp
Expand Up @@ -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); " "DELETE FROM tag WHERE idTag=old.idTag AND idTag NOT IN (SELECT DISTINCT idTag FROM taglinks); "
"END"); "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 // always recreate the view after any table change
CreateViews(); CreateViews();
return true; return true;
Expand Down
8 changes: 4 additions & 4 deletions xbmc/video/VideoDatabase.h
Expand Up @@ -175,7 +175,7 @@ const struct SDbTableOffsets
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_xml) }, { 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_strIMDBNumber) },
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strSortTitle) }, { 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_STRING, my_offsetof(CVideoInfoTag,m_strMPAARating) },
{ VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iTop250) }, { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iTop250) },
{ VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_genre) }, { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_genre) },
Expand Down Expand Up @@ -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_xml) },
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_spoof) }, { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_spoof) },
{ VIDEODB_TYPE_COUNT, my_offsetof(CVideoInfoTag,m_playCount) }, // unused { 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_director) },
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strProductionCode) }, { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strProductionCode) },
{ VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iSeason) }, { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iSeason) },
Expand Down Expand Up @@ -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_xml) },
{ VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_spoof) }, { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_spoof) },
{ VIDEODB_TYPE_COUNT, my_offsetof(CVideoInfoTag,m_playCount) }, // unused { 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_director) },
{ VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_studio) }, { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_studio) },
{ VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iYear) }, { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iYear) },
Expand Down Expand Up @@ -805,7 +805,7 @@ class CVideoDatabase : public CDatabase
*/ */
bool LookupByFolders(const CStdString &path, bool shows = false); 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; }; virtual int GetExportVersion() const { return 1; };
const char *GetBaseDBName() const { return "MyVideos"; }; const char *GetBaseDBName() const { return "MyVideos"; };


Expand Down
12 changes: 4 additions & 8 deletions xbmc/video/VideoInfoTag.cpp
Expand Up @@ -79,7 +79,6 @@ void CVideoInfoTag::Reset()
m_iBookmarkId = -1; m_iBookmarkId = -1;
m_iTrack = -1; m_iTrack = -1;
m_fanart.m_xml.clear(); m_fanart.m_xml.clear();
m_strRuntime.clear();
m_duration = 0; m_duration = 0;
m_lastPlayed.Reset(); m_lastPlayed.Reset();
m_showLink.clear(); m_showLink.clear();
Expand Down Expand Up @@ -296,7 +295,6 @@ void CVideoInfoTag::Archive(CArchive& ar)
ar << m_strSet; ar << m_strSet;
ar << m_iSetId; ar << m_iSetId;
ar << m_tags; ar << m_tags;
ar << m_strRuntime;
ar << m_duration; ar << m_duration;
ar << m_strFile; ar << m_strFile;
ar << m_strPath; ar << m_strPath;
Expand Down Expand Up @@ -375,7 +373,6 @@ void CVideoInfoTag::Archive(CArchive& ar)
ar >> m_strSet; ar >> m_strSet;
ar >> m_iSetId; ar >> m_iSetId;
ar >> m_tags; ar >> m_tags;
ar >> m_strRuntime;
ar >> m_duration; ar >> m_duration;
ar >> m_strFile; ar >> m_strFile;
ar >> m_strPath; ar >> m_strPath;
Expand Down Expand Up @@ -590,7 +587,9 @@ void CVideoInfoTag::ParseNative(const TiXmlElement* movie, bool prioritise)
XMLUtils::GetString(movie, "outline", m_strPlotOutline); XMLUtils::GetString(movie, "outline", m_strPlotOutline);
XMLUtils::GetString(movie, "plot", m_strPlot); XMLUtils::GetString(movie, "plot", m_strPlot);
XMLUtils::GetString(movie, "tagline", m_strTagLine); 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::GetString(movie, "mpaa", m_strMPAARating);
XMLUtils::GetInt(movie, "playcount", m_playCount); XMLUtils::GetInt(movie, "playcount", m_playCount);
XMLUtils::GetDate(movie, "lastplayed", m_lastPlayed); XMLUtils::GetDate(movie, "lastplayed", m_lastPlayed);
Expand Down Expand Up @@ -794,10 +793,7 @@ unsigned int CVideoInfoTag::GetDuration() const
if (m_streamDetails.GetVideoDuration() > 0) if (m_streamDetails.GetVideoDuration() > 0)
return m_streamDetails.GetVideoDuration(); return m_streamDetails.GetVideoDuration();


if (m_duration) return m_duration;
return m_duration;

return GetDurationFromMinuteString(m_strRuntime);
} }


unsigned int CVideoInfoTag::GetDurationFromMinuteString(const std::string &runtime) unsigned int CVideoInfoTag::GetDurationFromMinuteString(const std::string &runtime)
Expand Down
1 change: 0 additions & 1 deletion xbmc/video/VideoInfoTag.h
Expand Up @@ -108,7 +108,6 @@ class CVideoInfoTag : public IArchivable, public ISerializable, public ISortable
CStdString m_strSet; CStdString m_strSet;
int m_iSetId; int m_iSetId;
std::vector<std::string> m_tags; std::vector<std::string> m_tags;
CStdString m_strRuntime;
CStdString m_strFile; CStdString m_strFile;
CStdString m_strPath; CStdString m_strPath;
CStdString m_strIMDBNumber; CStdString m_strIMDBNumber;
Expand Down

0 comments on commit d1e806a

Please sign in to comment.