feat: add first metadata implementation

This commit is contained in:
2026-02-15 18:13:08 +01:00
parent 1ce9feb5e6
commit 5b557f1b1f
4 changed files with 1890 additions and 4 deletions

View File

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