@@ -133,35 +133,8 @@ func (s *UIState) v2MultiCommandNodes(perspectives []f1tv.AdditionalStream, main
133133
134134 for _ , multi := range s .cmd .MultiCommads {
135135 s .logger .Infof ("checking %q" , multi .Title )
136- var commands []cmd.CommandContext
137- for _ , target := range multi .Targets {
138- mainFeed , perspective , err := findPerspectiveByName (target .MatchTitle , perspectives , mainStream )
139- if err != nil {
140- continue
141- }
142-
143- var urlFunc func () (string , error )
144- if mainFeed != nil {
145- urlFunc = func () (string , error ) { return s .v2 .GetPlaybackURL (f1tv .BIG_SCREEN_HLS , mainStream .Metadata .ContentID ) }
146- } else {
147- urlFunc = func () (string , error ) {
148- return s .v2 .GetPerspectivePlaybackURL (f1tv .BIG_SCREEN_HLS , perspective .PlaybackURL )
149- }
150- }
151- targetCmd := s .cmd .GetCommand (target )
152- if len (targetCmd .Command ) == 0 {
153- s .logger .Errorf ("could not determine command for %q - %q" , multi .Title , target .MatchTitle )
154- continue
155- }
136+ commands := s .extractCommands (multi , perspectives , mainStream )
156137
157- // If we have a match, run the given command!
158- context := cmd.CommandContext {
159- MetaData : cmd.MetaData {PerspectiveTitle : multi .Title },
160- CustomOptions : targetCmd ,
161- URL : urlFunc ,
162- }
163- commands = append (commands , context )
164- }
165138 // If no streams are matched, continue
166139 if len (commands ) == 0 {
167140 continue
@@ -185,6 +158,39 @@ func (s *UIState) v2MultiCommandNodes(perspectives []f1tv.AdditionalStream, main
185158 return nodes
186159}
187160
161+ func (s * UIState ) extractCommands (multi cmd.MultiCommand , perspectives []f1tv.AdditionalStream , mainStream f1tv.ContentContainer ) []cmd.CommandContext {
162+ var commands []cmd.CommandContext
163+ for _ , target := range multi .Targets {
164+ mainFeed , perspective , err := findPerspectiveByName (target .MatchTitle , perspectives , mainStream )
165+ if err != nil {
166+ continue
167+ }
168+
169+ var urlFunc func () (string , error )
170+ if mainFeed != nil {
171+ urlFunc = func () (string , error ) { return s .v2 .GetPlaybackURL (f1tv .BIG_SCREEN_HLS , mainStream .Metadata .ContentID ) }
172+ } else {
173+ urlFunc = func () (string , error ) {
174+ return s .v2 .GetPerspectivePlaybackURL (f1tv .BIG_SCREEN_HLS , perspective .PlaybackURL )
175+ }
176+ }
177+ targetCmd := s .cmd .GetCommand (target )
178+ if len (targetCmd .Command ) == 0 {
179+ s .logger .Errorf ("could not determine command for %q - %q" , multi .Title , target .MatchTitle )
180+ continue
181+ }
182+
183+ // If we have a match, run the given command!
184+ context := cmd.CommandContext {
185+ MetaData : cmd.MetaData {PerspectiveTitle : multi .Title },
186+ CustomOptions : targetCmd ,
187+ URL : urlFunc ,
188+ }
189+ commands = append (commands , context )
190+ }
191+ return commands
192+ }
193+
188194func findPerspectiveByName (name string , perspectives []f1tv.AdditionalStream , mainStream f1tv.ContentContainer ) (* f1tv.ContentContainer , * f1tv.AdditionalStream , error ) {
189195 notFound := fmt .Errorf ("found no perspective matching '%s'" , name )
190196 for _ , perspective := range perspectives {
0 commit comments