Updated configuration to include epggrab channel update settings, also added sensible default for first run.
This commit is contained in:
parent
9095f6e797
commit
57928c30b1
4 changed files with 224 additions and 74 deletions
101
src/epggrab.c
101
src/epggrab.c
|
@ -32,6 +32,9 @@ pthread_cond_t epggrab_cond;
|
|||
uint32_t epggrab_interval;
|
||||
epggrab_module_t* epggrab_module;
|
||||
epggrab_module_list_t epggrab_modules;
|
||||
uint32_t epggrab_channel_rename;
|
||||
uint32_t epggrab_channel_renumber;
|
||||
uint32_t epggrab_channel_reicon;
|
||||
|
||||
/* **************************************************************************
|
||||
* Helpers
|
||||
|
@ -234,9 +237,12 @@ static int _ch_link ( epggrab_channel_t *ec, channel_t *ch )
|
|||
tvhlog(LOG_INFO, ec->mod->id, "linking %s to %s",
|
||||
ec->id, ch->ch_name);
|
||||
ec->channel = ch;
|
||||
if (ec->name) channel_rename(ch, ec->name);
|
||||
if (ec->icon) channel_set_icon(ch, ec->icon);
|
||||
if (ec->number>0) channel_set_number(ch, ec->number);
|
||||
if (ec->name && epggrab_channel_rename)
|
||||
channel_rename(ch, ec->name);
|
||||
if (ec->icon && epggrab_channel_reicon)
|
||||
channel_set_icon(ch, ec->icon);
|
||||
if (ec->number>0 && epggrab_channel_renumber)
|
||||
channel_set_number(ch, ec->number);
|
||||
}
|
||||
|
||||
return match;
|
||||
|
@ -651,6 +657,9 @@ static void _epggrab_load ( void )
|
|||
|
||||
/* Process */
|
||||
if (m) {
|
||||
htsmsg_get_u32(m, "channel_rename", &epggrab_channel_rename);
|
||||
htsmsg_get_u32(m, "channel_renumber", &epggrab_channel_renumber);
|
||||
htsmsg_get_u32(m, "channel_reicon", &epggrab_channel_reicon);
|
||||
if (!htsmsg_get_u32(m, old ? "grab-interval" : "interval", &epggrab_interval))
|
||||
if (old) epggrab_interval *= 3600;
|
||||
htsmsg_get_u32(m, "grab-enabled", &enabled);
|
||||
|
@ -666,35 +675,44 @@ static void _epggrab_load ( void )
|
|||
}
|
||||
}
|
||||
htsmsg_destroy(m);
|
||||
}
|
||||
|
||||
/* Finish up migration */
|
||||
if (old) {
|
||||
htsmsg_field_t *f;
|
||||
htsmsg_t *xc, *ch;
|
||||
htsmsg_t *xchs = hts_settings_load("xmltv/channels");
|
||||
htsmsg_t *chs = hts_settings_load("channels");
|
||||
if (xchs) {
|
||||
HTSMSG_FOREACH(f, chs) {
|
||||
if ((ch = htsmsg_get_map_by_field(f))) {
|
||||
if ((str = htsmsg_get_str(ch, "xmltv-channel"))) {
|
||||
if ((xc = htsmsg_get_map(xchs, str))) {
|
||||
htsmsg_add_u32(xc, "channel", atoi(f->hmf_name));
|
||||
/* Finish up migration */
|
||||
if (old) {
|
||||
htsmsg_field_t *f;
|
||||
htsmsg_t *xc, *ch;
|
||||
htsmsg_t *xchs = hts_settings_load("xmltv/channels");
|
||||
htsmsg_t *chs = hts_settings_load("channels");
|
||||
if (xchs) {
|
||||
HTSMSG_FOREACH(f, chs) {
|
||||
if ((ch = htsmsg_get_map_by_field(f))) {
|
||||
if ((str = htsmsg_get_str(ch, "xmltv-channel"))) {
|
||||
if ((xc = htsmsg_get_map(xchs, str))) {
|
||||
htsmsg_add_u32(xc, "channel", atoi(f->hmf_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HTSMSG_FOREACH(f, xchs) {
|
||||
if ((xc = htsmsg_get_map_by_field(f))) {
|
||||
hts_settings_save(xc, "epggrab/xmltv/channels/%s", f->hmf_name);
|
||||
HTSMSG_FOREACH(f, xchs) {
|
||||
if ((xc = htsmsg_get_map_by_field(f))) {
|
||||
hts_settings_save(xc, "epggrab/xmltv/channels/%s", f->hmf_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Save epggrab config */
|
||||
epggrab_save();
|
||||
}
|
||||
|
||||
/* Save epggrab config */
|
||||
epggrab_save();
|
||||
/* Defaults */
|
||||
} else {
|
||||
epggrab_module_t *m;
|
||||
epggrab_interval = 12 * 3600; // hours
|
||||
epggrab_module = NULL; // disabled
|
||||
LIST_FOREACH(m, &epggrab_modules, link) // enable all OTA by default
|
||||
if (m->flags & EPGGRAB_MODULE_OTA)
|
||||
epggrab_enable_module(m, 1);
|
||||
}
|
||||
|
||||
|
||||
/* Load module config (channels) */
|
||||
eit_load();
|
||||
xmltv_load();
|
||||
|
@ -713,6 +731,9 @@ void epggrab_save ( void )
|
|||
|
||||
/* Save */
|
||||
m = htsmsg_create_map();
|
||||
htsmsg_add_u32(m, "channel_rename", epggrab_channel_rename);
|
||||
htsmsg_add_u32(m, "channel_renumber", epggrab_channel_renumber);
|
||||
htsmsg_add_u32(m, "channel_reicon", epggrab_channel_reicon);
|
||||
htsmsg_add_u32(m, "interval", epggrab_interval);
|
||||
if ( epggrab_module )
|
||||
htsmsg_add_str(m, "module", epggrab_module->id);
|
||||
|
@ -760,6 +781,36 @@ int epggrab_set_module_by_id ( const char *id )
|
|||
return epggrab_set_module(epggrab_module_find_by_id(id));
|
||||
}
|
||||
|
||||
int epggrab_set_channel_rename ( uint32_t e )
|
||||
{
|
||||
int save = 0;
|
||||
if ( e != epggrab_channel_rename ) {
|
||||
epggrab_channel_rename = e;
|
||||
save = 1;
|
||||
}
|
||||
return save;
|
||||
}
|
||||
|
||||
int epggrab_set_channel_renumber ( uint32_t e )
|
||||
{
|
||||
int save = 0;
|
||||
if ( e != epggrab_channel_renumber ) {
|
||||
epggrab_channel_renumber = e;
|
||||
save = 1;
|
||||
}
|
||||
return save;
|
||||
}
|
||||
|
||||
int epggrab_set_channel_reicon ( uint32_t e )
|
||||
{
|
||||
int save = 0;
|
||||
if ( e != epggrab_channel_reicon ) {
|
||||
epggrab_channel_reicon = e;
|
||||
save = 1;
|
||||
}
|
||||
return save;
|
||||
}
|
||||
|
||||
int epggrab_enable_module ( epggrab_module_t *mod, uint8_t e )
|
||||
{
|
||||
int save = 0;
|
||||
|
@ -786,10 +837,6 @@ int epggrab_enable_module_by_id ( const char *id, uint8_t e )
|
|||
*/
|
||||
void epggrab_init ( void )
|
||||
{
|
||||
/* Defaults */
|
||||
epggrab_interval = 12 * 3600; // hours
|
||||
epggrab_module = NULL; // disabled
|
||||
|
||||
/* Initialise modules */
|
||||
eit_init(&epggrab_modules);
|
||||
xmltv_init(&epggrab_modules);
|
||||
|
|
|
@ -163,19 +163,25 @@ htsmsg_t* epggrab_module_list ( void );
|
|||
/*
|
||||
* Configuration
|
||||
*/
|
||||
extern pthread_mutex_t epggrab_mutex;
|
||||
extern uint32_t epggrab_interval;
|
||||
extern epggrab_module_t* epggrab_module;
|
||||
extern pthread_mutex_t epggrab_mutex;
|
||||
extern uint32_t epggrab_interval;
|
||||
extern epggrab_module_t* epggrab_module;
|
||||
extern uint32_t epggrab_channel_rename;
|
||||
extern uint32_t epggrab_channel_renumber;
|
||||
extern uint32_t epggrab_channel_reicon;
|
||||
|
||||
/*
|
||||
* Update
|
||||
*/
|
||||
int epggrab_set_interval ( uint32_t interval );
|
||||
int epggrab_set_module ( epggrab_module_t *module );
|
||||
int epggrab_set_module_by_id ( const char *id );
|
||||
int epggrab_enable_module ( epggrab_module_t *module, uint8_t e );
|
||||
int epggrab_enable_module_by_id ( const char *id, uint8_t e );
|
||||
void epggrab_save ( void );
|
||||
int epggrab_set_interval ( uint32_t interval );
|
||||
int epggrab_set_module ( epggrab_module_t *module );
|
||||
int epggrab_set_module_by_id ( const char *id );
|
||||
int epggrab_set_channel_rename ( uint32_t e );
|
||||
int epggrab_set_channel_renumber ( uint32_t e );
|
||||
int epggrab_set_channel_reicon ( uint32_t e );
|
||||
int epggrab_enable_module ( epggrab_module_t *module, uint8_t e );
|
||||
int epggrab_enable_module_by_id ( const char *id, uint8_t e );
|
||||
void epggrab_save ( void );
|
||||
|
||||
/* **************************************************************************
|
||||
* Global Functions
|
||||
|
|
|
@ -489,6 +489,9 @@ extjs_epggrab(http_connection_t *hc, const char *remain, void *opaque)
|
|||
if (epggrab_module)
|
||||
htsmsg_add_str(r, "module", epggrab_module->id);
|
||||
htsmsg_add_u32(r, "interval", epggrab_interval);
|
||||
htsmsg_add_u32(r, "channel_rename", epggrab_channel_rename);
|
||||
htsmsg_add_u32(r, "channel_renumber", epggrab_channel_renumber);
|
||||
htsmsg_add_u32(r, "channel_reicon", epggrab_channel_reicon);
|
||||
pthread_mutex_unlock(&epggrab_mutex);
|
||||
|
||||
out = json_single_record(r, "epggrabSettings");
|
||||
|
@ -513,6 +516,12 @@ extjs_epggrab(http_connection_t *hc, const char *remain, void *opaque)
|
|||
} else if (!strcmp(op, "saveSettings") ) {
|
||||
int save = 0;
|
||||
pthread_mutex_lock(&epggrab_mutex);
|
||||
str = http_arg_get(&hc->hc_req_args, "channel_rename");
|
||||
save |= epggrab_set_channel_rename(str ? 1 : 0);
|
||||
str = http_arg_get(&hc->hc_req_args, "channel_renumber");
|
||||
save |= epggrab_set_channel_renumber(str ? 1 : 0);
|
||||
str = http_arg_get(&hc->hc_req_args, "channel_reicon");
|
||||
save |= epggrab_set_channel_reicon(str ? 1 : 0);
|
||||
if ( (str = http_arg_get(&hc->hc_req_args, "interval")) )
|
||||
save |= epggrab_set_interval(atoi(str));
|
||||
if ( (str = http_arg_get(&hc->hc_req_args, "module")) )
|
||||
|
|
|
@ -48,15 +48,29 @@ tvheadend.epggrab = function() {
|
|||
moduleStore.each(function(r) {
|
||||
otaModuleStore.add(r.copy());
|
||||
});
|
||||
moduleStore.filterBy(function(r) {
|
||||
return r.get('flags') & (EPGGRAB_MODULE_OTA | EPGGRAB_MODULE_EXTERNAL);
|
||||
});
|
||||
});
|
||||
|
||||
/* Enable module in one of the stores (will auto update primary) */
|
||||
function moduleSelect ( r, e )
|
||||
{
|
||||
r.set('enabled', e);
|
||||
t = moduleStore.getById(r.id);
|
||||
if (t) t.set('enabled', e);
|
||||
}
|
||||
|
||||
/*
|
||||
* Basic Config
|
||||
*/
|
||||
|
||||
var confreader = new Ext.data.JsonReader(
|
||||
{ root: 'epggrabSettings' },
|
||||
[ 'module', 'interval' ]
|
||||
[
|
||||
'module', 'interval',
|
||||
'channel_rename', 'channel_renumber', 'channel_reicon',
|
||||
]
|
||||
);
|
||||
|
||||
/* ****************************************************************
|
||||
|
@ -145,10 +159,49 @@ tvheadend.epggrab = function() {
|
|||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Channel handling
|
||||
*/
|
||||
var channelRename = new Ext.form.Checkbox({
|
||||
name : 'channel_rename',
|
||||
fieldLabel : 'Update channel name',
|
||||
});
|
||||
|
||||
var channelRenumber = new Ext.form.Checkbox({
|
||||
name : 'channel_renumber',
|
||||
fieldLabel : 'Update channel number',
|
||||
});
|
||||
|
||||
var channelReicon = new Ext.form.Checkbox({
|
||||
name : 'channel_reicon',
|
||||
fieldLabel : 'Update channel icon'
|
||||
});
|
||||
|
||||
/*
|
||||
* Simple fieldet
|
||||
*/
|
||||
var simplePanel = new Ext.form.FieldSet({
|
||||
title : 'Basic Config',
|
||||
width : 800,
|
||||
autoHeight : true,
|
||||
collapsible : true,
|
||||
items : [
|
||||
interval,
|
||||
internalModule,
|
||||
intervalValue,
|
||||
intervalUnit,
|
||||
channelRename,
|
||||
channelRenumber,
|
||||
channelReicon,
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
/* ****************************************************************
|
||||
* Advanced Fields
|
||||
* ***************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* External modules
|
||||
*/
|
||||
|
@ -156,13 +209,14 @@ tvheadend.epggrab = function() {
|
|||
singleSelect : false,
|
||||
listeners : {
|
||||
'rowselect' : function (s, ri, r) {
|
||||
r.set('enabled', 1);
|
||||
moduleSelect(r, 1);
|
||||
},
|
||||
'rowdeselect' : function (s, ri, r) {
|
||||
r.set('enabled', 0);
|
||||
moduleSelect(r, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var externalColumnModel = new Ext.grid.ColumnModel([
|
||||
externalSelectionModel,
|
||||
{
|
||||
|
@ -192,6 +246,17 @@ tvheadend.epggrab = function() {
|
|||
iconCls : 'icon-grid',
|
||||
});
|
||||
|
||||
var externalPanel = new Ext.form.FieldSet({
|
||||
title : 'External Interfaces',
|
||||
width : 800,
|
||||
autoHeight : true,
|
||||
collapsible : true,
|
||||
collapsed : true,
|
||||
items : [
|
||||
externalGrid
|
||||
]
|
||||
});
|
||||
|
||||
/*
|
||||
* OTA modules
|
||||
*/
|
||||
|
@ -200,17 +265,27 @@ tvheadend.epggrab = function() {
|
|||
singleSelect : false,
|
||||
listeners : {
|
||||
'rowselect' : function (s, ri, r) {
|
||||
r.set('enabled', 1);
|
||||
moduleSelect(r, 1);
|
||||
},
|
||||
'rowdeselect' : function (s, ri, r) {
|
||||
r.set('enabled', 0);
|
||||
moduleSelect(r, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var otaColumnModel = new Ext.grid.ColumnModel([
|
||||
otaSelectionModel,
|
||||
{
|
||||
header : 'Module',
|
||||
dataIndex : 'name',
|
||||
width : 200,
|
||||
sortable : false,
|
||||
}
|
||||
]);
|
||||
|
||||
var otaGrid = new Ext.grid.EditorGridPanel({
|
||||
store : otaModuleStore,
|
||||
cm : externalColumnModel,
|
||||
cm : otaColumnModel,
|
||||
sm : otaSelectionModel,
|
||||
width : 600,
|
||||
height : 150,
|
||||
|
@ -221,26 +296,15 @@ tvheadend.epggrab = function() {
|
|||
iconCls : 'icon-grid',
|
||||
});
|
||||
|
||||
/* HACK: get display working */
|
||||
externalGrid.on('render', function(){
|
||||
delay = new Ext.util.DelayedTask(function(){
|
||||
rows = [];
|
||||
externalModuleStore.each(function(r){
|
||||
if (r.get('enabled')) rows.push(r);
|
||||
});
|
||||
externalSelectionModel.selectRecords(rows);
|
||||
});
|
||||
delay.delay(100);
|
||||
});
|
||||
otaGrid.on('render', function(){
|
||||
delay = new Ext.util.DelayedTask(function(){
|
||||
rows = [];
|
||||
otaModuleStore.each(function(r){
|
||||
if (r.get('enabled')) rows.push(r);
|
||||
});
|
||||
otaSelectionModel.selectRecords(rows);
|
||||
});
|
||||
delay.delay(100);
|
||||
var otaPanel = new Ext.form.FieldSet({
|
||||
title : 'OTA Interfaces',
|
||||
width : 800,
|
||||
autoHeight : true,
|
||||
collapsible : true,
|
||||
collapsed : true,
|
||||
items : [
|
||||
otaGrid
|
||||
],
|
||||
});
|
||||
|
||||
/* ****************************************************************
|
||||
|
@ -273,15 +337,11 @@ tvheadend.epggrab = function() {
|
|||
reader : confreader,
|
||||
layout : 'form',
|
||||
defaultType : 'textfield',
|
||||
autoHeight : true,
|
||||
items : [
|
||||
interval,
|
||||
internalModule,
|
||||
intervalValue,
|
||||
intervalUnit,
|
||||
new Ext.form.Label({text: 'External Interfaces'}),
|
||||
externalGrid,
|
||||
new Ext.form.Label({text: 'OTA Modules'}),
|
||||
otaGrid,
|
||||
simplePanel,
|
||||
externalPanel,
|
||||
otaPanel,
|
||||
],
|
||||
tbar: [
|
||||
saveButton,
|
||||
|
@ -294,7 +354,38 @@ tvheadend.epggrab = function() {
|
|||
* Load/Save
|
||||
* ***************************************************************/
|
||||
|
||||
/* HACK: get display working */
|
||||
externalGrid.on('render', function(){
|
||||
delay = new Ext.util.DelayedTask(function(){
|
||||
rows = [];
|
||||
externalModuleStore.each(function(r){
|
||||
if (r.get('enabled')) rows.push(r);
|
||||
});
|
||||
externalSelectionModel.selectRecords(rows);
|
||||
});
|
||||
delay.delay(100);
|
||||
});
|
||||
otaGrid.on('render', function(){
|
||||
delay = new Ext.util.DelayedTask(function(){
|
||||
rows = [];
|
||||
otaModuleStore.each(function(r){
|
||||
if (r.get('enabled')) rows.push(r);
|
||||
});
|
||||
otaSelectionModel.selectRecords(rows);
|
||||
});
|
||||
delay.delay(100);
|
||||
});
|
||||
|
||||
confpanel.on('render', function() {
|
||||
|
||||
/* Hack to get display working */
|
||||
delay = new Ext.util.DelayedTask(function(){
|
||||
simplePanel.doLayout(false);
|
||||
externalPanel.doLayout(false);
|
||||
otaPanel.doLayout(false);
|
||||
});
|
||||
delay.delay(100);
|
||||
|
||||
confpanel.getForm().load({
|
||||
url : 'epggrab',
|
||||
params : { op : 'loadSettings' },
|
||||
|
@ -306,10 +397,7 @@ tvheadend.epggrab = function() {
|
|||
|
||||
function saveChanges() {
|
||||
mods = [];
|
||||
externalModuleStore.each(function(r) {
|
||||
mods.push({id: r.get('id'), enabled: r.get('enabled') ? 1 : 0});
|
||||
});
|
||||
otaModuleStore.each(function(r) {
|
||||
moduleStore.each(function(r) {
|
||||
mods.push({id: r.get('id'), enabled: r.get('enabled') ? 1 : 0});
|
||||
});
|
||||
mods = Ext.util.JSON.encode(mods);
|
||||
|
|
Loading…
Add table
Reference in a new issue