mirror of
https://github.com/Superredstone/spotiflac-cli.git
synced 2026-03-07 20:18:07 +01:00
feat: add playlist download
This commit is contained in:
14
lib/utils.go
14
lib/utils.go
@@ -15,6 +15,10 @@ const (
|
||||
UrlTypePlaylist
|
||||
)
|
||||
|
||||
const (
|
||||
BASE_SPOTIFY_TRACK_URL = "https://open.spotify.com/track/"
|
||||
)
|
||||
|
||||
func ParseUrlType(url string) (UrlType, error) {
|
||||
if strings.Contains(url, "https://open.spotify.com/track") {
|
||||
return UrlTypeTrack, nil
|
||||
@@ -131,3 +135,13 @@ func (app *App) InitSpotifyClient() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func SpotifyUriToLink(uri string) (string, error) {
|
||||
spotifyId := strings.Split(uri, ":")
|
||||
|
||||
if len(spotifyId) != 3 {
|
||||
return "", errors.New("Invalid URI parsed.")
|
||||
}
|
||||
|
||||
return BASE_SPOTIFY_TRACK_URL + spotifyId[2], nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user