mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
add files info to data on add to db
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package torr
|
package torr
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"server/settings"
|
"server/settings"
|
||||||
@@ -9,11 +10,25 @@ import (
|
|||||||
"github.com/anacrolix/torrent/metainfo"
|
"github.com/anacrolix/torrent/metainfo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type tsFiles struct {
|
||||||
|
TorrServer struct {
|
||||||
|
Files []*state.TorrentFileStat `json:"Files"`
|
||||||
|
} `json:"TorrServer"`
|
||||||
|
}
|
||||||
|
|
||||||
func AddTorrentDB(torr *Torrent) {
|
func AddTorrentDB(torr *Torrent) {
|
||||||
t := new(settings.TorrentDB)
|
t := new(settings.TorrentDB)
|
||||||
t.TorrentSpec = torr.TorrentSpec
|
t.TorrentSpec = torr.TorrentSpec
|
||||||
t.Title = torr.Title
|
t.Title = torr.Title
|
||||||
t.Data = torr.Data
|
if torr.Data == "" {
|
||||||
|
files := new(tsFiles)
|
||||||
|
files.TorrServer.Files = torr.Status().FileStats
|
||||||
|
buf, _ := json.Marshal(files)
|
||||||
|
t.Data = string(buf)
|
||||||
|
torr.Data = t.Data
|
||||||
|
} else {
|
||||||
|
t.Data = torr.Data
|
||||||
|
}
|
||||||
t.Poster = torr.Poster
|
t.Poster = torr.Poster
|
||||||
t.Size = torr.Size
|
t.Size = torr.Size
|
||||||
if t.Size == 0 && torr.Torrent != nil {
|
if t.Size == 0 && torr.Torrent != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user