From bf39c224c85435f3a5aedcf4721769278c6088be Mon Sep 17 00:00:00 2001 From: Adriano Caloiaro Date: Fri, 28 Nov 2025 10:19:56 -0800 Subject: [PATCH] feat: remove network name from favorite names in favorite list --- difm/difm.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/difm/difm.go b/difm/difm.go index c31798e..bd78a39 100644 --- a/difm/difm.go +++ b/difm/difm.go @@ -196,12 +196,17 @@ func ListFavorites(ctx *context.AppContext) (favorites []components.FavoriteItem } sec := "playlist" + + // Playlist files prefix favorites with: 'NETWORKNAME - ', which needs to be removed + networkNamePrefix := fmt.Sprintf("%s - ", strings.ToUpper(ctx.Network.Name)) numEntries := cfg.Section(sec).Key("NumberOfEntries").MustInt(0) for i := 0; i < numEntries; i++ { // di.fm's PLS keys begin at 1 k := i + 1 + origFavoriteName := cfg.Section(sec).Key(fmt.Sprintf("Title%d", k)).String() + favoriteName := strings.Replace(origFavoriteName, networkNamePrefix, "", 1) favorites = append(favorites, components.FavoriteItem{ - Name: cfg.Section(sec).Key(fmt.Sprintf("Title%d", k)).String(), + Name: favoriteName, PlaylistURL: cfg.Section(sec).Key(fmt.Sprintf("File%d", k)).String(), }) } @@ -265,11 +270,8 @@ func Stream(url string, ctx *context.AppContext) { // FavoriteItemChannel identifies the ChannelItem that corresponds with a FavoriteItem func FavoriteItemChannel(ctx *context.AppContext, favorite components.FavoriteItem) (channel *components.ChannelItem) { - // favorites are prefixed with " - ", e.g. "DI.fm - Liquid Trap" - // shave it off before comparing - prefix := fmt.Sprintf("%s - ", ctx.Network.Name) for _, chn := range ctx.ChannelList { - if chn.Name == favorite.Name[len(prefix):len(favorite.Name)] { + if chn.Name == favorite.Name { channel = &chn return }