#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
require epg.class system.class
httpheader
set service [cgi_get service -]
set event [cgi_get event -]
set type [cgi_get type 1]
if {$service eq "-" || $event eq "-"} {
puts "Error, insufficient parameters passed."
exit
}
set event [lindex [epg fetch dump -service $service -event $event] 0]
if {$event eq ""} {
puts "Error, cannot find event to schedule."
exit
}
if {[$event percent] > 0} {
puts "Error, cannot record programme which has already started showing"
puts "or occurred in the past."
exit
}
set r [rsv construct $event $type]
if {[catch {$r insert} msg]} {
puts "Error encountered while scheduling: $msg"
} else {
puts "Successfully scheduled [$event get name]"
system restartpending
}
epg cleanup