remove long link from m3u

This commit is contained in:
YouROK
2020-04-29 11:45:27 +03:00
parent 524c2604c8
commit 3a70e8cf1c
2 changed files with 21 additions and 6 deletions

View File

@@ -15,7 +15,16 @@ func MakeM3ULists(torrents []*settings.Torrent, host string) string {
for _, t := range torrents {
m3u += "#EXTINF:-1 type=\"playlist\", " + t.Name + "\n"
m3u += host + "/torrent/play?link=" + url.QueryEscape(t.Magnet) + "&m3u=true&fname=" + utils.CleanFName(t.Name+".m3u") + "\n\n"
magnet := t.Magnet
mag, _, err := GetMagnet(magnet)
if err == nil {
mag.Trackers = []string{} //Remove retrackers for small link size
magnet = mag.String()
}
magnet = url.QueryEscape(magnet)
m3u += host + "/torrent/play?link=" + url.QueryEscape(magnet) + "&m3u=true&fname=" + utils.CleanFName(t.Name+".m3u") + "\n\n"
}
return m3u
}
@@ -23,6 +32,13 @@ func MakeM3ULists(torrents []*settings.Torrent, host string) string {
func MakeM3UPlayList(tor torr.TorrentStats, magnet string, host string) string {
m3u := "#EXTM3U\n"
mag, _, err := GetMagnet(magnet)
if err == nil {
mag.Trackers = []string{} //Remove retrackers for small link size
magnet = mag.String()
}
magnet = url.QueryEscape(magnet)
for _, f := range tor.FileStats {
if GetMimeType(f.Path) != "*/*" {
fn := filepath.Base(f.Path)
@@ -30,8 +46,7 @@ func MakeM3UPlayList(tor torr.TorrentStats, magnet string, host string) string {
fn = f.Path
}
m3u += "#EXTINF:-1, " + fn + "\n"
mag := url.QueryEscape(magnet)
m3u += host + "/torrent/play?link=" + mag + "&file=" + fmt.Sprint(f.Id) + "\n\n"
m3u += host + "/torrent/play?link=" + magnet + "&file=" + fmt.Sprint(f.Id) + "\n\n"
}
}
return m3u