Skip to content

Commit

Permalink
29: implement checks for oldest, random flags
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillerv committed Dec 11, 2022
1 parent dbfd87b commit 0117136
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
14 changes: 13 additions & 1 deletion content/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ type Program struct {
Type MediaType
}

var (
PodcastPlayOrderRandom bool
PodcastPlayerOrderOldest bool
)

func (p *Program) GetMedia() Media {
media := p.mediaFactory()
return media
Expand All @@ -36,7 +41,14 @@ func (p *Program) mediaFactory() Media {
podcast := m.(*Podcast)
podcast.Name = p.Name
podcast.URL = p.Source
podcast.PlayOrder = "newest" // TODO: Add support for random, oldest, and set from PlayOrder from config.
podcast.PlayOrder = playOrderNewest // default
if PodcastPlayerOrderOldest == true {
podcast.PlayOrder = playOrderOldest
}
if PodcastPlayOrderRandom == true {
podcast.PlayOrder = playOrderRandom
}

log.Debugf("returning podcast: %v", formatter.StructToString(podcast))
return podcast
case *WebRadio:
Expand Down
20 changes: 20 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ func main() {
Hidden: false,
Destination: &content.Shuffled,
},
cli.BoolFlag{
Name: "pod-oldest",
Usage: "podcasts will play starting with the oldest first",
Required: false,
Hidden: false,
Destination: &content.PodcastPlayerOrderOldest,
},
cli.BoolFlag{
Name: "pod-random",
Usage: "podcasts will play in a random order",
Required: false,
Hidden: false,
Destination: &content.PodcastPlayOrderRandom,
},
},
},
},
Expand All @@ -59,3 +73,9 @@ func main() {
log.Fatal(err)
}
}

func init() {
content.Shuffled = false
content.PodcastPlayerOrderOldest = false
content.PodcastPlayOrderRandom = false
}

0 comments on commit 0117136

Please sign in to comment.