Skip to content

Commit

Permalink
fix mediaBaseURL handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulexus committed Jul 24, 2022
1 parent f36d226 commit 5a4afc4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions agenda/agenda.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"encoding/hex"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -39,6 +39,8 @@ func New(filename string) (*Agenda, error) {
a.MediaBaseURL = "/media/"
}

a.MediaBaseURL = strings.TrimSuffix(a.MediaBaseURL, "/")

// Generate all IDs
for _, c := range a.Cues {
if err = c.generateID(); err != nil {
Expand Down Expand Up @@ -424,10 +426,12 @@ func (t *Track) generateID(a *Agenda) error {
// Calculate AudioFiles from prefix, if we are given one
if t.AudioFilePrefix != "" {
for _, f := range fileFormats {
t.AudioFiles = append(t.AudioFiles, filepath.Join(a.MediaBaseURL, fmt.Sprintf("%s.%s", strings.TrimSuffix(t.AudioFilePrefix, "."), f)))
t.AudioFiles = append(t.AudioFiles, fmt.Sprintf("%s/%s", a.MediaBaseURL, fmt.Sprintf("%s.%s", strings.TrimSuffix(t.AudioFilePrefix, "."), f)))
}
}

log.Printf("generated audio URLs based on %q for %q: %+v", a.MediaBaseURL, t.AudioFilePrefix, t.AudioFiles)

if len(t.AudioFiles) < 1 {
return fmt.Errorf("track must have audio files (cue %s)", t.Cue)
}
Expand Down

0 comments on commit 5a4afc4

Please sign in to comment.