2012-09-25, 06:25 PM
(This post was last modified: 2012-09-25, 06:38 PM by wileecoyote.)
The recordings list shows all recordings, past, present and future. I was playing around with the addon and added this code to only show recordings that are completed.
This code is in the GetRecordings(ADDON_HANDLE handle) method. Code modifed is in bold
// include already-completed recordings
CStdString response;
CStdString status;
CStdString title;
if (DoRequest("/service?method=recording.list&filter=ready", response) == HTTP_OK)
{
TiXmlDocument doc;
if (doc.Parse(response) != NULL)
{
PVR_RECORDING tag;
TiXmlElement* recordingsNode = doc.RootElement()->FirstChildElement("recordings");
TiXmlElement* pRecordingNode = recordingsNode->FirstChildElement("recording");
for( pRecordingNode; pRecordingNode; pRecordingNode=pRecordingNode->NextSiblingElement())
{
[COLOR="#FF0000"] status = pRecordingNode->FirstChildElement("status")->FirstChild()->Value();
if(status == "Ready")
{[/COLOR]
memset(&tag, 0, sizeof(PVR_RECORDING));
PVR_STRCPY(tag.strRecordingId, pRecordingNode->FirstChildElement("id")->FirstChild()->Value());
//PVR_STRCPY(tag.strTitle, pRecordingNode->FirstChildElement("title")->FirstChild()->Value());
PVR_STRCPY(tag.strDirectory, pRecordingNode->FirstChildElement("name")->FirstChild()->Value());
title = pRecordingNode->FirstChildElement("name")->FirstChild()->Value();
if (pRecordingNode->FirstChildElement("desc") != NULL && pRecordingNode->FirstChildElement("desc")->FirstChild() != NULL)
{
PVR_STRCPY(tag.strPlot, pRecordingNode->FirstChildElement("desc")->FirstChild()->Value());
[COLOR="#FF0000"] title += " - ";
title += pRecordingNode->FirstChildElement("desc")->FirstChild()->Value();[/COLOR]
}
PVR_STRCPY(tag.strTitle, title);
tag.recordingTime = atoi(pRecordingNode->FirstChildElement("start_time_ticks")->FirstChild()->Value());
tag.iDuration = atoi(pRecordingNode->FirstChildElement("duration_seconds")->FirstChild()->Value());
CStdString strStream;
strStream.Format("http://%s:%d/live?recording=%s", g_szHostname, g_iPort, tag.strRecordingId);
strncpy(tag.strStreamURL, strStream.c_str(), sizeof(tag.strStreamURL));
PVR->TransferRecordingEntry(handle, &tag);
}
}
}
}
This code is in the GetRecordings(ADDON_HANDLE handle) method. Code modifed is in bold
// include already-completed recordings
CStdString response;
CStdString status;
CStdString title;
if (DoRequest("/service?method=recording.list&filter=ready", response) == HTTP_OK)
{
TiXmlDocument doc;
if (doc.Parse(response) != NULL)
{
PVR_RECORDING tag;
TiXmlElement* recordingsNode = doc.RootElement()->FirstChildElement("recordings");
TiXmlElement* pRecordingNode = recordingsNode->FirstChildElement("recording");
for( pRecordingNode; pRecordingNode; pRecordingNode=pRecordingNode->NextSiblingElement())
{
[COLOR="#FF0000"] status = pRecordingNode->FirstChildElement("status")->FirstChild()->Value();
if(status == "Ready")
{[/COLOR]
memset(&tag, 0, sizeof(PVR_RECORDING));
PVR_STRCPY(tag.strRecordingId, pRecordingNode->FirstChildElement("id")->FirstChild()->Value());
//PVR_STRCPY(tag.strTitle, pRecordingNode->FirstChildElement("title")->FirstChild()->Value());
PVR_STRCPY(tag.strDirectory, pRecordingNode->FirstChildElement("name")->FirstChild()->Value());
title = pRecordingNode->FirstChildElement("name")->FirstChild()->Value();
if (pRecordingNode->FirstChildElement("desc") != NULL && pRecordingNode->FirstChildElement("desc")->FirstChild() != NULL)
{
PVR_STRCPY(tag.strPlot, pRecordingNode->FirstChildElement("desc")->FirstChild()->Value());
[COLOR="#FF0000"] title += " - ";
title += pRecordingNode->FirstChildElement("desc")->FirstChild()->Value();[/COLOR]
}
PVR_STRCPY(tag.strTitle, title);
tag.recordingTime = atoi(pRecordingNode->FirstChildElement("start_time_ticks")->FirstChild()->Value());
tag.iDuration = atoi(pRecordingNode->FirstChildElement("duration_seconds")->FirstChild()->Value());
CStdString strStream;
strStream.Format("http://%s:%d/live?recording=%s", g_szHostname, g_iPort, tag.strRecordingId);
strncpy(tag.strStreamURL, strStream.c_str(), sizeof(tag.strStreamURL));
PVR->TransferRecordingEntry(handle, &tag);
}
}
}
}