2011-07-11 23:29:21 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
|
|
|
package require cgi
|
|
|
|
source /mod/var/mongoose/lib/setup
|
|
|
|
require epg.class
|
|
|
|
|
|
|
|
puts "Content-Type: text/html"
|
|
|
|
puts ""
|
|
|
|
|
|
|
|
cgi_input
|
|
|
|
#cgi_dump
|
|
|
|
|
2011-07-12 18:57:30 +00:00
|
|
|
#set _cgi(service) 4170
|
|
|
|
#set _cgi(event) 38584
|
|
|
|
#set _cgi(type) 2
|
2011-07-11 23:29:21 +00:00
|
|
|
|
|
|
|
if {![dict exists $_cgi service] || ![dict exists $_cgi event]} {
|
|
|
|
puts "Error, insufficient parameters passed."
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
set service $_cgi(service)
|
|
|
|
set event $_cgi(event)
|
|
|
|
set type 1
|
|
|
|
if {[dict exists $_cgi type]} { set type $_cgi(type) }
|
|
|
|
|
|
|
|
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} {
|
2011-07-12 18:57:30 +00:00
|
|
|
puts "Error, cannot record programme which has already started showing"
|
|
|
|
puts "or occurred in the past."
|
2011-07-11 23:29:21 +00:00
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
$event get_channel_info
|
|
|
|
|
|
|
|
set args {}
|
|
|
|
|
|
|
|
set args(ersvtype) 3
|
|
|
|
set args(hsvc) [$event get channel_hsvc]
|
|
|
|
set args(nsttime) [$event get start]
|
|
|
|
set args(nduration) [$event get duration]
|
|
|
|
set args(usevtid) [$event get event_id]
|
|
|
|
set args(szevtname) "\025[$event get name]"
|
|
|
|
set args(eReady) 30
|
|
|
|
|
2011-07-12 18:57:30 +00:00
|
|
|
set ccrid [$event get channel_crid]
|
|
|
|
|
2011-07-11 23:29:21 +00:00
|
|
|
if {$type == 1} {
|
|
|
|
# Event
|
2011-07-12 18:57:30 +00:00
|
|
|
set args(ucCRIDType) 49
|
|
|
|
set args(ucRecKind) 1
|
|
|
|
set args(szCRID) "$ccrid[$event get event_crid]"
|
2011-07-11 23:29:21 +00:00
|
|
|
set args(szEventToRecord) "1$args(szCRID)|"
|
|
|
|
} else {
|
|
|
|
# Series
|
2011-07-12 18:57:30 +00:00
|
|
|
set args(ucCRIDType) 50
|
|
|
|
set args(ucRecKind) 4
|
|
|
|
set args(szCRID) "$ccrid[$event get series_crid]"
|
2011-07-11 23:29:21 +00:00
|
|
|
set args(szFPBRecPath) "$args(szevtname)"
|
2011-07-12 18:57:30 +00:00
|
|
|
set progs [lmap i [epg fetch dump -scrid [$event get series_crid]] {
|
|
|
|
if {[set ecrid [$i get event_crid]] eq ""} { continue }
|
|
|
|
list "1$::ccrid$ecrid"
|
|
|
|
}]
|
|
|
|
set args(szEventToRecord) "[join $progs "|"]|"
|
2011-07-11 23:29:21 +00:00
|
|
|
}
|
|
|
|
|
2011-07-12 18:57:30 +00:00
|
|
|
#puts $args
|
|
|
|
|
2011-07-11 23:29:21 +00:00
|
|
|
set msg ""
|
2011-07-12 18:57:30 +00:00
|
|
|
if {![file exists /mod/.schedule.testing]} { set msg "Disabled during testing" }
|
2011-07-11 23:29:21 +00:00
|
|
|
if {$msg ne "" || [catch {[rsv new $args] insert} msg]} {
|
|
|
|
puts "Error encountered while scheduling the recording: <i>$msg</i>"
|
|
|
|
} else {
|
|
|
|
puts "Successfully scheduled recording of <i>[$event get name]</i>"
|
2011-07-12 18:57:30 +00:00
|
|
|
close [open /tmp/.restartpending w]
|
2011-07-11 23:29:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
epg cleanup
|
|
|
|
|