Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bouquets: add enigma1 parser, allow edit urls, logic fixes
  • Loading branch information
perexg committed Oct 19, 2015
1 parent 3a0756c commit a8a29d2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
4 changes: 4 additions & 0 deletions src/api/api_bouquet.c
Expand Up @@ -63,9 +63,13 @@ api_bouquet_create
{
htsmsg_t *conf;
bouquet_t *bq;
const char *s;

if (!(conf = htsmsg_get_map(args, "conf")))
return EINVAL;
s = htsmsg_get_str(conf, "ext_url");
if (s == NULL || *s == '\0')
return EINVAL;

pthread_mutex_lock(&global_lock);
bq = bouquet_create(NULL, conf, NULL, NULL);
Expand Down
32 changes: 21 additions & 11 deletions src/bouquet.c
Expand Up @@ -92,15 +92,20 @@ bouquet_create(const char *uuid, htsmsg_t *conf,
}

if (bq->bq_ext_url) {
free(bq->bq_src);
snprintf(buf, sizeof(buf), "exturl://%s", idnode_uuid_as_sstr(&bq->bq_id));
bq->bq_src = strdup(buf);
bq->bq_download = bqd = calloc(1, sizeof(*bqd));
bqd->bq = bq;
download_init(&bqd->download, "bouquet");
bqd->download.process = bouquet_download_process;
bqd->download.stop = bouquet_download_stop;
bouquet_change_comment(bq, bq->bq_ext_url, 0);
if (bq->bq_src && strncmp(bq->bq_src, "exturl://", 9) != 0) {
free(bq->bq_ext_url);
bq->bq_ext_url = NULL;
} else {
free(bq->bq_src);
snprintf(buf, sizeof(buf), "exturl://%s", idnode_uuid_as_sstr(&bq->bq_id));
bq->bq_src = strdup(buf);
bq->bq_download = bqd = calloc(1, sizeof(*bqd));
bqd->bq = bq;
download_init(&bqd->download, "bouquet");
bqd->download.process = bouquet_download_process;
bqd->download.stop = bouquet_download_stop;
bouquet_change_comment(bq, bq->bq_ext_url, 0);
}
}

bq2 = RB_INSERT_SORTED(&bouquets, bq, bq_link, _bq_cmp);
Expand Down Expand Up @@ -951,6 +956,7 @@ const idclass_t bouquet_class = {
.name = N_("Re-fetch period (mins)"),
.off = offsetof(bouquet_t, bq_ext_url_period),
.opts = PO_ADVANCED | PO_HIDDEN,
.notify = bouquet_class_ext_url_notify,
.def.i = 60
},
{
Expand Down Expand Up @@ -1041,7 +1047,7 @@ parse_enigma2(bouquet_t *bq, char *data)
char *argv[11], *p, *tagname = NULL, *name;
long lv, stype, sid, tsid, onid, hash;
uint32_t seen = 0;
int n;
int n, ver = 2;

while (*data) {
if (strncmp(data, "#NAME ", 6) == 0) {
Expand All @@ -1051,6 +1057,7 @@ parse_enigma2(bouquet_t *bq, char *data)
bq->bq_name = strdup(p);
} if (strncmp(data, "#SERVICE ", 9) == 0) {
data += 9, p = data;
service:
while (*data && *data != '\r' && *data != '\n') data++;
if (*data) { *data = '\0'; data++; }
n = http_tokenize(p, argv, ARRAY_SIZE(argv), ':');
Expand All @@ -1072,14 +1079,17 @@ parse_enigma2(bouquet_t *bq, char *data)
tagname = name;
}
}
} else if (strncmp(data, "#SERVICE: ", 10) == 0) {
ver = 1, data += 10, p = data;
goto service;
} else {
while (*data && *data != '\r' && *data != '\n') data++;
}
next:
while (*data && (*data == '\r' || *data == '\n')) data++;
}
bouquet_completed(bq, seen);
tvhinfo("bouquet", "parsed Enigma2 bouquet %s (%d services)", bq->bq_name, seen);
tvhinfo("bouquet", "parsed Enigma%d bouquet %s (%d services)", ver, bq->bq_name, seen);
return 0;
}

Expand Down
11 changes: 6 additions & 5 deletions src/webui/static/app/cteditor.js
Expand Up @@ -33,10 +33,11 @@ tvheadend.cteditor = function(panel, index)
*/
tvheadend.bouquet = function(panel, index)
{
var list = 'enabled,rescan,name,maptoch,mapnolcn,lcn_off,mapnoname,mapradio,' +
'chtag,source,services_count,services_seen,comment';
var alist = 'enabled,ext_url,name,maptoch,mapnolcn,lcn_off,mapnoname,mapradio,' +
'chtag,comment';
var list0 = 'name,maptoch,mapnolcn,lcn_off,mapnoname,mapradio,' +
'chtag,source,services_count,services_seen,comment';
var list = 'enabled,rescan,' + list0;
var elist = 'enabled,rescan,ext_url,' + list0;
var alist = 'enabled,ext_url,' + list0;

tvheadend.idnode_grid(panel, {
url: 'api/bouquet',
Expand Down Expand Up @@ -66,7 +67,7 @@ tvheadend.bouquet = function(panel, index)
create: { }
},
del: true,
edit: { params: { list: list } },
edit: { params: { list: elist } },
sort: {
field: 'name',
direction: 'ASC'
Expand Down

0 comments on commit a8a29d2

Please sign in to comment.