mirror of
https://github.com/Superredstone/spotiflac-cli.git
synced 2026-06-17 16:44:40 +02:00
feat: add first metadata implementation
This commit is contained in:
+12
-1
@@ -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