Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Support pre- and post-recording custom rules on ARGUS TV server #253

Merged
merged 1 commit into from

2 participants

@Red-F

Create new timers based on default schedule retrieved from ARGUS server.

Removed warnings about unused parameters in ADDON_Announce

@Red-F Red-F [argustv] Create new timers based on default schedule retrieved from …
…ARGUS

server. Removed warnings about unused parameters in ADDON_Announce
3dc78eb
@opdenkamp opdenkamp merged commit 8f46675 into opdenkamp:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 23, 2013
  1. @Red-F

    [argustv] Create new timers based on default schedule retrieved from …

    Red-F authored
    …ARGUS
    
    server. Removed warnings about unused parameters in ADDON_Announce
This page is out of date. Refresh to see the latest.
View
2  addons/pvr.argustv/addon/addon.xml.in
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.argustv"
- version="1.9.171"
+ version="1.9.172"
name="ARGUS TV client"
provider-name="Fred Hoogduin, Marcel Groothuis">
<requires>
View
2  addons/pvr.argustv/addon/changelog.txt
@@ -1,3 +1,5 @@
+v1.9.172 (23-12-2013)
+- base new timers on templates retrieved from ARGUS TV server.
v1.9.171 (11-12-2013)
- removed redundant notification
v1.9.170 (28-09-2013)
View
135 addons/pvr.argustv/src/argustvrpc.cpp
@@ -1061,6 +1061,33 @@ namespace ArgusTV
return retval;
}
+ /**
+ * \brief Retrieve an empty schedule from the server
+ */
+ int GetEmptySchedule(Json::Value& response)
+ {
+ int retval = -1;
+ XBMC->Log(LOG_DEBUG, "GetEmptySchedule");
+
+ retval = ArgusTVJSONRPC("ArgusTV/Scheduler/EmptySchedule/0/82", "", response);
+
+ if(retval >= 0)
+ {
+ if( response.type() != Json::objectValue)
+ {
+ XBMC->Log(LOG_DEBUG, "Unknown response format. Expected Json::objectValue\n");
+ return -1;
+ }
+ }
+ else
+ {
+ XBMC->Log(LOG_DEBUG, "GetEmptySchedule failed. Return value: %i\n", retval);
+ }
+
+ return retval;
+ }
+
+
/**
* \brief Add a xbmc timer as a one time schedule
*/
@@ -1072,26 +1099,52 @@ namespace ArgusTV
struct tm* convert = localtime(&starttime);
struct tm tm_start = *convert;
- // Format: ArgusTV/Scheduler/SaveSchedule
- // argument: {"ChannelType":0,"IsActive":true,"IsOneTime":true,"KeepUntilMode":0,"KeepUntilValue":null,
- // "LastModifiedTime":"\/Date(1297889326000+0100)\/","Name":"Astro TV","PostRecordSeconds":null,
- // "PreRecordSeconds":null,"ProcessingCommands":[],"RecordingFileFormatId":null,
- // "Rules":[{"Arguments":["Astro TV"],"Type":"TitleEquals"},{"Arguments":["2011-02-17T00:00:00+01:00"],"Type":"OnDate"},{"Arguments":["00:45:00"],"Type":"AroundTime"},{"Arguments":["ed49a4ef-5777-40c4-80b8-715e4c87f1a6"],"Type":"Channels"}],
- // "ScheduleId":"00000000-0000-0000-0000-000000000000","SchedulePriority":0,"ScheduleType":82,"Version":0}
+ // Get empty schedule from the server
+ Json::Value newSchedule;
+ if (ArgusTV::GetEmptySchedule(newSchedule) < 0) return retval;
- time_t now = time(NULL);
- std::string modifiedtime = TimeTToWCFDate(mktime(localtime(&now)));
+ // Fill relevant members
CStdString modifiedtitle = title;
modifiedtitle.Replace("\"", "\\\"");
- char arguments[1024];
- snprintf( arguments, sizeof(arguments),
- "{\"ChannelType\":0,\"IsActive\":true,\"IsOneTime\":true,\"KeepUntilMode\":\"%i\",\"KeepUntilValue\":\"%i\",\"LastModifiedTime\":\"%s\",\"Name\":\"%s\",\"PostRecordSeconds\":%i,\"PreRecordSeconds\":%i,\"ProcessingCommands\":[],\"RecordingFileFormatId\":null,\"Rules\":[{\"Arguments\":[\"%s\"],\"Type\":\"TitleEquals\"},{\"Arguments\":[\"%i-%02i-%02iT00:00:00\"],\"Type\":\"OnDate\"},{\"Arguments\":[\"%02i:%02i:%02i\"],\"Type\":\"AroundTime\"},{\"Arguments\":[\"%s\"],\"Type\":\"Channels\"}],\"ScheduleId\":\"00000000-0000-0000-0000-000000000000\",\"SchedulePriority\":0,\"ScheduleType\":82,\"Version\":0}",
- lifetimeToKeepUntilMode(lifetime), lifetimeToKeepUntilValue(lifetime), modifiedtime.c_str(), modifiedtitle.c_str(), postrecordseconds, prerecordseconds, modifiedtitle.c_str(),
- tm_start.tm_year + 1900, tm_start.tm_mon + 1, tm_start.tm_mday,
- tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec,
- channelid.c_str());
- retval = ArgusTVJSONRPC("ArgusTV/Scheduler/SaveSchedule", arguments, response);
+ newSchedule["IsOneTime"] = Json::Value(true);
+ newSchedule["KeepUntilMode"] = Json::Value(lifetimeToKeepUntilMode(lifetime));
+ newSchedule["KeepUntilValue"] = Json::Value(lifetimeToKeepUntilValue(lifetime));
+ newSchedule["Name"] = Json::Value(modifiedtitle.c_str());
+ newSchedule["PostRecordSeconds"] = Json::Value(postrecordseconds);
+ newSchedule["PreRecordSeconds"] = Json::Value(prerecordseconds);
+
+ Json::Value rule(Json::objectValue);
+ rule["Arguments"] = Json::arrayValue;
+ rule["Arguments"].append(Json::Value(modifiedtitle.c_str()));
+ rule["Type"] = Json::Value("TitleEquals");
+ newSchedule["Rules"].append(rule);
+
+ char formatbuffer[256];
+ rule = Json::objectValue;
+ rule["Arguments"] = Json::arrayValue;
+ snprintf(formatbuffer, sizeof(formatbuffer), "%i-%02i-%02iT00:00:00", tm_start.tm_year + 1900, tm_start.tm_mon + 1, tm_start.tm_mday);
+ rule["Arguments"].append(Json::Value(formatbuffer));
+ rule["Type"] = Json::Value("OnDate");
+ newSchedule["Rules"].append(rule);
+
+ rule = Json::objectValue;
+ rule["Arguments"] = Json::arrayValue;
+ snprintf(formatbuffer, sizeof(formatbuffer), "%02i:%02i:%02i", tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec);
+ rule["Arguments"].append(Json::Value(formatbuffer));
+ rule["Type"] = Json::Value("AroundTime");
+ newSchedule["Rules"].append(rule);
+
+ rule = Json::objectValue;
+ rule["Arguments"] = Json::arrayValue;
+ rule["Arguments"].append(Json::Value(channelid.c_str()));
+ rule["Type"] = Json::Value("Channels");
+ newSchedule["Rules"].append(rule);
+
+ Json::FastWriter writer;
+ std::string tmparguments = writer.write(newSchedule);
+
+ retval = ArgusTVJSONRPC("ArgusTV/Scheduler/SaveSchedule", tmparguments.c_str(), response);
if(retval >= 0)
{
@@ -1126,28 +1179,44 @@ namespace ArgusTV
recordingduration /= 60;
int duration_hrs = recordingduration;
- // Format: ArgusTV/Scheduler/SaveSchedule
- // argument: {"ChannelType":0,"IsActive":true,"IsOneTime":true,"KeepUntilMode":0,"KeepUntilValue":null,
- // "LastModifiedTime":"\/Date(1307645182000+0100)\/","Name":"XBMC (manual) - blup","PostRecordSeconds":600,
- // "PreRecordSeconds":120,"ProcessingCommands":[],"RecordingFileFormatId":null,
- // "Rules":[{"Arguments":["2011-06-11T22:10:00", "01:13:00"],"Type":"ManualSchedule"},{"Arguments":["6a14caaf-5e39-4750-b7b7-eae8c741c094"],"Type":"Channels"}],
- // "ScheduleId":"00000000-0000-0000-0000-000000000000","SchedulePriority":0,"ScheduleType":82,"Version":0}
+ // Get empty schedule from the server
+ Json::Value newSchedule;
+ if (ArgusTV::GetEmptySchedule(newSchedule) < 0) return retval;
- time_t now = time(NULL);
- std::string modifiedtime = TimeTToWCFDate(mktime(localtime(&now)));
+ // Fill relevant members
CStdString modifiedtitle = title;
modifiedtitle.Replace("\"", "\\\"");
- char arguments[1024];
- snprintf( arguments, sizeof(arguments),
- "{\"ChannelType\":0,\"IsActive\":true,\"IsOneTime\":true,\"KeepUntilMode\":\"%i\",\"KeepUntilValue\":\"%i\",\"LastModifiedTime\":\"%s\",\"Name\":\"%s (manual)\",\"PostRecordSeconds\":%i,\"PreRecordSeconds\":%i,\"ProcessingCommands\":[],\"RecordingFileFormatId\":null,"
- "\"Rules\":[{\"Arguments\":[\"%i-%02i-%02iT%02i:%02i:%02i\", \"%02i:%02i:%02i\"],\"Type\":\"ManualSchedule\"},{\"Arguments\":[\"%s\"],\"Type\":\"Channels\"}],\"ScheduleId\":\"00000000-0000-0000-0000-000000000000\",\"SchedulePriority\":0,\"ScheduleType\":82,\"Version\":0}",
- lifetimeToKeepUntilMode(lifetime), lifetimeToKeepUntilValue(lifetime), modifiedtime.c_str(), modifiedtitle.c_str(), postrecordseconds, prerecordseconds,
+
+ newSchedule["IsOneTime"] = Json::Value(true);
+ newSchedule["KeepUntilMode"] = Json::Value(lifetimeToKeepUntilMode(lifetime));
+ newSchedule["KeepUntilValue"] = Json::Value(lifetimeToKeepUntilValue(lifetime));
+ newSchedule["Name"] = Json::Value(modifiedtitle.c_str());
+ newSchedule["PostRecordSeconds"] = Json::Value(postrecordseconds);
+ newSchedule["PreRecordSeconds"] = Json::Value(prerecordseconds);
+
+ Json::Value rule(Json::objectValue);
+ char formatbuffer[256];
+ rule["Arguments"] = Json::arrayValue;
+ snprintf(formatbuffer, sizeof(formatbuffer), "%i-%02i-%02iT%02i:%02i:%02i",
tm_start.tm_year + 1900, tm_start.tm_mon + 1, tm_start.tm_mday,
- tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec,
- duration_hrs, duration_min, duration_sec,
- channelid.c_str());
+ tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec);
+ rule["Arguments"].append(Json::Value(formatbuffer));
+ snprintf(formatbuffer, sizeof(formatbuffer), "%02i:%02i:%02i",
+ duration_hrs, duration_min, duration_sec);
+ rule["Arguments"].append(Json::Value(formatbuffer));
+ rule["Type"] = Json::Value("ManualSchedule");
+ newSchedule["Rules"].append(rule);
+
+ rule = Json::objectValue;
+ rule["Arguments"] = Json::arrayValue;
+ rule["Arguments"].append(Json::Value(channelid.c_str()));
+ rule["Type"] = Json::Value("Channels");
+ newSchedule["Rules"].append(rule);
+
+ Json::FastWriter writer;
+ std::string tmparguments = writer.write(newSchedule);
- retval = ArgusTVJSONRPC("ArgusTV/Scheduler/SaveSchedule", arguments, response);
+ retval = ArgusTVJSONRPC("ArgusTV/Scheduler/SaveSchedule", tmparguments, response);
if(retval >= 0)
{
View
5 addons/pvr.argustv/src/argustvrpc.h
@@ -289,6 +289,11 @@ namespace ArgusTV
int CancelUpcomingProgram(const std::string& scheduleid, const std::string& channelid, const time_t starttime, const std::string& upcomingprogramid);
/**
+ * \brief Retrieve an empty schedule from the server
+ */
+ int GetEmptySchedule(Json::Value& response);
+
+ /**
* \brief Add a xbmc timer as a one time schedule
*/
int AddOneTimeSchedule(const std::string& channelid, const time_t starttime, const std::string& title, int prerecordseconds, int postrecordseconds, int lifetime, Json::Value& response);
View
1  addons/pvr.argustv/src/client.cpp
@@ -287,6 +287,7 @@ void ADDON_FreeSettings()
void ADDON_Announce(const char *flag, const char *sender, const char *message, const void *data)
{
+ (void) flag; (void) sender; (void) message; (void) data;
}
/***********************************************************
Something went wrong with that request. Please try again.