Fix for file namings

This commit is contained in:
Mukhtar Akere
2025-03-26 21:12:01 +01:00
parent 56bca562f4
commit 7bd38736b1
18 changed files with 731 additions and 288 deletions

View File

@@ -233,3 +233,15 @@ func GetInfohashFromURL(url string) (string, error) {
infoHash := hash.HexString()
return infoHash, nil
}
func ConstructMagnet(infoHash, name string) *Magnet {
// Create a magnet link from the infohash and name
name = url.QueryEscape(strings.TrimSpace(name))
magnetUri := fmt.Sprintf("magnet:?xt=urn:btih:%s&dn=%s", infoHash, name)
return &Magnet{
InfoHash: infoHash,
Name: name,
Size: 0,
Link: magnetUri,
}
}