aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Marshall <jmarshall@never.you.mind>2012-11-02 15:49:02 +1300
committerJonathan Marshall <jmarshall@never.you.mind>2012-11-26 11:09:23 +1300
commita8a5b31ec911d25ff904b88978b2dbbf0a5845db (patch)
tree3b2c77b09797706b86d792178cfbfba831322cbc
parent544b1d4c3ee694646ec880900c8b73f7a7a093d2 (diff)
[runtime] adds m_duration to CVideoInfoTag as duration in seconds, and set this in preference to m_strRuntime where practical.
-rw-r--r--xbmc/filesystem/BlurayDirectory.cpp2
-rw-r--r--xbmc/filesystem/MythDirectory.cpp4
-rw-r--r--xbmc/filesystem/MythSession.cpp2
-rw-r--r--xbmc/filesystem/RSSDirectory.cpp10
-rw-r--r--xbmc/interfaces/json-rpc/VideoLibrary.cpp2
-rw-r--r--xbmc/interfaces/legacy/ListItem.cpp2
-rw-r--r--xbmc/network/upnp/UPnPInternal.cpp2
-rw-r--r--xbmc/utils/TuxBoxUtil.cpp2
-rw-r--r--xbmc/video/VideoDatabase.cpp2
-rw-r--r--xbmc/video/VideoInfoTag.cpp11
-rw-r--r--xbmc/video/VideoInfoTag.h7
11 files changed, 31 insertions, 15 deletions
diff --git a/xbmc/filesystem/BlurayDirectory.cpp b/xbmc/filesystem/BlurayDirectory.cpp
index 21e30ece02..4f38a35ca2 100644
--- a/xbmc/filesystem/BlurayDirectory.cpp
+++ b/xbmc/filesystem/BlurayDirectory.cpp
@@ -62,7 +62,7 @@ CFileItemPtr CBlurayDirectory::GetTitle(const BLURAY_TITLE_INFO* title, const CS
buf.Format("BDMV/PLAYLIST/%05d.mpls", title->playlist);
path.SetFileName(buf);
item->SetPath(path.Get());
- item->GetVideoInfoTag()->m_strRuntime.Format("%d",title->duration / 90000);
+ item->GetVideoInfoTag()->m_duration = (int)(title->duration / 90000);
item->GetVideoInfoTag()->m_iTrack = title->playlist;
buf.Format(label.c_str(), title->playlist);
item->m_strTitle = buf;
diff --git a/xbmc/filesystem/MythDirectory.cpp b/xbmc/filesystem/MythDirectory.cpp
index e9f6e9f01a..7e61205414 100644
--- a/xbmc/filesystem/MythDirectory.cpp
+++ b/xbmc/filesystem/MythDirectory.cpp
@@ -214,9 +214,7 @@ bool CMythDirectory::GetGuideForChannel(const CStdString& base, CFileItemList &i
CDateTime start(program[i].starttime);
CDateTime end(program[i].endtime);
CDateTimeSpan runtime = end - start;
- tag->m_strRuntime = StringUtils::SecondsToTimeString(runtime.GetSeconds() +
- runtime.GetMinutes() * 60 +
- runtime.GetHours() * 3600);
+ tag->m_duration = runtime.GetSeconds() + runtime.GetMinutes() * 60 + runtime.GetHours() * 3600;
tag->m_iSeason = 0; // So XBMC treats the content as an episode and displays tag information.
tag->m_iEpisode = 0;
diff --git a/xbmc/filesystem/MythSession.cpp b/xbmc/filesystem/MythSession.cpp
index 1b91f1e645..2e8a3534a4 100644
--- a/xbmc/filesystem/MythSession.cpp
+++ b/xbmc/filesystem/MythSession.cpp
@@ -167,7 +167,7 @@ void CMythSession::SetFileItemMetaData(CFileItem &item, cmyth_proginfo_t program
*/
tag->m_genre = StringUtils::Split(GetValue(m_dll->proginfo_category(program)), g_advancedSettings.m_videoItemSeparator); // e.g. Sports
tag->m_strAlbum = GetValue(m_dll->proginfo_chansign(program)); // e.g. TV3
- tag->m_strRuntime = StringUtils::SecondsToTimeString(m_dll->proginfo_length_sec(program));
+ tag->m_duration = m_dll->proginfo_length_sec(program);
SetSeasonAndEpisode(program, &tag->m_iSeason, &tag->m_iEpisode);
diff --git a/xbmc/filesystem/RSSDirectory.cpp b/xbmc/filesystem/RSSDirectory.cpp
index a6a1464ec1..96143195f2 100644
--- a/xbmc/filesystem/RSSDirectory.cpp
+++ b/xbmc/filesystem/RSSDirectory.cpp
@@ -274,7 +274,7 @@ static void ParseItemItunes(CFileItem* item, SResources& resources, TiXmlElement
else if(name == "author")
vtag->m_writingCredits.push_back(text);
else if(name == "duration")
- vtag->m_strRuntime = text;
+ vtag->m_duration = StringUtils::TimeStringToSeconds(text);
else if(name == "keywords")
item->SetProperty("keywords", text);
}
@@ -377,7 +377,7 @@ static void ParseItemBoxee(CFileItem* item, SResources& resources, TiXmlElement*
else if(name == "content_type")
item->SetMimeType(text);
else if(name == "runtime")
- vtag->m_strRuntime = text;
+ vtag->m_duration = StringUtils::TimeStringToSeconds(text);
else if(name == "episode")
vtag->m_iEpisode = atoi(text);
else if(name == "season")
@@ -405,9 +405,9 @@ static void ParseItemZink(CFileItem* item, SResources& resources, TiXmlElement*
else if(name == "userrating")
vtag->m_fRating = (float)atof(text.c_str());
else if(name == "duration")
- vtag->m_strRuntime = StringUtils::SecondsToTimeString(atoi(text));
+ vtag->m_duration = atoi(text);
else if(name == "durationstr")
- vtag->m_strRuntime = text;
+ vtag->m_duration = StringUtils::TimeStringToSeconds(text);
}
static void ParseItemSVT(CFileItem* item, SResources& resources, TiXmlElement* element, const CStdString& name, const CStdString& xmlns, const CStdString& path)
@@ -562,7 +562,7 @@ static void ParseItem(CFileItem* item, TiXmlElement* root, const CStdString& pat
CVideoInfoTag* vtag = item->GetVideoInfoTag();
if(item->HasProperty("duration") && !vtag->GetDuration())
- vtag->m_strRuntime = item->GetProperty("duration").asString();
+ vtag->m_duration = StringUtils::TimeStringToSeconds(item->GetProperty("duration").asString());
if(item->HasProperty("description") && vtag->m_strPlot.IsEmpty())
vtag->m_strPlot = item->GetProperty("description").asString();
diff --git a/xbmc/interfaces/json-rpc/VideoLibrary.cpp b/xbmc/interfaces/json-rpc/VideoLibrary.cpp
index 6358f5ffa8..b55d90c543 100644
--- a/xbmc/interfaces/json-rpc/VideoLibrary.cpp
+++ b/xbmc/interfaces/json-rpc/VideoLibrary.cpp
@@ -889,7 +889,7 @@ void CVideoLibrary::UpdateVideoTag(const CVariant &parameterObject, CVideoInfoTa
if (ParameterNotNull(parameterObject, "playcount"))
details.m_playCount = (int)parameterObject["playcount"].asInteger();
if (ParameterNotNull(parameterObject, "runtime"))
- details.m_strRuntime = parameterObject["runtime"].asString();
+ details.m_duration = CVideoInfoTag::GetDurationFromMinuteString(parameterObject["runtime"].asString());
if (ParameterNotNull(parameterObject, "director"))
CopyStringArray(parameterObject["director"], details.m_director);
if (ParameterNotNull(parameterObject, "studio"))
diff --git a/xbmc/interfaces/legacy/ListItem.cpp b/xbmc/interfaces/legacy/ListItem.cpp
index f7f0f3cf77..b342ea312d 100644
--- a/xbmc/interfaces/legacy/ListItem.cpp
+++ b/xbmc/interfaces/legacy/ListItem.cpp
@@ -337,7 +337,7 @@ namespace XBMCAddon
else if (key == "originaltitle")
item->GetVideoInfoTag()->m_strOriginalTitle = value;
else if (key == "duration")
- item->GetVideoInfoTag()->m_strRuntime = value;
+ item->GetVideoInfoTag()->m_duration = CVideoInfoTag::GetDurationFromMinuteString(value);
else if (key == "studio")
item->GetVideoInfoTag()->m_studio = StringUtils::Split(value, g_advancedSettings.m_videoItemSeparator);
else if (key == "tagline")
diff --git a/xbmc/network/upnp/UPnPInternal.cpp b/xbmc/network/upnp/UPnPInternal.cpp
index e23550c8b2..4bf1fd330e 100644
--- a/xbmc/network/upnp/UPnPInternal.cpp
+++ b/xbmc/network/upnp/UPnPInternal.cpp
@@ -664,7 +664,7 @@ PopulateTagFromObject(CVideoInfoTag& tag,
if(resource)
{
if (resource->m_Duration)
- tag.m_strRuntime.Format("%d",resource->m_Duration/60);
+ tag.m_duration = resource->m_Duration;
if (object.m_MiscInfo.last_position > 0 )
{
tag.m_resumePoint.totalTimeInSeconds = resource->m_Duration;
diff --git a/xbmc/utils/TuxBoxUtil.cpp b/xbmc/utils/TuxBoxUtil.cpp
index c0676555e3..f67a69c5a9 100644
--- a/xbmc/utils/TuxBoxUtil.cpp
+++ b/xbmc/utils/TuxBoxUtil.cpp
@@ -594,7 +594,7 @@ bool CTuxBoxUtil::GetZapUrl(const CStdString& strPath, CFileItem &items )
items.GetVideoInfoTag()->m_genre = StringUtils::Split(strGenre, g_advancedSettings.m_videoItemSeparator); // VIDEOPLAYER_GENRE: current_event_description (Film Name)
items.GetVideoInfoTag()->m_strTitle = strTitle; // VIDEOPLAYER_TITLE: current_event_details (Film beschreibung)
- items.GetVideoInfoTag()->m_strRuntime = StringUtils::SecondsToTimeString(iDuration); //VIDEOPLAYER_DURATION: current_event_duration (laufzeit in sec.)
+ items.GetVideoInfoTag()->m_duration = iDuration; //VIDEOPLAYER_DURATION: current_event_duration (laufzeit in sec.)
items.SetPath(strStreamURL);
items.m_iDriveType = url.GetPort(); // Dirty Hack! But i need to hold the Port ;)
diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp
index 950c309abe..4104213ecb 100644
--- a/xbmc/video/VideoDatabase.cpp
+++ b/xbmc/video/VideoDatabase.cpp
@@ -3150,7 +3150,7 @@ bool CVideoDatabase::GetStreamDetails(CVideoInfoTag& tag) const
details.DetermineBestStreams();
if (details.GetVideoDuration() > 0)
- tag.m_strRuntime.Format("%i", details.GetVideoDuration() / 60 );
+ tag.m_duration = details.GetVideoDuration();
return retVal;
}
diff --git a/xbmc/video/VideoInfoTag.cpp b/xbmc/video/VideoInfoTag.cpp
index bfde1ac449..08c1b3dc0c 100644
--- a/xbmc/video/VideoInfoTag.cpp
+++ b/xbmc/video/VideoInfoTag.cpp
@@ -80,6 +80,7 @@ void CVideoInfoTag::Reset()
m_iTrack = -1;
m_fanart.m_xml.clear();
m_strRuntime.clear();
+ m_duration = 0;
m_lastPlayed.Reset();
m_showLink.clear();
m_streamDetails.Reset();
@@ -296,6 +297,7 @@ void CVideoInfoTag::Archive(CArchive& ar)
ar << m_iSetId;
ar << m_tags;
ar << m_strRuntime;
+ ar << m_duration;
ar << m_strFile;
ar << m_strPath;
ar << m_strIMDBNumber;
@@ -374,6 +376,7 @@ void CVideoInfoTag::Archive(CArchive& ar)
ar >> m_iSetId;
ar >> m_tags;
ar >> m_strRuntime;
+ ar >> m_duration;
ar >> m_strFile;
ar >> m_strPath;
ar >> m_strIMDBNumber;
@@ -791,6 +794,14 @@ unsigned int CVideoInfoTag::GetDuration() const
if (m_streamDetails.GetVideoDuration() > 0)
return m_streamDetails.GetVideoDuration();
+ if (m_duration)
+ return m_duration;
+
+ return GetDurationFromMinuteString(m_strRuntime);
+}
+
+unsigned int CVideoInfoTag::GetDurationFromMinuteString(const std::string &runtime)
+{
unsigned int duration = (unsigned int)str2uint64(runtime);
if (!duration)
{ // failed for some reason, or zero
diff --git a/xbmc/video/VideoInfoTag.h b/xbmc/video/VideoInfoTag.h
index 805026990f..dd40553bab 100644
--- a/xbmc/video/VideoInfoTag.h
+++ b/xbmc/video/VideoInfoTag.h
@@ -82,6 +82,12 @@ public:
*/
unsigned int GetDuration() const;
+ /*! \brief get the duration in seconds from a minute string
+ \param runtime the runtime string from a scraper or similar
+ \return the time in seconds, if decipherable.
+ */
+ static unsigned int GetDurationFromMinuteString(const std::string &runtime);
+
CStdString m_basePath; // the base path of the video, for folder-based lookups
int m_parentPathID; // the parent path id where the base path of the video lies
std::vector<std::string> m_director;
@@ -141,6 +147,7 @@ public:
CBookmark m_resumePoint;
CDateTime m_dateAdded;
CStdString m_type;
+ int m_duration; ///< duration in seconds
private:
/* \brief Parse our native XML format for video info.