WebUI: Add programme duration filtering
This commit is contained in:
parent
32ed32e4a4
commit
2b46f09231
6 changed files with 104 additions and 49 deletions
|
@ -247,6 +247,10 @@ typedef struct dvr_autorec_entry {
|
|||
epg_serieslink_t *dae_serieslink;
|
||||
epg_episode_num_t dae_epnum;
|
||||
|
||||
//IH
|
||||
int dae_minduration;
|
||||
int dae_maxduration;
|
||||
//
|
||||
} dvr_autorec_entry_t;
|
||||
|
||||
|
||||
|
|
|
@ -70,6 +70,9 @@ autorec_cmp(dvr_autorec_entry_t *dae, epg_broadcast_t *e)
|
|||
{
|
||||
channel_tag_mapping_t *ctm;
|
||||
dvr_config_t *cfg;
|
||||
//IH
|
||||
int duration;
|
||||
//
|
||||
|
||||
if (!e->channel) return 0;
|
||||
if (!e->episode) return 0;
|
||||
|
@ -83,6 +86,10 @@ autorec_cmp(dvr_autorec_entry_t *dae, epg_broadcast_t *e)
|
|||
dae->dae_title[0] == '\0') &&
|
||||
dae->dae_brand == NULL &&
|
||||
dae->dae_season == NULL &&
|
||||
//IH
|
||||
&dae->dae_minduration == NULL &&
|
||||
&dae->dae_maxduration == NULL && //IH Think about whether we should be testing INT_MAX here
|
||||
//
|
||||
dae->dae_serieslink == NULL)
|
||||
return 0; // Avoid super wildcard match
|
||||
|
||||
|
@ -135,7 +142,19 @@ autorec_cmp(dvr_autorec_entry_t *dae, epg_broadcast_t *e)
|
|||
if(abs(mktime(&a_time) - mktime(&ev_time)) > 900)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//IH
|
||||
duration = &e->stop - &e->start;
|
||||
|
||||
if(dae->dae_minduration) {
|
||||
if(duration < dae->dae_minduration) return 0;
|
||||
}
|
||||
|
||||
if(dae->dae_maxduration) {
|
||||
if(duration > dae->dae_maxduration) return 0;
|
||||
}
|
||||
//
|
||||
|
||||
if(dae->dae_weekdays != 0x7f) {
|
||||
struct tm tm;
|
||||
localtime_r(&e->start, &tm);
|
||||
|
@ -300,7 +319,11 @@ autorec_record_build(dvr_autorec_entry_t *dae)
|
|||
//
|
||||
// This way I don't care what it's set to beyond the string value for
|
||||
// initial display purposes
|
||||
|
||||
if (dae->dae_minduration)
|
||||
htsmsg_add_u32(e, "minduration", dae->dae_minduration);
|
||||
if (dae->dae_maxduration)
|
||||
htsmsg_add_u32(e, "maxduration", dae->dae_maxduration);
|
||||
//
|
||||
htsmsg_add_str(e, "pri", dvr_val2pri(dae->dae_pri));
|
||||
|
||||
if (dae->dae_brand)
|
||||
|
@ -425,6 +448,14 @@ autorec_record_update(void *opaque, const char *id, htsmsg_t *values,
|
|||
}
|
||||
}
|
||||
|
||||
//IH Need to put something in here that triggers when we update min/max in the autorec rule
|
||||
if(!htsmsg_get_u32(values, "minduration", &u32))
|
||||
dae->dae_minduration = u32;
|
||||
|
||||
if(!htsmsg_get_u32(values, "maxduration", &u32))
|
||||
dae->dae_maxduration = u32;
|
||||
//
|
||||
|
||||
if((l = htsmsg_get_list(values, "weekdays")) != NULL)
|
||||
dae->dae_weekdays = build_weekday_mask(l);
|
||||
|
||||
|
|
|
@ -2221,7 +2221,7 @@ static void _eqr_add
|
|||
//IH
|
||||
duration = (int)e->stop - (int)e->start;
|
||||
if ( duration < min_duration || duration > max_duration) return;
|
||||
tvhlog(LOG_INFO, "_eqr_add", "episode duration %d vs min_duration %d and max_duration %d", duration, min_duration, max_duration);
|
||||
tvhtrace("epg", "Episode duration %d vs min_duration of %d and max_duration of %d", duration, min_duration, max_duration);
|
||||
//
|
||||
|
||||
/* More space */
|
||||
|
|
|
@ -1087,7 +1087,7 @@ htsp_method_epgQuery(htsp_connection_t *htsp, htsmsg_t *in)
|
|||
//IH
|
||||
min_duration = htsmsg_get_u32_or_default(in, "minduration", 0);
|
||||
max_duration = htsmsg_get_u32_or_default(in, "maxduration", INT_MAX);
|
||||
tvhlog(LOG_INFO, "htsp_server", "min_duration %d and max_duration %d", min_duration, max_duration);
|
||||
tvhtrace("htsp", "min_duration %d and max_duration %d", min_duration, max_duration);
|
||||
//
|
||||
|
||||
/* Check access */
|
||||
|
|
|
@ -547,12 +547,15 @@ tvheadend.autoreceditor = function() {
|
|||
triggerAction: 'all',
|
||||
emptyText: 'Only include channel...'
|
||||
}),
|
||||
renderer: function(v, m, r) {
|
||||
var i = tvheadend.channels.find('key', v);
|
||||
if (i !== -1)
|
||||
v = tvheadend.channels.getAt(i).get('val');
|
||||
return v;
|
||||
}
|
||||
renderer: function(v) {
|
||||
return tvheadend.channelLookupName(v);
|
||||
},
|
||||
// renderer: function(v, m, r) {
|
||||
// var i = tvheadend.channels.find('key', v);
|
||||
// if (i !== -1)
|
||||
// v = tvheadend.channels.getAt(i).get('val');
|
||||
// return v;
|
||||
// }
|
||||
},
|
||||
{
|
||||
header: "SeriesLink",
|
||||
|
@ -590,30 +593,37 @@ tvheadend.autoreceditor = function() {
|
|||
})
|
||||
},
|
||||
// IH
|
||||
|
||||
// This will now bring through the real limit (i.e. seconds). We can look that up from the Store to turn it into an index
|
||||
// or into a string equivalent, and populate the combobox with the same values so it will automatically match
|
||||
// see epg.js for the lookup/conversion code
|
||||
|
||||
{
|
||||
header: "Min"
|
||||
/*dataIndex: minduration,
|
||||
editor: new Ext.ux.form.ComboBox({
|
||||
header: "Min. Duration",
|
||||
dataIndex: 'minduration',
|
||||
width: 75,
|
||||
renderer: function(v) {
|
||||
return tvheadend.durationLookupName(v);
|
||||
},
|
||||
editor: new Ext.form.ComboBox({
|
||||
store: tvheadend.DurationStore,
|
||||
mode: 'local',
|
||||
valueField: 'value',
|
||||
displayField: 'label'
|
||||
})*/
|
||||
},
|
||||
{
|
||||
header: "Max"
|
||||
/*dataIndex: maxduration
|
||||
editor: new Ext.ux.form.ComboBox({
|
||||
displayField: 'label',
|
||||
editable: false,
|
||||
triggerAction: 'all',
|
||||
})
|
||||
},
|
||||
{
|
||||
header: "Max. Duration",
|
||||
dataIndex: 'maxduration',
|
||||
width: 75,
|
||||
renderer: function(v) {
|
||||
return tvheadend.durationLookupName(v);
|
||||
},
|
||||
editor: new Ext.form.ComboBox({
|
||||
store: tvheadend.DurationStore,
|
||||
mode: 'local',
|
||||
valueField: 'value',
|
||||
displayField: 'label'
|
||||
})*/
|
||||
displayField: 'label',
|
||||
editable: false,
|
||||
triggerAction: 'all'
|
||||
})
|
||||
},
|
||||
//
|
||||
{
|
||||
|
@ -814,7 +824,7 @@ tvheadend.dvr = function() {
|
|||
tvheadend.autorecRecord = Ext.data.Record.create(['enabled', 'title',
|
||||
'serieslink', 'channel', 'tag', 'creator', 'contenttype', 'comment',
|
||||
//IH
|
||||
'mindurationstring', 'maxdurationstring',
|
||||
'minduration', 'maxduration',
|
||||
//
|
||||
'weekdays', 'pri', 'approx_time', 'config_name']);
|
||||
|
||||
|
|
|
@ -30,6 +30,28 @@ tvheadend.contentGroupLookupName = function(code) {
|
|||
tvheadend.ContentGroupStore.setDefaultSort('code', 'ASC');
|
||||
|
||||
//IH
|
||||
tvheadend.channelLookupName = function(key) {
|
||||
channelString = "";
|
||||
|
||||
var index = tvheadend.channels.find('key', key);
|
||||
|
||||
if (index !== -1)
|
||||
var channelString = tvheadend.channels.getAt(index).get('val');
|
||||
|
||||
return channelString;
|
||||
};
|
||||
|
||||
tvheadend.durationLookupName = function(value) {
|
||||
durationString = "";
|
||||
|
||||
var index = tvheadend.DurationStore.find('value', value);
|
||||
|
||||
if (index !== -1)
|
||||
var durationString = tvheadend.DurationStore.getById(index).data.label;
|
||||
|
||||
return durationString;
|
||||
};
|
||||
|
||||
tvheadend.DurationStore = new Ext.data.SimpleStore({
|
||||
storeId: 'durations',
|
||||
id: 0,
|
||||
|
@ -506,22 +528,15 @@ tvheadend.epg = function() {
|
|||
setduration = function(slider) {
|
||||
|
||||
var min = slider.getValue(0);
|
||||
var max = slider.getValue(1);
|
||||
var minRec = tvheadend.DurationStore.getById(min);
|
||||
|
||||
epgStore.baseParams.minduration = minRec.data.value;
|
||||
|
||||
var max = slider.getValue(1);
|
||||
var maxRec = tvheadend.DurationStore.getById(max);
|
||||
|
||||
epgStore.baseParams.minduration = minRec.data.value;
|
||||
epgStore.baseParams.maxduration = maxRec.data.value;
|
||||
|
||||
//Debugging to test set and lookup
|
||||
var index = tvheadend.DurationStore.find( 'value', epgStore.baseParams.minduration );
|
||||
var string = tvheadend.DurationStore.getById(index).data.label;
|
||||
console.log('Min Duration record:', index, 'string:', string);
|
||||
|
||||
var index = tvheadend.DurationStore.find( 'value', epgStore.baseParams.maxduration );
|
||||
var string = tvheadend.DurationStore.getById(index).data.label;
|
||||
console.log('Max Duration record:', index, 'string:', string);
|
||||
//
|
||||
epgStore.reload();
|
||||
};
|
||||
//
|
||||
|
@ -612,7 +627,9 @@ tvheadend.epg = function() {
|
|||
|
||||
var title = epgStore.baseParams.title ? epgStore.baseParams.title
|
||||
: "<i>Don't care</i>";
|
||||
var channel = epgStore.baseParams.channel ? epgStore.baseParams.channel
|
||||
//IH - correct to display content type as a string as opposed to the underlying (lookup) code
|
||||
var channel = epgStore.baseParams.channel ? tvheadend.channelLookupName(epgStore.baseParams.channel)
|
||||
//
|
||||
: "<i>Don't care</i>";
|
||||
var tag = epgStore.baseParams.tag ? epgStore.baseParams.tag
|
||||
: "<i>Don't care</i>";
|
||||
|
@ -621,9 +638,9 @@ tvheadend.epg = function() {
|
|||
//
|
||||
: "<i>Don't care</i>";
|
||||
//IH
|
||||
var minduration = epgStore.baseParams.minduration ? tvheadend.DurationStore.getById(tvheadend.DurationStore.find('value', epgStore.baseParams.minduration)).data.label
|
||||
var minduration = epgStore.baseParams.minduration ? tvheadend.durationLookupName(epgStore.baseParams.minduration)
|
||||
: "<i>Don't care</i>";
|
||||
var maxduration = epgStore.baseParams.maxduration ? tvheadend.DurationStore.getById(tvheadend.DurationStore.find('value', epgStore.baseParams.maxduration)).data.label
|
||||
var maxduration = epgStore.baseParams.maxduration ? tvheadend.durationLookupName(epgStore.baseParams.maxduration)
|
||||
: "<i>Don't care</i>";
|
||||
//
|
||||
|
||||
|
@ -649,13 +666,6 @@ tvheadend.epg = function() {
|
|||
});
|
||||
}
|
||||
|
||||
//
|
||||
// IH: TO DO
|
||||
//
|
||||
// Check that contenttype is still passed correctly (epgStore.baseParams.contenttype) to autorec vs the new contenttypestring - SHOULDN'T HAVE CHANGED
|
||||
// Add min/max to autorec rules (C)
|
||||
// Check they're displayed (js)
|
||||
//
|
||||
function createAutoRec2(params) {
|
||||
/* Really do it */
|
||||
params.op = 'createAutoRec';
|
||||
|
|
Loading…
Add table
Reference in a new issue