WebUI: Add programme duration filtering

This commit is contained in:
Ian 2014-06-08 19:15:55 +01:00
parent 2b46f09231
commit c622dc9b1c
8 changed files with 77 additions and 40 deletions

View file

@ -133,6 +133,7 @@ api_epg_grid
//IH
int min_duration;
int max_duration;
//
*resp = htsmsg_create_map();
@ -147,6 +148,7 @@ api_epg_grid
//IH
min_duration = htsmsg_get_u32_or_default(args, "minduration", 0);
max_duration = htsmsg_get_u32_or_default(args, "maxduration", INT_MAX);
//
/* Pagination settings */
start = htsmsg_get_u32_or_default(args, "start", 0);

View file

@ -390,12 +390,15 @@ int dvr_sort_start_ascending(const void *A, const void *B);
*/
void dvr_autorec_add(const char *dvr_config_name,
const char *title, const char *channel,
const char *tag, epg_genre_t *content_type,
const char *creator, const char *comment);
const char *tag, epg_genre_t *content_type,
//IH
const int min_duration, const int max_duration,
//
const char *creator, const char *comment);
void dvr_autorec_add_series_link(const char *dvr_config_name,
epg_broadcast_t *event,
const char *creator, const char *comment);
const char *creator, const char *comment);
void dvr_autorec_check_event(epg_broadcast_t *e);
void dvr_autorec_check_brand(epg_brand_t *b);

View file

@ -26,6 +26,9 @@
#include <stdarg.h>
#include <errno.h>
#include <math.h>
//IH
#include <time.h>
//
#include "tvheadend.h"
#include "settings.h"
@ -71,7 +74,7 @@ autorec_cmp(dvr_autorec_entry_t *dae, epg_broadcast_t *e)
channel_tag_mapping_t *ctm;
dvr_config_t *cfg;
//IH
int duration;
double duration;
//
if (!e->channel) return 0;
@ -88,7 +91,7 @@ autorec_cmp(dvr_autorec_entry_t *dae, epg_broadcast_t *e)
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_maxduration == NULL &&
//
dae->dae_serieslink == NULL)
return 0; // Avoid super wildcard match
@ -144,7 +147,7 @@ autorec_cmp(dvr_autorec_entry_t *dae, epg_broadcast_t *e)
}
//IH
duration = &e->stop - &e->start;
duration = difftime(e->stop,e->start);
if(dae->dae_minduration) {
if(duration < dae->dae_minduration) return 0;
@ -303,27 +306,12 @@ autorec_record_build(dvr_autorec_entry_t *dae)
htsmsg_add_msg(e, "weekdays", l);
//IH
// This is where we add mindurationstring and maxdurationstring to the proceedings, I think
// Same question as to whether we deal with an offset, and absolute time (s), or the string.
// Increasingly, I think it should be the offset... although look at 'channel', above, that translates on the fly
//
// It also looks like we need to adjust dea to include the min/max fields (offset, absolute, string...)
// dvr_autorec_entry in dvr.h
// More thoughts...
//
// Channel group and contentype jus start from their base values (string/value
// as relevant). Start time (approx) does the same, but changes as soon as you
// select, so it isn't primed with the existing value - we could default to 0
// and max as well, 'you're changing it, here's the full range' sort of logic
//
// 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)
@ -448,7 +436,7 @@ 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
//IH Updated autorec entry
if(!htsmsg_get_u32(values, "minduration", &u32))
dae->dae_minduration = u32;
@ -555,7 +543,10 @@ dvr_autorec_update(void)
static void
_dvr_autorec_add(const char *config_name,
const char *title, channel_t *ch,
const char *tag, epg_genre_t *content_type,
const char *tag, epg_genre_t *content_type,
//IH
const int min_duration, const int max_duration,
//
epg_brand_t *brand, epg_season_t *season,
epg_serieslink_t *serieslink,
int approx_time, epg_episode_num_t *epnum,
@ -592,6 +583,14 @@ _dvr_autorec_add(const char *config_name,
if (content_type)
dae->dae_content_type.code = content_type->code;
//IH
if (min_duration)
dae->dae_minduration = min_duration;
if (max_duration)
dae->dae_maxduration = max_duration;
//
if(serieslink) {
serieslink->getref(serieslink);
dae->dae_serieslink = serieslink;
@ -613,12 +612,18 @@ _dvr_autorec_add(const char *config_name,
void
dvr_autorec_add(const char *config_name,
const char *title, const char *channel,
const char *tag, epg_genre_t *content_type,
const char *creator, const char *comment)
const char *tag, epg_genre_t *content_type,
//IH
const int min_duration, const int max_duration,
//
const char *creator, const char *comment)
{
channel_t *ch = NULL;
if(channel != NULL) ch = channel_find(channel);
_dvr_autorec_add(config_name, title, ch, tag, content_type,
//IH
min_duration, max_duration,
//
NULL, NULL, NULL, 0, NULL, creator, comment);
}
@ -633,6 +638,7 @@ void dvr_autorec_add_series_link
title,
event->channel,
NULL, 0, // tag/content type
0,INT_MAX,
NULL,
NULL,
event->serieslink,

View file

@ -23,6 +23,9 @@
#include <regex.h>
#include <assert.h>
#include <inttypes.h>
//IH
#include <time.h>
//
#include "tvheadend.h"
#include "queue.h"
@ -2210,7 +2213,7 @@ static void _eqr_add
epg_genre_t *genre, regex_t *preg, time_t start, const char *lang, int min_duration, int max_duration )
{
const char *title;
int duration;
double duration;
/* Ignore */
if ( e->stop < start ) return;
@ -2219,9 +2222,9 @@ static void _eqr_add
if ( preg && regexec(preg, title, 0, NULL, 0)) return;
//IH
duration = (int)e->stop - (int)e->start;
if ( duration < min_duration || duration > max_duration) return;
tvhtrace("epg", "Episode duration %d vs min_duration of %d and max_duration of %d", duration, min_duration, max_duration);
duration = difftime(e->stop,e->start);
// duration = (int)e->stop - (int)e->start;
if ( duration < min_duration || duration > max_duration ) return;
//
/* More space */

View file

@ -59,6 +59,7 @@
#include <sys/time.h>
//IH
#include <limits.h>
//
/* **************************************************************************
* Datatypes and variables
@ -1064,6 +1065,7 @@ htsp_method_epgQuery(htsp_connection_t *htsp, htsmsg_t *in)
//IH
int min_duration;
int max_duration;
//
/* Required */
if( (query = htsmsg_get_str(in, "query")) == NULL )

View file

@ -1134,18 +1134,38 @@ extjs_dvr(http_connection_t *hc, const char *remain, void *opaque)
htsmsg_add_u32(out, "success", 1);
} else if(!strcmp(op, "createAutoRec")) {
//IH
int min_duration;
int max_duration;
//
epg_genre_t genre, *eg = NULL;
if ((s = http_arg_get(&hc->hc_req_args, "contenttype"))) {
genre.code = atoi(s);
eg = &genre;
}
//IH
if((s = http_arg_get(&hc->hc_req_args, "minduration")) != NULL)
min_duration = atoi(s);
else
min_duration = 0;
if((s = http_arg_get(&hc->hc_req_args, "maxduration")) != NULL)
max_duration = atoi(s);
else
max_duration = INT_MAX;
//
dvr_autorec_add(http_arg_get(&hc->hc_req_args, "config_name"),
http_arg_get(&hc->hc_req_args, "title"),
http_arg_get(&hc->hc_req_args, "channel"),
http_arg_get(&hc->hc_req_args, "tag"),
eg,
hc->hc_representative, "Created from EPG query");
http_arg_get(&hc->hc_req_args, "channel"),
http_arg_get(&hc->hc_req_args, "tag"),
eg,
//IH
min_duration,max_duration,
//
hc->hc_representative, "Created from EPG query");
out = htsmsg_create_map();
htsmsg_add_u32(out, "success", 1);

View file

@ -90,7 +90,7 @@ page_simple(http_connection_t *hc,
//IH
// epg_query(&eqr, NULL, NULL, NULL, s, lang);
//IH Force all programme durations for this interface (0 to INT_MAX seconds)
//Note: force min/max durations for this interface to 0 and INT_MAX seconds respectively
epg_query(&eqr, NULL, NULL, NULL, s, lang, 0, INT_MAX);
epg_query_sort(&eqr);

View file

@ -455,7 +455,7 @@ tvheadend.epg = function() {
}
});
// Note: is there any way to seed the slider labels in one go, versus with specific lookups?
// Q: is there any way to seed the slider labels in one go, versus with specific lookups?
var durationSlider = new Ext.slider.MultiSlider({
width: 100,
@ -482,7 +482,8 @@ tvheadend.epg = function() {
//
function epgQueryClear() {
//IH - reset the pointers before deleting the underlying variables - otherwise they reset to 0/24h not null/null
//IH
// Reset the pointers before deleting the underlying variables - otherwise they reset to 0/24h not null/null
durationSlider.setValue(0,0);
durationSlider.setValue(1,7);
//
@ -524,7 +525,7 @@ tvheadend.epg = function() {
}
});
//IH ------------------
//IH
setduration = function(slider) {
var min = slider.getValue(0);
@ -581,7 +582,7 @@ tvheadend.epg = function() {
epgFilterContentGroup,
'-',
//IH
'Duration (test env): 0h ',
'Duration: 0h ',
durationSlider,
'24h','-',
//
@ -676,4 +677,4 @@ tvheadend.epg = function() {
}
return panel;
}
};