Helper to convert URI to ID

This commit is contained in:
aditya-K2
2023-04-18 01:06:26 +05:30
parent 7da271d561
commit 002d72d7db

View File

@@ -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
}