Permalink
Browse files

[argustv-add] Full support for PlayCount

  • Loading branch information...
1 parent 398d23e commit 23b05fbd0b0c964fea5f7431329fc9d1ba00b969 @Red-F Red-F committed Nov 18, 2012
@@ -1,5 +1,6 @@
-v1.0.150.144 (14-11-2012)
+v1.0.150.144 (18-11-2012)
- First ARGUS TV implementation
+- Support XBMC play count
v1.0.150.143 (03-11-2012)
- Bump version to 1 for Frodo :)
@@ -853,6 +853,25 @@ namespace ArgusTV
return retval;
}
+ int SetRecordingFullyWatchedCount(const std::string& recordingfilename, int playcount)
+ {
+ std::string response;
+ char tmp[512];
+
+ XBMC->Log(LOG_DEBUG, "SetRecordingFullyWatchedCount(\"%s\", %d)", recordingfilename.c_str(), playcount);
+
+ snprintf(tmp, 512, "{\"RecordingFileName\":%s,\"FullyWatchedCount\":%d}", recordingfilename.c_str(), playcount);
+ std::string arguments = tmp;
+ std::string command = "ArgusTV/Control/SetRecordingFullyWatchedCount";
+
+ int retval = ArgusTV::ArgusTVRPC(command, arguments, response);
+ if (retval < 0)
+ {
+ XBMC->Log(LOG_DEBUG, "SetRecordingFullyWatchedCount failed. Return value: %i\n", retval);
+ }
+ return retval;
+ }
+
int GetScheduleById(const std::string& id, Json::Value& response)
{
int retval = E_FAILED;
@@ -229,6 +229,13 @@ namespace ArgusTV
*/
int SetRecordingLastWatchedPosition(const std::string& recordingfilename, int lastwatchedposition);
+ /**
+ * \brief Set the play count for this recording
+ * \param recordingfilename full UNC path of the recording file
+ * \param playcount the number of times this recording was played
+ */
+ int SetRecordingFullyWatchedCount(const std::string& recordingfilename, int playcount);
+
/**
* \brief Delete the recording on the pvr backend
* \param recordingfilename UNC filename to delete
@@ -325,7 +325,7 @@ PVR_ERROR GetAddonCapabilities(PVR_ADDON_CAPABILITIES *pCapabilities)
pCapabilities->bSupportsChannelScan = false;
pCapabilities->bSupportsLastPlayedPosition = true;
pCapabilities->bSupportsRecordingFolders = true;
- pCapabilities->bSupportsRecordingPlayCount = false;
+ pCapabilities->bSupportsRecordingPlayCount = true;
return PVR_ERROR_NO_ERROR;
}
@@ -484,6 +484,10 @@ int GetRecordingLastPlayedPosition(const PVR_RECORDING &recording)
return g_client->GetRecordingLastPlayedPosition(recording);
}
+PVR_ERROR SetRecordingPlayCount(const PVR_RECORDING &recording, int count)
+{
+ return g_client->SetRecordingPlayCount(recording, count);
+}
/*******************************************/
/** PVR Timer Functions **/
@@ -629,7 +633,6 @@ DemuxPacket* DemuxRead(void) { return NULL; }
void DemuxAbort(void) {}
void DemuxReset(void) {}
void DemuxFlush(void) {}
-PVR_ERROR SetRecordingPlayCount(const PVR_RECORDING &recording, int count) { NOTUSED(recording); NOTUSED(count); return PVR_ERROR_NOT_IMPLEMENTED; }
unsigned int GetChannelSwitchDelay(void) { return 0; }
bool SeekTime(int,bool,double*) { return false; }
void SetSpeed(int) {};
@@ -737,7 +737,6 @@ PVR_ERROR cPVRClientArgusTV::GetRecordings(ADDON_HANDLE handle)
tag.iDuration = recording.RecordingStopTime() - recording.RecordingStartTime();
strncpy(tag.strPlot, recording.Description(), sizeof(tag.strPlot));
tag.iPlayCount = recording.FullyWatchedCount();
- XBMC->Log(LOG_DEBUG, "recording %s, watch count == %d\n", recording.Title(), recording.FullyWatchedCount());
if (nrOfRecordings > 1)
{
recording.Transform(true);
@@ -863,6 +862,29 @@ int cPVRClientArgusTV::GetRecordingLastPlayedPosition(const PVR_RECORDING &recin
return retval;
}
+PVR_ERROR cPVRClientArgusTV::SetRecordingPlayCount(const PVR_RECORDING &recinfo, int playcount)
+{
+ XBMC->Log(LOG_DEBUG, "->SetRecordingPlayCount(index=%s [%s], %d)", recinfo.strRecordingId, recinfo.strStreamURL, playcount);
+
+ std::string recordingfilename = recinfo.strStreamURL;
+#if !defined(TARGET_WINDOWS)
+ recordingfilename = ArgusTV::ToUNC(recordingfilename);
+#endif
+
+ // JSONify the stream_url
+ Json::Value recordingname (recordingfilename);
+ Json::FastWriter writer;
+ std::string jsonval = writer.write(recordingname);
+ int retval = ArgusTV::SetRecordingFullyWatchedCount(jsonval, playcount);
+ if (retval < 0)
+ {
+ XBMC->Log(LOG_INFO, "Failed to set recording play count (%d)", retval);
+ return PVR_ERROR_SERVER_ERROR;
+ }
+
+ return PVR_ERROR_NO_ERROR;
+}
+
/************************************************************/
/** Timer handling */
@@ -72,6 +72,7 @@ class cPVRClientArgusTV
PVR_ERROR RenameRecording(const PVR_RECORDING &recinfo);
PVR_ERROR SetRecordingLastPlayedPosition(const PVR_RECORDING &recinfo, int lastplayedposition);
int GetRecordingLastPlayedPosition(const PVR_RECORDING &recinfo);
+ PVR_ERROR SetRecordingPlayCount(const PVR_RECORDING &recinfo, int playcount);
/* Timer handling */
int GetNumTimers(void);

0 comments on commit 23b05fb

Please sign in to comment.