Project

General

Profile

Bug #5797 » gitdiff.txt

Antony B, 2019-12-21 05:42

 
1
diff --git a/src/channels.c b/src/channels.c
2
index 521a6e0f5..811a2285d 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,26 @@ 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
-    if (!isspace(*ch)) {
40
+    if (!isspace(*ch) && *ch!='.' && *ch!=':' && *ch!=';' && *ch!=',' && *ch!='_' && *ch!='-' ) {
41
       *ch_fuzzy++ = tolower(*ch);
42
     }
43
   }
44
diff --git a/src/channels.h b/src/channels.h
45
index 7b377487d..bfd83a17a 100644
46
--- a/src/channels.h
47
+++ b/src/channels.h
48
@@ -212,6 +212,8 @@ int channel_set_icon ( channel_t *ch, const char *icon );
49
 
50
 const char *channel_get_epgid ( channel_t *ch );
51
 
52
+char *channel_make_fuzzy_name(const char *name);
53
+
54
 #define channel_get_uuid(ch,ub) idnode_uuid_as_str(&(ch)->ch_id, ub)
55
 
56
 #define channel_get_id(ch)    idnode_get_short_uuid((&(ch)->ch_id))
57
diff --git a/src/epggrab/channel.c b/src/epggrab/channel.c
58
index 2bda67fd8..e4304f343 100644
59
--- a/src/epggrab/channel.c
60
+++ b/src/epggrab/channel.c
61
@@ -82,14 +82,21 @@ int epggrab_channel_match_name ( epggrab_channel_t *ec, channel_t *ch )
62
   if (name == NULL)
63
     return 0;
64
 
65
-  if (ec->name && !strcasecmp(ec->name, name))
66
-    return 1;
67
+  char *ch_fuzzy_name = channel_make_fuzzy_name(name);
68
+
69
+  if (ec->name)
70
+  {
71
+	  char *ec_fuzzy_name = channel_make_fuzzy_name(ec->name);
72
+	  if(!strcmp(ec_fuzzy_name, ch_fuzzy_name)) return 1;
73
+  }
74
 
75
   if (ec->names)
76
     HTSMSG_FOREACH(f, ec->names)
77
       if ((s = htsmsg_field_get_str(f)) != NULL)
78
-        if (!strcasecmp(s, name))
79
-          return 1;
80
+      {
81
+    	  char *s_fuzzy_name = channel_make_fuzzy_name(s);
82
+    	  if(!strcmp(s_fuzzy_name, ch_fuzzy_name)) return 1;
83
+      }
84
 
85
   return 0;
86
 }
87
@@ -195,6 +202,7 @@ epggrab_channel_map ( idnode_t *ec, idnode_t *ch, void *origin )
88
   return epggrab_channel_link((epggrab_channel_t *)ec, (channel_t *)ch, origin);
89
 }
90
 
91
+
92
 /* Set name */
93
 int epggrab_channel_set_name ( epggrab_channel_t *ec, const char *name )
94
 {
95
@@ -288,20 +296,16 @@ static int
96
 epggrab_channel_autolink( epggrab_channel_t *ec )
97
 {
98
   channel_t *ch;
99
+  int found=1;
100
 
101
   CHANNEL_FOREACH(ch)
102
-    if (epggrab_channel_match_epgid(ec, ch))
103
+    if (epggrab_channel_match_epgid(ec, ch)
104
+    		|| epggrab_channel_match_name(ec, ch)
105
+			|| epggrab_channel_match_number(ec, ch))
106
       if (epggrab_channel_link(ec, ch, NULL))
107
-        return 1;
108
-  CHANNEL_FOREACH(ch)
109
-    if (epggrab_channel_match_name(ec, ch))
110
-      if (epggrab_channel_link(ec, ch, NULL))
111
-        return 1;
112
-  CHANNEL_FOREACH(ch)
113
-    if (epggrab_channel_match_number(ec, ch))
114
-      if (epggrab_channel_link(ec, ch, NULL))
115
-        return 1;
116
-  return 0;
117
+        found=1;
118
+
119
+  return found;
120
 }
121
 
122
 /* Channel settings updated */
(1-1/2)