package ytdlp import ( "crypto/sha1" "encoding/base64" "strings" ) type Source struct { Url string `json:"url"` } var hasher = sha1.New() var prefixCutset = [...]string{ "https://", "http://", "www.", } func urlHash(url string) string { for _, v := range prefixCutset { url = strings.TrimPrefix(url, v) } return base64.URLEncoding.EncodeToString(hasher.Sum([]byte(url))) } func (s *Source) Name() string { return urlHash(s.Url) }