Skip to content

Commit

Permalink
fix: reshuffling not working
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanleo committed May 6, 2020
1 parent a58e68d commit d7f7f02
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion models/guild_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func (guildSession *GuildSession) Loop() {
if err == nil {
volume = volumeConv
}
guildSession.PlayYouTube(fmt.Sprintf("https://www.youtube.com/watch?v=%s", song.VideoID), volume)
guildSession.History = append(guildSession.History, song.VideoID)
guildSession.PlayYouTube(fmt.Sprintf("https://www.youtube.com/watch?v=%s", song.VideoID), volume)
guildSession.RWMutex.Lock()
if len(guildSession.Queue) > 0 {
guildSession.Queue = guildSession.Queue[1:]
Expand Down
4 changes: 3 additions & 1 deletion util/youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func GenerateAutoPlaylistQueueItem(videoIdsToAvoid []string) (*youtube.PlaylistI
return nil, fmt.Errorf("Nothing in cache, unable to generate")
}

for chosenListing == nil || chosenListing.Snippet == nil {
for {
chosenListing = autoPlaylistItemCache[rand.Intn(len(autoPlaylistItemCache))]

snippetsResp, err := youtubeService.
Expand All @@ -120,6 +120,7 @@ func GenerateAutoPlaylistQueueItem(videoIdsToAvoid []string) (*youtube.PlaylistI

if stringInSlice(snippetsResp.Items[0].Id, videoIdsToAvoid) {
// Played before
log.Println("Reshuffling, played before")
continue
}

Expand All @@ -128,6 +129,7 @@ func GenerateAutoPlaylistQueueItem(videoIdsToAvoid []string) (*youtube.PlaylistI
ChannelTitle: snippetsResp.Items[0].Snippet.ChannelTitle,
Thumbnails: snippetsResp.Items[0].Snippet.Thumbnails,
}
break

}

Expand Down

0 comments on commit d7f7f02

Please sign in to comment.