From 91d71201f62261d8b1b6ad29eb3f43a236330078 Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Fri, 12 Mar 2021 12:09:18 +0300 Subject: [PATCH] add load torrent to bt client --- server/torr/apihelper.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/torr/apihelper.go b/server/torr/apihelper.go index 5eb5572..ee0b07f 100644 --- a/server/torr/apihelper.go +++ b/server/torr/apihelper.go @@ -21,6 +21,23 @@ func InitApiHelper(bt *BTServer) { bts = bt } +func LoadTorrent(tor *Torrent) *Torrent { + if tor.TorrentSpec == nil { + return nil + } + tr, err := NewTorrent(tor.TorrentSpec, bts) + if err != nil { + return nil + } + if !tr.WaitInfo() { + return nil + } + tr.Title = tor.Title + tr.Poster = tor.Poster + tr.Data = tor.Data + return tr +} + func AddTorrent(spec *torrent.TorrentSpec, title, poster string, data string) (*Torrent, error) { torr, err := NewTorrent(spec, bts) if err != nil {