Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
EPG: implement fulltext search (title, subtitle, summary, description)
  • Loading branch information
perexg committed Jan 17, 2015
1 parent 3dba7bf commit 60f959b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/api/api_epg.c
Expand Up @@ -289,11 +289,12 @@ api_epg_grid
memset(&eq, 0, sizeof(eq));

lang = htsmsg_get_str(args, "lang");
eq.lang = lang ? strdup(lang) : NULL;

if (lang)
eq.lang = strdup(lang);
str = htsmsg_get_str(args, "title");
if (str)
eq.stitle = strdup(str);
eq.fulltext = htsmsg_get_bool_or_default(args, "fulltext", 0);
str = htsmsg_get_str(args, "channel");
if (str)
eq.channel = strdup(str);
Expand Down
27 changes: 21 additions & 6 deletions src/epg.c
Expand Up @@ -2263,6 +2263,7 @@ _eq_add ( epg_query_t *eq, epg_broadcast_t *e )
{
const char *s, *lang = eq->lang;
epg_episode_t *ep;
int fulltext = eq->stitle && eq->fulltext;

/* Filtering */
if (e == NULL) return;
Expand Down Expand Up @@ -2292,22 +2293,36 @@ _eq_add ( epg_query_t *eq, epg_broadcast_t *e )
}
if (!r) return;
}
if (eq->title.comp != EC_NO || eq->stitle) {
if (fulltext) {
if ((s = epg_episode_get_title(ep, lang)) == NULL ||
regexec(&eq->stitle_re, s, 0, NULL, 0)) {
if ((s = epg_episode_get_subtitle(ep, lang)) == NULL ||
regexec(&eq->stitle_re, s, 0, NULL, 0)) {
if ((s = epg_broadcast_get_summary(e, lang)) == NULL ||
regexec(&eq->stitle_re, s, 0, NULL, 0)) {
if ((s = epg_broadcast_get_description(e, lang)) == NULL ||
regexec(&eq->stitle_re, s, 0, NULL, 0)) {
return;
}
}
}
}
}
if (eq->title.comp != EC_NO || (eq->stitle && !fulltext)) {
if ((s = epg_episode_get_title(ep, lang)) == NULL) return;
if (eq->stitle)
if (regexec(&eq->stitle_re, s, 0, NULL, 0)) return;
if (_eq_comp_str(&eq->title, s)) return;
if (eq->stitle && !fulltext && regexec(&eq->stitle_re, s, 0, NULL, 0)) return;
if (eq->title.comp != EC_NO && _eq_comp_str(&eq->title, s)) return;
}
if (eq->subtitle.comp != EC_NO) {
if ((s = epg_episode_get_subtitle(ep, lang)) == NULL) return;
if (_eq_comp_str(&eq->subtitle, s)) return;
}
if (eq->summary.comp != EC_NO) {
if ((s = epg_episode_get_summary(ep, lang)) == NULL) return;
if ((s = epg_broadcast_get_summary(e, lang)) == NULL) return;
if (_eq_comp_str(&eq->summary, s)) return;
}
if (eq->description.comp != EC_NO) {
if ((s = epg_episode_get_description(ep, lang)) == NULL) return;
if ((s = epg_broadcast_get_description(e, lang)) == NULL) return;
if (_eq_comp_str(&eq->description, s)) return;
}

Expand Down
1 change: 1 addition & 0 deletions src/epg.h
Expand Up @@ -579,6 +579,7 @@ typedef struct epg_query {
epg_filter_num_t channel_num;
char *stitle;
regex_t stitle_re;
int fulltext;
char *channel;
char *channel_tag;
uint32_t genre_count;
Expand Down
19 changes: 18 additions & 1 deletion src/webui/static/app/epg.js
Expand Up @@ -562,6 +562,10 @@ tvheadend.epg = function() {
width: 200
});

var epgFilterFulltext = new Ext.form.Checkbox({
width: 20
});

// Channels, uses global store

var epgFilterChannels = new Ext.form.ComboBox({
Expand Down Expand Up @@ -662,6 +666,11 @@ tvheadend.epg = function() {
epgFilterTitle.setValue("");
};

clearFulltextFilter = function() {
delete epgStore.baseParams.fulltext;
epgFilterFulltext.setValue(0);
};

clearChannelFilter = function() {
delete epgStore.baseParams.channel;
epgFilterChannels.setValue("");
Expand All @@ -685,6 +694,7 @@ tvheadend.epg = function() {

function epgQueryClear() {
clearTitleFilter();
clearFulltextFilter();
clearChannelFilter();
clearChannelTagsFilter();
clearDurationFilter();
Expand Down Expand Up @@ -752,6 +762,13 @@ tvheadend.epg = function() {
}
});

epgFilterFulltext.on('check', function(c, value) {
if (epgStore.baseParams.fulltext !== value) {
epgStore.baseParams.fulltext = value;
epgView.reset();
}
});

var epgView = new Ext.ux.grid.livegrid.GridView({
nearLimit: 100,
loadMask: {
Expand All @@ -777,7 +794,7 @@ tvheadend.epg = function() {
});

var tbar = [
epgFilterTitle, '-',
epgFilterTitle, { text: 'Fulltext' }, epgFilterFulltext, '-',
epgFilterChannels, '-',
epgFilterChannelTags, '-',
epgFilterContentGroup, '-',
Expand Down

0 comments on commit 60f959b

Please sign in to comment.