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

@@ -626,19 +626,19 @@ func getTorrentJS(tor *settings.Torrent) (*TorrentJsonResponse, error) {
if err == nil && len(tor.Name) < len(mag.DisplayName) {
js.Name = mag.DisplayName
}
mag.Trackers = []string{} //Remove retrackers for small link size
js.Magnet = tor.Magnet
js.Hash = tor.Hash
js.AddTime = tor.Timestamp
js.Length = tor.Size
//fname is fake param for file name
js.Playlist = "/torrent/play?link=" + url.QueryEscape(tor.Magnet) + "&m3u=true"
js.Playlist = "/torrent/play?link=" + url.QueryEscape(mag.String()) + "&m3u=true"
var size int64 = 0
for _, f := range tor.Files {
size += f.Size
tf := TorFile{
Name: f.Name,
Link: "/torrent/view/" + js.Hash + "/" + utils.CleanFName(f.Name),
Play: "/torrent/play?link=" + js.Magnet + "&file=" + fmt.Sprint(f.Id),
Play: "/torrent/play?link=" + mag.String() + "&file=" + fmt.Sprint(f.Id),
Preload: "/torrent/preload/" + js.Hash + "/" + utils.CleanFName(f.Name),
Size: f.Size,
Viewed: f.Viewed,

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