mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-08 21:37:58 -05:00
Helper to convert URI to ID
This commit is contained in:
11
spt/play.go
11
spt/play.go
@@ -1,6 +1,9 @@
|
||||
package spt
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/zmb3/spotify/v2"
|
||||
)
|
||||
|
||||
@@ -50,3 +53,11 @@ func TogglePlayback() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func UriToID(uri spotify.URI) (spotify.ID, error) {
|
||||
a := strings.Split(string(uri), ":")
|
||||
if len(a) != 3 {
|
||||
return "", errors.New("Error Decoding the URI")
|
||||
}
|
||||
return spotify.ID(a[2]), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user