mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
remove long link from m3u
This commit is contained in:
@@ -626,19 +626,19 @@ func getTorrentJS(tor *settings.Torrent) (*TorrentJsonResponse, error) {
|
|||||||
if err == nil && len(tor.Name) < len(mag.DisplayName) {
|
if err == nil && len(tor.Name) < len(mag.DisplayName) {
|
||||||
js.Name = mag.DisplayName
|
js.Name = mag.DisplayName
|
||||||
}
|
}
|
||||||
|
mag.Trackers = []string{} //Remove retrackers for small link size
|
||||||
js.Magnet = tor.Magnet
|
js.Magnet = tor.Magnet
|
||||||
js.Hash = tor.Hash
|
js.Hash = tor.Hash
|
||||||
js.AddTime = tor.Timestamp
|
js.AddTime = tor.Timestamp
|
||||||
js.Length = tor.Size
|
js.Length = tor.Size
|
||||||
//fname is fake param for file name
|
js.Playlist = "/torrent/play?link=" + url.QueryEscape(mag.String()) + "&m3u=true"
|
||||||
js.Playlist = "/torrent/play?link=" + url.QueryEscape(tor.Magnet) + "&m3u=true"
|
|
||||||
var size int64 = 0
|
var size int64 = 0
|
||||||
for _, f := range tor.Files {
|
for _, f := range tor.Files {
|
||||||
size += f.Size
|
size += f.Size
|
||||||
tf := TorFile{
|
tf := TorFile{
|
||||||
Name: f.Name,
|
Name: f.Name,
|
||||||
Link: "/torrent/view/" + js.Hash + "/" + utils.CleanFName(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),
|
Preload: "/torrent/preload/" + js.Hash + "/" + utils.CleanFName(f.Name),
|
||||||
Size: f.Size,
|
Size: f.Size,
|
||||||
Viewed: f.Viewed,
|
Viewed: f.Viewed,
|
||||||
|
|||||||
@@ -15,7 +15,16 @@ func MakeM3ULists(torrents []*settings.Torrent, host string) string {
|
|||||||
|
|
||||||
for _, t := range torrents {
|
for _, t := range torrents {
|
||||||
m3u += "#EXTINF:-1 type=\"playlist\", " + t.Name + "\n"
|
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
|
return m3u
|
||||||
}
|
}
|
||||||
@@ -23,6 +32,13 @@ func MakeM3ULists(torrents []*settings.Torrent, host string) string {
|
|||||||
func MakeM3UPlayList(tor torr.TorrentStats, magnet string, host string) string {
|
func MakeM3UPlayList(tor torr.TorrentStats, magnet string, host string) string {
|
||||||
m3u := "#EXTM3U\n"
|
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 {
|
for _, f := range tor.FileStats {
|
||||||
if GetMimeType(f.Path) != "*/*" {
|
if GetMimeType(f.Path) != "*/*" {
|
||||||
fn := filepath.Base(f.Path)
|
fn := filepath.Base(f.Path)
|
||||||
@@ -30,8 +46,7 @@ func MakeM3UPlayList(tor torr.TorrentStats, magnet string, host string) string {
|
|||||||
fn = f.Path
|
fn = f.Path
|
||||||
}
|
}
|
||||||
m3u += "#EXTINF:-1, " + fn + "\n"
|
m3u += "#EXTINF:-1, " + fn + "\n"
|
||||||
mag := url.QueryEscape(magnet)
|
m3u += host + "/torrent/play?link=" + magnet + "&file=" + fmt.Sprint(f.Id) + "\n\n"
|
||||||
m3u += host + "/torrent/play?link=" + mag + "&file=" + fmt.Sprint(f.Id) + "\n\n"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return m3u
|
return m3u
|
||||||
|
|||||||
Reference in New Issue
Block a user