sanitize playlist descriptions
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
693b228194
commit
81d5135d1a
@ -2,6 +2,7 @@ package tui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -12,6 +13,8 @@ import (
|
|||||||
"github.com/zmb3/spotify/v2"
|
"github.com/zmb3/spotify/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const regex = `<.*?>`
|
||||||
|
|
||||||
func DeviceView(ctx *gctx.Context, commands *commands.Commands) ([]list.Item, error) {
|
func DeviceView(ctx *gctx.Context, commands *commands.Commands) ([]list.Item, error) {
|
||||||
items := []list.Item{}
|
items := []list.Item{}
|
||||||
devices, err := commands.Client().PlayerDevices(ctx)
|
devices, err := commands.Client().PlayerDevices(ctx)
|
||||||
@ -122,7 +125,7 @@ func SearchPlaylistsView(ctx *gctx.Context, commands *commands.Commands, playlis
|
|||||||
for _, playlist := range playlists.Playlists {
|
for _, playlist := range playlists.Playlists {
|
||||||
items = append(items, mainItem{
|
items = append(items, mainItem{
|
||||||
Name: playlist.Name,
|
Name: playlist.Name,
|
||||||
Desc: playlist.Description,
|
Desc: stripHtmlRegex(playlist.Description),
|
||||||
SpotifyItem: playlist,
|
SpotifyItem: playlist,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -291,10 +294,15 @@ func MainView(ctx *gctx.Context, commands *commands.Commands) ([]list.Item, erro
|
|||||||
for _, playlist := range playlists.Playlists {
|
for _, playlist := range playlists.Playlists {
|
||||||
items = append(items, mainItem{
|
items = append(items, mainItem{
|
||||||
Name: playlist.Name,
|
Name: playlist.Name,
|
||||||
Desc: playlist.Description,
|
Desc: stripHtmlRegex(playlist.Description),
|
||||||
SpotifyItem: playlist,
|
SpotifyItem: playlist,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stripHtmlRegex(s string) string {
|
||||||
|
r := regexp.MustCompile(regex)
|
||||||
|
return r.ReplaceAllString(s, "")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user