ScheduleRule rules[] format

Post Reply
rtenklooster
Posts: 2
Joined: Tue Feb 25, 2014 12:10 am

ScheduleRule rules[] format

Post by rtenklooster » Tue Feb 25, 2014 9:07 pm

I am trying to add a schedule using the rest api + php

The problem is, the rules[] array is not documented. It's not clear what parameters to send in what format.I guessed it would be like this:

Code: Select all

// First request empty ID
//	Scheduler/EmptySchedule/0/82
$schedUrl = "/Scheduler/EmptySchedule/0/82";
$schedule = execute_curl($schedUrl);
//Object to array
$schedule = (array) $schedule;

$recordingname = "Een programmanaam";
$date = "2014-02-26T00:00:00+01:00";
$time = "16:05:00";
$channel = "71495e21-76b3-4bfb-8203-7dcc8104cb09";
$film = "2a47c176-eed2-4185-8272-be2044dbd263";
$serie = "ae221e24-d15f-4716-ac99-1cd5af6bc828";

$schedule[KeepUntilMode] = "UntilSpaceIsNeeded";
$schedule[IsOneTime] = "true";
$schedule[Name] = $recordingname;
$schedule[RecordingFileFormatId] = $film;
$schedule[Rules][ScheduleRule] = array("TitleEquals" => $recordingname, "OnDate" => $date, "AroundTime" => $time, "Channels" => $channel);
$schedule[SchedulePriority] = "Normal";
$schedule[ScheduleType] = "Recording";
$schedule[Version] = 1;
This way the schedule gets saved, but the rule content is ignored. If someone could give me a hint.. i would be a happy man :)

rtenklooster
Posts: 2
Joined: Tue Feb 25, 2014 12:10 am

Re: ScheduleRule rules[] format

Post by rtenklooster » Tue Feb 25, 2014 11:33 pm

Wireshark helped me out. I sniffed xbmc's communication, so got it figured out.
My solution, if someone else is having the same question:

Code: Select all

    // First request empty ID
    $schedUrl = "/Scheduler/EmptySchedule/0/82";
    $schedule = execute_curl($schedUrl);
    //Object to array
    $schedule = (array) $schedule;
    
    $recordingname = $_POST['title'];
    $date = $_POST['date'];
    $time = $_POST['time'];
    $channel = $_POST['channel'];
    if($_POST['type'] == 1){
        $fileFormat = "2a47c176-eed2-4185-8272-be2044dbd263";
    }else{
        $fileFormat = "ae221e24-d15f-4716-ac99-1cd5af6bc828";   
    }
    // Generate array
    $schedule[KeepUntilMode] = "UntilSpaceIsNeeded";
    $schedule[IsOneTime] = "true";
    $schedule[Name] = $recordingname;
    $schedule[RecordingFileFormatId] = $fileFormat;
    $schedule[Rules][0][Arguments][0] = $recordingname;
    $schedule[Rules][0][Type] = "TitleEquals";
    $schedule[Rules][1][Arguments][0] = $date;
    $schedule[Rules][1][Type] = "OnDate";
    $schedule[Rules][2][Arguments][0] = $time;
    $schedule[Rules][2][Type] = "AroundTime";
    $schedule[Rules][3][Arguments][0] = $channel;
    $schedule[Rules][3][Type] = "Channels";
    $schedule[SchedulePriority] = "Normal";
    $schedule[ScheduleType] = "Recording";
    $schedule[Version] = 1;
    
    // Save schedule
    $content = json_encode($schedule);
    $url = "http://192.168.1.68:49943/ArgusTV";
    $url .= "/Scheduler/SaveSchedule";
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //curl error SSL certificate problem, verify that the CA cert is OK
    
    $result = curl_exec($curl);
A small suggestion, for making things a bit more easy:
The reply of:

Code: Select all

ArgusTV/Guide/Program/{the program id}
Does not contains the channelId, only the channelEpgId. It would be nice to include the channelId to, because then i would only have to input a programId, and with one api call i would be able to start a recording.

User avatar
dot-i
Site Admin
Posts: 5848
Joined: Mon Oct 01, 2012 3:40 pm

Re: ScheduleRule rules[] format

Post by dot-i » Wed Feb 26, 2014 12:40 pm

Hi Richard,

Everything in the /Guide sub-system deals with GuideChannels and GuidePrograms only, so there's no concept of a regular Channel there yet. That is added by the /Scheduler sub-system where you can re-use the GuideChannels in more than one Channel if you like.
I have the heart of a child. I keep it in a jar on my shelf. -- Robert Bloch
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests