Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
IPTV: Add extra channels tags to IPTV mux config, m3u attribute tvh-tags
  • Loading branch information
perexg committed Nov 12, 2015
1 parent 7173bba commit abad26e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/input/mpegts/iptv/iptv_auto.c
Expand Up @@ -54,7 +54,7 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
int delim;
size_t l;
int64_t chnum2;
const char *url, *name, *logo, *epgid;
const char *url, *name, *logo, *epgid, *tags;
char url2[512], custom[512], name2[128], buf[32], *n, *y;

url = htsmsg_get_str(item, "m3u-url");
Expand Down Expand Up @@ -90,6 +90,15 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
logo = htsmsg_get_str(item, "logo");

epgid = htsmsg_get_str(item, "tvg-id");
tags = htsmsg_get_str(item, "tvh-tags");
if (tags) {
tags = n = strdupa(tags);
while (*n) {
if (*n == '|')
*n = '\n';
n++;
}
}

urlinit(&u);
custom[0] = '\0';
Expand Down Expand Up @@ -199,6 +208,11 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
im->mm_iptv_hdr = strdup(custom);
change = 1;
}
if (strcmp(im->mm_iptv_tags ?: "", tags ?: "")) {
free(im->mm_iptv_tags);
im->mm_iptv_tags = strdup(tags);
change = 1;
}
if (change)
idnode_notify_changed(&im->mm_id);
(*total)++;
Expand All @@ -222,6 +236,8 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
htsmsg_add_str(conf, "iptv_icon", logo);
if (epgid)
htsmsg_add_str(conf, "iptv_epgid", epgid);
if (tags)
htsmsg_add_str(conf, "iptv_tags", tags);
if (!in->in_scan_create)
htsmsg_add_s32(conf, "scan_result", MM_SCAN_OK);
if (custom[0])
Expand Down
8 changes: 8 additions & 0 deletions src/input/mpegts/iptv/iptv_mux.c
Expand Up @@ -224,6 +224,13 @@ const idclass_t iptv_mux_class =
.off = offsetof(iptv_mux_t, mm_iptv_hdr),
.opts = PO_ADVANCED | PO_MULTILINE
},
{
.type = PT_STR,
.id = "iptv_tags",
.name = N_("Channel tags"),
.off = offsetof(iptv_mux_t, mm_iptv_tags),
.opts = PO_ADVANCED | PO_MULTILINE
},
{}
}
};
Expand Down Expand Up @@ -260,6 +267,7 @@ iptv_mux_delete ( mpegts_mux_t *mm, int delconf )
free(im->mm_iptv_svcname);
free(im->mm_iptv_env);
free(im->mm_iptv_hdr);
free(im->mm_iptv_tags);
free(im->mm_iptv_icon);
free(im->mm_iptv_epgid);
mpegts_mux_delete(mm, delconf);
Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts/iptv/iptv_private.h
Expand Up @@ -131,6 +131,7 @@ struct iptv_mux
int mm_iptv_kill_timeout;
char *mm_iptv_env;
char *mm_iptv_hdr;
char *mm_iptv_tags;

uint32_t mm_iptv_rtp_seq;

Expand Down
22 changes: 22 additions & 0 deletions src/input/mpegts/iptv/iptv_service.c
Expand Up @@ -108,6 +108,27 @@ iptv_service_channel_epgid ( service_t *s )
return im->mm_iptv_epgid;
}

static htsmsg_t *
iptv_service_channel_tags ( service_t *s )
{
iptv_service_t *is = (iptv_service_t *)s;
iptv_mux_t *im = (iptv_mux_t *)is->s_dvb_mux;
char *p = im->mm_iptv_tags, *x;
htsmsg_t *r = NULL;
if (p) {
r = htsmsg_create_list();
while (*p) {
while (*p && *p <= ' ') p++;
x = p;
while (*p && *p >= ' ') p++;
if (*p) { *p = '\0'; p++; }
if (*x)
htsmsg_add_str(r, NULL, x);
}
}
return r;
}

/*
* Create
*/
Expand All @@ -128,6 +149,7 @@ iptv_service_create0
is->s_channel_number = iptv_service_channel_number;
is->s_channel_icon = iptv_service_channel_icon;
is->s_channel_epgid = iptv_service_channel_epgid;
is->s_channel_tags = iptv_service_channel_tags;

/* Set default service name */
if (!is->s_dvb_svcname || !*is->s_dvb_svcname)
Expand Down
1 change: 1 addition & 0 deletions src/service.h
Expand Up @@ -320,6 +320,7 @@ typedef struct service {
int64_t (*s_channel_number) (struct service *);
const char *(*s_channel_name) (struct service *);
const char *(*s_channel_epgid) (struct service *);
htsmsg_t *(*s_channel_tags) (struct service *);
const char *(*s_provider_name) (struct service *);
const char *(*s_channel_icon) (struct service *);
void (*s_mapped) (struct service *);
Expand Down
10 changes: 9 additions & 1 deletion src/service_mapper.c
Expand Up @@ -209,7 +209,9 @@ channel_t *
service_mapper_process ( service_t *s, bouquet_t *bq )
{
channel_t *chn = NULL;
const char *name;
const char *name, *tagname;
htsmsg_field_t *f;
htsmsg_t *m;

/* Ignore */
if (s->s_status == SERVICE_ZOMBIE) {
Expand Down Expand Up @@ -249,6 +251,12 @@ service_mapper_process ( service_t *s, bouquet_t *bq )
channel_tag_map(channel_tag_find_by_name("Radio", 1), chn, chn);
}

/* Custom tags */
if (s->s_channel_tags && (m = s->s_channel_tags(s)) != NULL)
HTSMSG_FOREACH(f, m)
if ((tagname = htsmsg_field_get_str(f)) != NULL)
channel_tag_map(channel_tag_find_by_name(tagname, 1), chn, chn);

/* Provider */
if (service_mapper_conf.provider_tags)
if ((prov = s->s_provider_name(s)))
Expand Down

0 comments on commit abad26e

Please sign in to comment.