Skip to content

Commit

Permalink
Add youtube playlists (#86)
Browse files Browse the repository at this point in the history
* Added playlist command and functionality for YoutubeProvide

* Added playlist struct

* Applied feedback

* fixes

* derefencen

Co-authored-by: Floris van Maldegem <[email protected]>
  • Loading branch information
fvanmaldegem and fvanmaldegem authored Oct 4, 2022
1 parent 5f259e2 commit f045a10
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/bot/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ var addPlaylistCommand = Command{
playlist, err := bot.musicPlayer.AddPlaylist(parameter)
if err != nil {
bot.ReplyToMessage(message, fmt.Sprintf("error: %v", err))
return
}

bot.ReplyToMessage(message, fmt.Sprintf("Started playing Playlist '%s' with %d songs", playlist.Title, playlist.Length()))
Expand Down
4 changes: 2 additions & 2 deletions pkg/music/dataprovider/youtube/youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
)

var youtubeURLRegex = regexp.MustCompile(`^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$`)
var youtubePlaylistUrlRegex = regexp.MustCompile(`^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/watch\?v=.+&list=.+$`)
var youtubePlaylistUrlRegex = regexp.MustCompile(`^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/(watch|playlist)\?(v=.+&)?list=.+$`)

type DataProvider struct {
apiKey string
Expand Down Expand Up @@ -180,7 +180,7 @@ func (provider *DataProvider) AddPlaylist(ytUrl string) (*music.Playlist, error)
if item.Kind != "youtube#playlist" {
continue
}
playlist.Title = item.Snippet.Title
playlist = music.Playlist{Title: item.Snippet.Title}
}

nextPageToken := ""
Expand Down

0 comments on commit f045a10

Please sign in to comment.