mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-20 05:56:10 +05:00
add play link and file id
This commit is contained in:
@@ -68,6 +68,7 @@ type TorrentJsonResponse struct {
|
|||||||
type TorFile struct {
|
type TorFile struct {
|
||||||
Name string
|
Name string
|
||||||
Link string
|
Link string
|
||||||
|
Play string
|
||||||
Preload string
|
Preload string
|
||||||
Size int64
|
Size int64
|
||||||
Viewed bool
|
Viewed bool
|
||||||
@@ -592,14 +593,14 @@ func toTorrentDB(t *torr.Torrent) *settings.Torrent {
|
|||||||
mi := t.Torrent.Metainfo()
|
mi := t.Torrent.Metainfo()
|
||||||
tor.Magnet = mi.Magnet(t.Name(), t.Torrent.InfoHash()).String()
|
tor.Magnet = mi.Magnet(t.Name(), t.Torrent.InfoHash()).String()
|
||||||
tor.Size = t.Length()
|
tor.Size = t.Length()
|
||||||
files := t.Files()
|
|
||||||
sort.Slice(files, func(i, j int) bool {
|
st := getTorPlayState(t)
|
||||||
return files[i].Path() < files[j].Path()
|
|
||||||
})
|
for _, f := range st.FileStats {
|
||||||
for _, f := range files {
|
|
||||||
tf := settings.File{
|
tf := settings.File{
|
||||||
Name: f.Path(),
|
Id: f.Id,
|
||||||
Size: f.Length(),
|
Name: f.Path,
|
||||||
|
Size: f.Length,
|
||||||
Viewed: false,
|
Viewed: false,
|
||||||
}
|
}
|
||||||
tor.Files = append(tor.Files, tf)
|
tor.Files = append(tor.Files, tf)
|
||||||
@@ -626,6 +627,7 @@ func getTorrentJS(tor *settings.Torrent) (*TorrentJsonResponse, error) {
|
|||||||
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),
|
||||||
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,
|
||||||
|
|||||||
Reference in New Issue
Block a user