// Note: since channel names are no longer unique this method will simply
// return the first entry encountered, so could be somewhat random
channel_t *
-channel_find_by_name ( const char *name )
+channel_find_by_name_and_bouquet ( const char *name, const struct bouquet *bq )
{
channel_t *ch;
const char *s;
if (!ch->ch_enabled) continue;
s = channel_get_name(ch, NULL);
if (s == NULL) continue;
+ if (bq && ch->ch_bouquet != bq) continue;
if (strcmp(s, name) == 0) break;
}
return ch;
}
+channel_t *
+channel_find_by_name(const char *name)
+{
+ return channel_find_by_name_and_bouquet(name, NULL);
+}
/// Copy name without space and HD suffix, lowercase in to a new
/// buffer
}
channel_t *
-channel_find_by_name_fuzzy ( const char *name )
+channel_find_by_name_bouquet_fuzzy ( const char *name, const struct bouquet *bq )
{
channel_t *ch;
const char *s;
CHANNEL_FOREACH(ch) {
if (!ch->ch_enabled) continue;
+ if (bq && ch->ch_bouquet != bq) continue;
s = channel_get_name(ch, NULL);
if (s == NULL) continue;
/* We need case insensitive since historical constraints means we
return ct;
}
-
/**
*
*/
void channel_delete(channel_t *ch, int delconf);
+channel_t *channel_find_by_name_and_bouquet(const char *name, const struct bouquet *bq);
channel_t *channel_find_by_name(const char *name);
/// Apply fuzzy matching when finding a channel such as ignoring
/// whitespace, case, and stripping HD suffix. This means that
/// 'Channel 5 +1HD' can all be merged together.
/// Since channel names aren't unique, this returns the
/// first match (similar to channel_find_by_name).
-channel_t *channel_find_by_name_fuzzy(const char *name);
+/// @param bouquet - Bouquet to use: can be NULL
+channel_t *channel_find_by_name_bouquet_fuzzy(const char *name, const struct bouquet *bq);
#define channel_find_by_uuid(u)\
(channel_t*)idnode_find(u, &channel_class, NULL)
/* Find existing channel */
name = service_get_channel_name(s);
- if (!bq && conf->merge_same_name && name && *name) {
+ if (conf->merge_same_name && name && *name) {
/* Try exact match first */
- chn = channel_find_by_name(name);
+ chn = channel_find_by_name_and_bouquet(name, bq);
if (!chn && conf->merge_same_name_fuzzy) {
- chn = channel_find_by_name_fuzzy(name);
+ chn = channel_find_by_name_bouquet_fuzzy(name, bq);
}
}
- if (!chn) {
+ /* If using bouquets then we want to only merge
+ * with channels on the same bouquet. This is because
+ * you can disable all channels on a bouquet through
+ * the bouquet menu so if we merged between bouquets then
+ * you'd get odd results.
+ *
+ * The chn should already be for the correct bouquet
+ * but we'll safety-check here.
+ */
+ if (!chn || (bq && chn->ch_bouquet != bq)) {
chn = channel_create(NULL, NULL, NULL);
chn->ch_bouquet = bq;
}