diff --git a/htsclient.c b/htsclient.c index d961a23a..6f990ee8 100644 --- a/htsclient.c +++ b/htsclient.c @@ -558,6 +558,30 @@ cr_event_record(client_t *c, char **argv, int argc) return 0; } + + + +/* + * + */ +static int +cr_channel_record(client_t *c, char **argv, int argc) +{ + th_channel_t *ch; + int duration; + + if(argc < 2) + return 1; + + if((ch = channel_by_index(atoi(argv[0]))) == NULL) + return 1; + + duration = atoi(argv[1]); + + pvr_channel_record_op(ch, duration); + return 0; +} + /* * */ @@ -643,6 +667,7 @@ const struct { { "channel.info", cr_channel_info }, { "channel.subscribe", cr_channel_subscribe }, { "channel.unsubscribe", cr_channel_unsubscribe }, + { "channel.record", cr_channel_record }, { "event.info", cr_event_info }, { "event.record", cr_event_record }, { "pvr.getlog", cr_pvr_getlog }, diff --git a/pvr.c b/pvr.c index 5c31f746..1b773833 100644 --- a/pvr.c +++ b/pvr.c @@ -268,6 +268,29 @@ pvr_event_record_op(th_channel_t *ch, event_t *e, recop_t op) +void +pvr_channel_record_op(th_channel_t *ch, int duration) +{ + time_t now = dispatch_clock; + time_t start = now; + time_t stop = now + duration; + pvr_rec_t *pvrr; + + pvrr = calloc(1, sizeof(pvr_rec_t)); + pvrr->pvrr_status = HTSTV_PVR_STATUS_SCHEDULED; + pvrr->pvrr_channel = ch; + pvrr->pvrr_start = start; + pvrr->pvrr_stop = stop; + pvrr->pvrr_title = strdup("Manual recording"); + pvrr->pvrr_desc = NULL; + + pvr_link_pvrr(pvrr); + pvr_database_save(); +} + + + + /***************************************************************************** * * Plain text "database" of pvr programmes diff --git a/pvr.h b/pvr.h index d7ca5880..2aece0d3 100644 --- a/pvr.h +++ b/pvr.h @@ -46,4 +46,6 @@ void pvr_database_save(void); void pvrr_set_rec_state(pvr_rec_t *pvrr, pvrr_rec_status_t status); +void pvr_channel_record_op(th_channel_t *ch, int duration); + #endif /* PVR_H */