Allow specifying playlists separately

This commit is contained in:
Svilen Markov
2025-02-09 00:31:53 +00:00
parent 982f3ee2a1
commit c583057d45
2 changed files with 25 additions and 7 deletions

View File

@@ -28,6 +28,7 @@ type videosWidget struct {
CollapseAfter int `yaml:"collapse-after"`
CollapseAfterRows int `yaml:"collapse-after-rows"`
Channels []string `yaml:"channels"`
Playlists []string `yaml:"playlists"`
Limit int `yaml:"limit"`
IncludeShorts bool `yaml:"include-shorts"`
}
@@ -47,6 +48,17 @@ func (widget *videosWidget) initialize() error {
widget.CollapseAfter = 7
}
// A bit cheeky, but from a user's perspective it makes more sense when channels and
// playlists are separate things rather than specifying a list of channels and some of
// them awkwardly have a "playlist:" prefix
if len(widget.Playlists) > 0 {
widget.Channels = append(widget.Channels, make([]string, len(widget.Playlists))...)
for i := range widget.Playlists {
widget.Channels[len(widget.Channels)-1+i] = "playlist:" + widget.Playlists[i]
}
}
return nil
}