FIX: [JSON] streamdetails are never retrieved #1233

Merged
merged 1 commit into from Aug 2, 2012
@@ -53,6 +53,16 @@ JSONRPC_STATUS CVideoLibrary::GetMovieDetails(const CStdString &method, ITranspo
if (!videodatabase.GetMovieInfo("", infos, id) || infos.m_iDbId <= 0)
return InvalidParams;
+ for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++)
+ {
+ CStdString fieldValue = itr->asString();
+ if (fieldValue == "streamdetails")
+ {
+ videodatabase.GetStreamDetails(infos);
+ break;
+ }
+ }
+
HandleFileItem("movieid", true, "moviedetails", CFileItemPtr(new CFileItem(infos)), parameterObject, parameterObject["properties"], result, false);
return OK;
}
@@ -196,6 +206,16 @@ JSONRPC_STATUS CVideoLibrary::GetEpisodeDetails(const CStdString &method, ITrans
if (!videodatabase.GetEpisodeInfo("", infos, id) || infos.m_iDbId <= 0)
return InvalidParams;
+ for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++)
+ {
+ CStdString fieldValue = itr->asString();
+ if (fieldValue == "streamdetails")
+ {
+ videodatabase.GetStreamDetails(infos);
+ break;
+ }
+ }
+
CFileItemPtr pItem = CFileItemPtr(new CFileItem(infos));
// We need to set the correct base path to get the valid fanart
int tvshowid = infos.m_iIdShow;
@@ -242,6 +262,16 @@ JSONRPC_STATUS CVideoLibrary::GetMusicVideoDetails(const CStdString &method, ITr
if (!videodatabase.GetMusicVideoInfo("", infos, id) || infos.m_iDbId <= 0)
return InvalidParams;
+ for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++)
+ {
+ CStdString fieldValue = itr->asString();
+ if (fieldValue == "streamdetails")
+ {
+ videodatabase.GetStreamDetails(infos);
+ break;
+ }
+ }
+
HandleFileItem("musicvideoid", true, "musicvideodetails", CFileItemPtr(new CFileItem(infos)), parameterObject, parameterObject["properties"], result, false);
return OK;
}
@@ -616,17 +646,25 @@ JSONRPC_STATUS CVideoLibrary::GetAdditionalMovieDetails(const CVariant &paramete
return InternalError;
bool additionalInfo = false;
+ bool streamdetails = false;
for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++)
{
CStdString fieldValue = itr->asString();
if (fieldValue == "cast" || fieldValue == "set" || fieldValue == "setid" || fieldValue == "showlink" || fieldValue == "resume")
additionalInfo = true;
+ else if (fieldValue == "streamdetails")
+ streamdetails = true;
}
- if (additionalInfo)
+ if (additionalInfo || streamdetails)
Montellese
Montellese Aug 1, 2012 Owner

I don't like this. It means that whenever someone just wants to retrieve the streamdetails we will also query the database for the cast, sets and other information that require extra queries. Either make an extra if-condition-block for the streamdetails or add an "if (additionalInfo)" in front of the videodatabase.GetFooInfo() call (not only here but also for episodes and musicvideos).

koying
koying Aug 1, 2012 Owner

You're right on the principle, but isn't GetMovieInfo creating the VideoInfoTag needed by GetStreamDetails?

Montellese
Montellese Aug 2, 2012 Owner

Sorry didn't get any email notification on your response. No the CVideoInfoTag object already exists in the CFileItemPtr from the list and both GetMovieInfo and GetStreamDetails just alter its details if necessary.

{
for (int index = 0; index < items.Size(); index++)
- videodatabase.GetMovieInfo("", *(items[index]->GetVideoInfoTag()), items[index]->GetVideoInfoTag()->m_iDbId);
+ {
+ if (additionalInfo)
+ videodatabase.GetMovieInfo("", *(items[index]->GetVideoInfoTag()), items[index]->GetVideoInfoTag()->m_iDbId);
+ if (streamdetails)
+ videodatabase.GetStreamDetails(*(items[index]->GetVideoInfoTag()));
+ }
}
int size = items.Size();
@@ -643,17 +681,25 @@ JSONRPC_STATUS CVideoLibrary::GetAdditionalEpisodeDetails(const CVariant &parame
return InternalError;
bool additionalInfo = false;
+ bool streamdetails = false;
for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++)
{
CStdString fieldValue = itr->asString();
if (fieldValue == "cast" || fieldValue == "resume")
additionalInfo = true;
+ else if (fieldValue == "streamdetails")
+ streamdetails = true;
}
- if (additionalInfo)
+ if (additionalInfo || streamdetails)
{
for (int index = 0; index < items.Size(); index++)
- videodatabase.GetEpisodeInfo("", *(items[index]->GetVideoInfoTag()), items[index]->GetVideoInfoTag()->m_iDbId);
+ {
+ if (additionalInfo)
+ videodatabase.GetEpisodeInfo("", *(items[index]->GetVideoInfoTag()), items[index]->GetVideoInfoTag()->m_iDbId);
+ if (streamdetails)
+ videodatabase.GetStreamDetails(*(items[index]->GetVideoInfoTag()));
+ }
}
int size = items.Size();
@@ -670,19 +716,27 @@ JSONRPC_STATUS CVideoLibrary::GetAdditionalMusicVideoDetails(const CVariant &par
return InternalError;
bool additionalInfo = false;
+ bool streamdetails = false;
for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++)
{
CStdString fieldValue = itr->asString();
if (fieldValue == "resume")
additionalInfo = true;
+ else if (fieldValue == "streamdetails")
+ streamdetails = true;
}
- if (additionalInfo)
+ if (additionalInfo || streamdetails)
{
for (int index = 0; index < items.Size(); index++)
- videodatabase.GetMusicVideoInfo("", *(items[index]->GetVideoInfoTag()), items[index]->GetVideoInfoTag()->m_iDbId);
+ {
+ if (additionalInfo)
+ videodatabase.GetMusicVideoInfo("", *(items[index]->GetVideoInfoTag()), items[index]->GetVideoInfoTag()->m_iDbId);
+ if (streamdetails)
+ videodatabase.GetStreamDetails(*(items[index]->GetVideoInfoTag()));
+ }
}
-
+
int size = items.Size();
if (items.HasProperty("total") && items.GetProperty("total").asInteger() > size)
size = (int)items.GetProperty("total").asInteger();