1
|
diff --git a/src/channels.c b/src/channels.c
|
2
|
index 521a6e0f5..f8c15a946 100644
|
3
|
--- a/src/channels.c
|
4
|
+++ b/src/channels.c
|
5
|
@@ -622,7 +622,7 @@ channel_find_by_name(const char *name)
|
6
|
|
7
|
/// Copy name without space and (U)HD suffix, lowercase in to a new
|
8
|
/// buffer
|
9
|
-static char *
|
10
|
+char *
|
11
|
channel_make_fuzzy_name(const char *name)
|
12
|
{
|
13
|
if (!name) return NULL;
|
14
|
@@ -632,17 +632,27 @@ channel_make_fuzzy_name(const char *name)
|
15
|
const char *ch = name;
|
16
|
|
17
|
for (; *ch ; ++ch) {
|
18
|
+ /* Strip trailing 'SD'. */
|
19
|
+ if (*ch == 'S' && *(ch+1) == 'D' && *(ch+2) == 0)
|
20
|
+ break;
|
21
|
/* Strip trailing 'HD'. */
|
22
|
if (*ch == 'H' && *(ch+1) == 'D' && *(ch+2) == 0)
|
23
|
break;
|
24
|
+ /* Strip trailing 'FHD'. */
|
25
|
+ if (*ch == 'F' && *(ch+1) == 'H' && *(ch+2) == 'D' && *(ch+3) == 0)
|
26
|
+ break;
|
27
|
/* Strip trailing 'UHD'. */
|
28
|
if (*ch == 'U' && *(ch+1) == 'H' && *(ch+2) == 'D' && *(ch+3) == 0)
|
29
|
break;
|
30
|
- /* Strip trailing 'FHD'. */
|
31
|
- if (*ch == 'F' && *(ch+1) == 'H' && *(ch+2) == 'D' && *(ch+3) == 0)
|
32
|
+ /* Strip trailing '4K'. */
|
33
|
+ if (*ch == '4' && *(ch+1) == 'K' && *(ch+2) == 0)
|
34
|
break;
|
35
|
+ /* Strip trailing '8K'. */
|
36
|
+ if (*ch == '8' && *(ch+1) == 'K' && *(ch+2) == 0)
|
37
|
+ break;
|
38
|
+
|
39
|
|
40
|
- if (!isspace(*ch)) {
|
41
|
+ if (!isspace(*ch) && *ch!='.' && *ch!=':' && *ch!=';' && *ch!=',' && *ch!='_' && *ch!='-' ) {
|
42
|
*ch_fuzzy++ = tolower(*ch);
|
43
|
}
|
44
|
}
|
45
|
diff --git a/src/channels.h b/src/channels.h
|
46
|
index 7b377487d..bfd83a17a 100644
|
47
|
--- a/src/channels.h
|
48
|
+++ b/src/channels.h
|
49
|
@@ -212,6 +212,8 @@ int channel_set_icon ( channel_t *ch, const char *icon );
|
50
|
|
51
|
const char *channel_get_epgid ( channel_t *ch );
|
52
|
|
53
|
+char *channel_make_fuzzy_name(const char *name);
|
54
|
+
|
55
|
#define channel_get_uuid(ch,ub) idnode_uuid_as_str(&(ch)->ch_id, ub)
|
56
|
|
57
|
#define channel_get_id(ch) idnode_get_short_uuid((&(ch)->ch_id))
|
58
|
diff --git a/src/epggrab/channel.c b/src/epggrab/channel.c
|
59
|
index 2bda67fd8..102ac8fd0 100644
|
60
|
--- a/src/epggrab/channel.c
|
61
|
+++ b/src/epggrab/channel.c
|
62
|
@@ -82,14 +82,25 @@ int epggrab_channel_match_name ( epggrab_channel_t *ec, channel_t *ch )
|
63
|
if (name == NULL)
|
64
|
return 0;
|
65
|
|
66
|
- if (ec->name && !strcasecmp(ec->name, name))
|
67
|
- return 1;
|
68
|
+ char *ch_fuzzy_name = channel_make_fuzzy_name(name);
|
69
|
+ const char *chid = channel_get_epgid(ch);
|
70
|
+ char *chid_fuzzy_name = chid ? channel_make_fuzzy_name(chid) : NULL;
|
71
|
+
|
72
|
+ if (ec->name)
|
73
|
+ {
|
74
|
+ char *ec_fuzzy_name = channel_make_fuzzy_name(ec->name);
|
75
|
+ if(!strcmp(ec_fuzzy_name, ch_fuzzy_name)) return 1;
|
76
|
+ if(chid_fuzzy_name && !strcmp(ec_fuzzy_name, chid_fuzzy_name) ) return 1; //macth chid with ec->name
|
77
|
+ }
|
78
|
|
79
|
if (ec->names)
|
80
|
HTSMSG_FOREACH(f, ec->names)
|
81
|
if ((s = htsmsg_field_get_str(f)) != NULL)
|
82
|
- if (!strcasecmp(s, name))
|
83
|
- return 1;
|
84
|
+ {
|
85
|
+ char *s_fuzzy_name = channel_make_fuzzy_name(s);
|
86
|
+ if(!strcmp(s_fuzzy_name, ch_fuzzy_name)) return 1;
|
87
|
+ if(chid_fuzzy_name && !strcmp(s_fuzzy_name, chid_fuzzy_name) ) return 1; //macth chid with ec->names
|
88
|
+ }
|
89
|
|
90
|
return 0;
|
91
|
}
|
92
|
@@ -195,6 +206,7 @@ epggrab_channel_map ( idnode_t *ec, idnode_t *ch, void *origin )
|
93
|
return epggrab_channel_link((epggrab_channel_t *)ec, (channel_t *)ch, origin);
|
94
|
}
|
95
|
|
96
|
+
|
97
|
/* Set name */
|
98
|
int epggrab_channel_set_name ( epggrab_channel_t *ec, const char *name )
|
99
|
{
|
100
|
@@ -288,20 +300,16 @@ static int
|
101
|
epggrab_channel_autolink( epggrab_channel_t *ec )
|
102
|
{
|
103
|
channel_t *ch;
|
104
|
+ int found=1;
|
105
|
|
106
|
CHANNEL_FOREACH(ch)
|
107
|
- if (epggrab_channel_match_epgid(ec, ch))
|
108
|
+ if (epggrab_channel_match_epgid(ec, ch)
|
109
|
+ || epggrab_channel_match_name(ec, ch)
|
110
|
+ || epggrab_channel_match_number(ec, ch))
|
111
|
if (epggrab_channel_link(ec, ch, NULL))
|
112
|
- return 1;
|
113
|
- CHANNEL_FOREACH(ch)
|
114
|
- if (epggrab_channel_match_name(ec, ch))
|
115
|
- if (epggrab_channel_link(ec, ch, NULL))
|
116
|
- return 1;
|
117
|
- CHANNEL_FOREACH(ch)
|
118
|
- if (epggrab_channel_match_number(ec, ch))
|
119
|
- if (epggrab_channel_link(ec, ch, NULL))
|
120
|
- return 1;
|
121
|
- return 0;
|
122
|
+ found=1;
|
123
|
+
|
124
|
+ return found;
|
125
|
}
|
126
|
|
127
|
/* Channel settings updated */
|