MCPcopy
hub / github.com/glanceapp/glance / initialize

Method initialize

internal/glance/widget-videos.go:36–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34}
35
36func (widget *videosWidget) initialize() error {
37 widget.withTitle("Videos").withCacheDuration(time.Hour)
38
39 if widget.Limit <= 0 {
40 widget.Limit = 25
41 }
42
43 if widget.CollapseAfterRows == 0 || widget.CollapseAfterRows < -1 {
44 widget.CollapseAfterRows = 4
45 }
46
47 if widget.CollapseAfter == 0 || widget.CollapseAfter < -1 {
48 widget.CollapseAfter = 7
49 }
50
51 // A bit cheeky, but from a user's perspective it makes more sense when channels and
52 // playlists are separate things rather than specifying a list of channels and some of
53 // them awkwardly have a "playlist:" prefix
54 if len(widget.Playlists) > 0 {
55 initialLen := len(widget.Channels)
56 widget.Channels = append(widget.Channels, make([]string, len(widget.Playlists))...)
57
58 for i := range widget.Playlists {
59 widget.Channels[initialLen+i] = videosWidgetPlaylistPrefix + widget.Playlists[i]
60 }
61 }
62
63 return nil
64}
65
66func (widget *videosWidget) update(ctx context.Context) {
67 videos, err := fetchYoutubeChannelUploads(widget.Channels, widget.VideoUrlTemplate, widget.IncludeShorts)

Callers

nothing calls this directly

Calls 2

withCacheDurationMethod · 0.80
withTitleMethod · 0.80

Tested by

no test coverage detected