tstor/daemons/ytdlp/ytdlp.go
royalcat 585f317478
Some checks failed
docker / build-docker (push) Failing after 34s
daemons separation
2024-11-24 20:32:26 +03:00

29 lines
448 B
Go

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