Allow autorecording to be created directly as a result of an EPG search query.
This commit is contained in:
parent
49787cd4a3
commit
3b3a8ce29d
9 changed files with 165 additions and 20 deletions
|
@ -159,4 +159,12 @@ void dvr_query(dvr_query_result_t *dqr);
|
|||
void dvr_query_free(dvr_query_result_t *dqr);
|
||||
void dvr_query_sort(dvr_query_result_t *dqr);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void dvr_autorec_add(const char *title, const char *channel,
|
||||
const char *tag, const char *contentgrp,
|
||||
const char *creator, const char *comment);
|
||||
|
||||
|
||||
#endif /* DVR_H */
|
||||
|
|
|
@ -26,9 +26,11 @@
|
|||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <regex.h>
|
||||
#include <libhts/htssettings.h>
|
||||
|
||||
#include "tvhead.h"
|
||||
#include "dvr.h"
|
||||
#include "notify.h"
|
||||
#include "dtable.h"
|
||||
#include "epg.h"
|
||||
|
||||
|
@ -240,7 +242,7 @@ autorec_record_update(void *opaque, const char *id, htsmsg_t *values,
|
|||
|
||||
if((dae = autorec_entry_find(id, maycreate)) == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
tvh_str_set(&dae->dae_creator, htsmsg_get_str(values, "creator"));
|
||||
tvh_str_set(&dae->dae_comment, htsmsg_get_str(values, "comment"));
|
||||
|
||||
|
@ -249,7 +251,7 @@ autorec_record_update(void *opaque, const char *id, htsmsg_t *values,
|
|||
LIST_REMOVE(dae, dae_channel_link);
|
||||
dae->dae_channel = NULL;
|
||||
}
|
||||
if((ch = channel_find_by_name(s, 0)) != NULL) {
|
||||
if((ch = channel_find_by_name(s, 0)) != NULL) {
|
||||
LIST_INSERT_HEAD(&ch->ch_autorecs, dae, dae_channel_link);
|
||||
dae->dae_channel = ch;
|
||||
}
|
||||
|
@ -324,3 +326,53 @@ dvr_autorec_init(void)
|
|||
dt = dtable_create(&autorec_dtc, "autorec", NULL);
|
||||
dtable_load(dt);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void
|
||||
dvr_autorec_add(const char *title, const char *channel,
|
||||
const char *tag, const char *cgrp,
|
||||
const char *creator, const char *comment)
|
||||
{
|
||||
dvr_autorec_entry_t *dae;
|
||||
htsmsg_t *m;
|
||||
channel_t *ch;
|
||||
channel_tag_t *ct;
|
||||
|
||||
if((dae = autorec_entry_find(NULL, 1)) == NULL)
|
||||
return;
|
||||
|
||||
tvh_str_set(&dae->dae_creator, creator);
|
||||
tvh_str_set(&dae->dae_comment, comment);
|
||||
|
||||
if(channel != NULL && (ch = channel_find_by_name(channel, 0)) != NULL) {
|
||||
LIST_INSERT_HEAD(&ch->ch_autorecs, dae, dae_channel_link);
|
||||
dae->dae_channel = ch;
|
||||
}
|
||||
|
||||
if(title != NULL &&
|
||||
!regcomp(&dae->dae_title_preg, title,
|
||||
REG_ICASE | REG_EXTENDED | REG_NOSUB)) {
|
||||
dae->dae_title = strdup(title);
|
||||
}
|
||||
|
||||
if(tag != NULL && (ct = channel_tag_find_by_name(tag)) != NULL) {
|
||||
LIST_INSERT_HEAD(&ct->ct_autorecs, dae, dae_channel_tag_link);
|
||||
dae->dae_channel_tag = ct;
|
||||
}
|
||||
|
||||
dae->dae_ecg = cgrp ? epg_content_group_find_by_name(cgrp) : NULL;
|
||||
dae->dae_enabled = 1;
|
||||
|
||||
m = autorec_record_build(dae);
|
||||
hts_settings_save(m, "%s/%s", "autorec", dae->dae_id);
|
||||
htsmsg_destroy(m);
|
||||
|
||||
/* Notify web clients that we have messed with the tables */
|
||||
|
||||
m = htsmsg_create();
|
||||
htsmsg_add_u32(m, "asyncreload", 1);
|
||||
notify_by_msg("autorec", m);
|
||||
}
|
||||
|
|
|
@ -961,6 +961,17 @@ extjs_dvr(http_connection_t *hc, const char *remain, void *opaque)
|
|||
out = htsmsg_create();
|
||||
htsmsg_add_u32(out, "success", 1);
|
||||
|
||||
} else if(!strcmp(op, "createAutoRec")) {
|
||||
|
||||
dvr_autorec_add(http_arg_get(&hc->hc_req_args, "title"),
|
||||
http_arg_get(&hc->hc_req_args, "channel"),
|
||||
http_arg_get(&hc->hc_req_args, "tag"),
|
||||
http_arg_get(&hc->hc_req_args, "contentgrp"),
|
||||
hc->hc_representative, "Created from EPG query");
|
||||
|
||||
out = htsmsg_create();
|
||||
htsmsg_add_u32(out, "success", 1);
|
||||
|
||||
} else if(!strcmp(op, "loadSettings")) {
|
||||
|
||||
r = htsmsg_create();
|
||||
|
|
|
@ -185,6 +185,25 @@ tvheadend.dvrlog = function() {
|
|||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
tvheadend.autorecRecord = Ext.data.Record.create([
|
||||
'enabled','title','channel','tag','creator','contentgrp','comment'
|
||||
]);
|
||||
|
||||
|
||||
tvheadend.autorecStore = new Ext.data.JsonStore({
|
||||
root: 'entries',
|
||||
fields: tvheadend.autorecRecord,
|
||||
url: "tablemgr",
|
||||
autoLoad: true,
|
||||
id: 'id',
|
||||
baseParams: {table: "autorec", op: "get"}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -239,7 +258,7 @@ tvheadend.autoreceditor = function() {
|
|||
})
|
||||
|
||||
},{
|
||||
header: "Creator",
|
||||
header: "Created by",
|
||||
dataIndex: 'creator',
|
||||
editor: new fm.TextField({allowBlank: false})
|
||||
},{
|
||||
|
@ -249,15 +268,10 @@ tvheadend.autoreceditor = function() {
|
|||
}
|
||||
]);
|
||||
|
||||
var rec = Ext.data.Record.create([
|
||||
'enabled','title','channel','tag','creator','contentgrp','comment'
|
||||
]);
|
||||
|
||||
return new tvheadend.tableEditor('Automatic Recorder',
|
||||
'autorec', cm, rec,
|
||||
[enabledColumn]);
|
||||
|
||||
|
||||
'autorec', cm, tvheadend.autorecRecord,
|
||||
[enabledColumn], tvheadend.autorecStore);
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -266,6 +266,15 @@ tvheadend.epg = function() {
|
|||
{
|
||||
text: 'Reset',
|
||||
handler: epgQueryClear
|
||||
},
|
||||
'->',
|
||||
{
|
||||
text: 'Create AutoRec',
|
||||
iconCls: 'rec',
|
||||
tooltip: 'Create an automatic recording entry that will ' +
|
||||
'record all future programmes that matches ' +
|
||||
'the current query.',
|
||||
handler: createAutoRec
|
||||
}
|
||||
],
|
||||
|
||||
|
@ -286,6 +295,44 @@ tvheadend.epg = function() {
|
|||
new tvheadend.epgDetails(grid.getStore().getAt(index).data);
|
||||
}
|
||||
|
||||
function createAutoRec() {
|
||||
|
||||
var title = epgStore.baseParams.title ?
|
||||
epgStore.baseParams.title : "<i>Don't care</i>";
|
||||
var channel = epgStore.baseParams.channel ?
|
||||
epgStore.baseParams.channel : "<i>Don't care</i>";
|
||||
var tag = epgStore.baseParams.tag ?
|
||||
epgStore.baseParams.tag : "<i>Don't care</i>";
|
||||
var contentgrp = epgStore.baseParams.contentgrp ?
|
||||
epgStore.baseParams.contentgrp : "<i>Don't care</i>";
|
||||
|
||||
Ext.MessageBox.confirm('Auto Recorder',
|
||||
'This will create an automatic rule that ' +
|
||||
'continously scans the EPG for programmes ' +
|
||||
'to recrod that matches this query: ' +
|
||||
'<br><br>' +
|
||||
'<div class="x-smallhdr">Title:</div>' + title + '<br>' +
|
||||
'<div class="x-smallhdr">Channel:</div>' + channel + '<br>' +
|
||||
'<div class="x-smallhdr">Tag:</div>' + tag + '<br>' +
|
||||
'<div class="x-smallhdr">Content Group:</div>' + contentgrp + '<br>' +
|
||||
'<br>' +
|
||||
'Currently this will match (and record) ' +
|
||||
epgStore.getTotalCount() + ' events. ' +
|
||||
'Are you sure?',
|
||||
|
||||
function(button) {
|
||||
if(button == 'no')
|
||||
return;
|
||||
createAutoRec2(epgStore.baseParams);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function createAutoRec2(params) {
|
||||
/* Really do it */
|
||||
params.op = 'createAutoRec';
|
||||
Ext.Ajax.request({url: '/dvr', params: params});
|
||||
}
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
|
|
@ -98,7 +98,14 @@
|
|||
.save {
|
||||
background-image:url(../icons/save.gif) !important;
|
||||
}
|
||||
.rec {
|
||||
background-image:url(../icons/rec.png) !important;
|
||||
}
|
||||
|
||||
.x-smallhdr {
|
||||
float:left;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.x-epg-title {
|
||||
margin: 5px;
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
tvheadend.tableEditor = function(title, dtable, cm, rec, plugins) {
|
||||
tvheadend.tableEditor = function(title, dtable, cm, rec, plugins, store) {
|
||||
cm.defaultSortable = true;
|
||||
|
||||
var store = new Ext.data.JsonStore({
|
||||
root: 'entries',
|
||||
fields: rec,
|
||||
url: "tablemgr",
|
||||
autoLoad: true,
|
||||
id: 'id',
|
||||
baseParams: {table: dtable, op: "get"}
|
||||
});
|
||||
|
||||
if(store == null) {
|
||||
store = new Ext.data.JsonStore({
|
||||
root: 'entries',
|
||||
fields: rec,
|
||||
url: "tablemgr",
|
||||
autoLoad: true,
|
||||
id: 'id',
|
||||
baseParams: {table: dtable, op: "get"}
|
||||
});
|
||||
}
|
||||
|
||||
function addRecord() {
|
||||
Ext.Ajax.request({
|
||||
|
|
|
@ -19,6 +19,11 @@ tvheadend.comet_poller = function() {
|
|||
tvheadend.channelTags.reload();
|
||||
break;
|
||||
|
||||
case 'autorec':
|
||||
if(m.asyncreload != null)
|
||||
tvheadend.autorecStore.reload();
|
||||
break;
|
||||
|
||||
case 'dvrdb':
|
||||
if(m.reload != null)
|
||||
tvheadend.dvrStore.reload();
|
||||
|
|
BIN
webui/static/icons/rec.png
Normal file
BIN
webui/static/icons/rec.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 828 B |
Loading…
Add table
Reference in a new issue