mirror of
https://github.com/Superredstone/spotiflac-cli.git
synced 2026-03-07 20:18:07 +01:00
feat: add first metadata implementation
This commit is contained in:
13
lib/utils.go
13
lib/utils.go
@@ -1,6 +1,7 @@
|
||||
package lib
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -12,7 +13,7 @@ const (
|
||||
UrlTypeInvalid
|
||||
)
|
||||
|
||||
func GetUrlType(url string) UrlType {
|
||||
func ParseUrlType(url string) UrlType {
|
||||
if strings.Contains(url, "https://open.spotify.com/track") {
|
||||
return UrlTypeTrack
|
||||
}
|
||||
@@ -23,3 +24,13 @@ func GetUrlType(url string) UrlType {
|
||||
|
||||
return UrlTypeInvalid
|
||||
}
|
||||
|
||||
func ParseTrackId(url string) (string, error) {
|
||||
tmp := strings.Split(url, "/")
|
||||
|
||||
if len(tmp) == 0 {
|
||||
return "", errors.New("Invalid URL.")
|
||||
}
|
||||
|
||||
return tmp[len(tmp)-1], nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user