mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-06 15:10:49 +08:00
fix: do not convert torrent to magnet link
This commit is contained in:
@@ -60,6 +60,10 @@ func (c *Client) GetAll() ([]pkg.Torrent, error) {
|
||||
}
|
||||
|
||||
func (c *Client) Download(link, dir string) (pkg.Torrent, error) {
|
||||
err := c.c.DownloadLinks([]string{link}, qbt.DownloadOptions{Savepath: &dir, Category: &c.category})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "qbt download")
|
||||
}
|
||||
magnet, err := utils.Link2Magnet(link)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", link, err)
|
||||
@@ -69,10 +73,7 @@ func (c *Client) Download(link, dir string) (pkg.Torrent, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get hash")
|
||||
}
|
||||
err = c.c.DownloadLinks([]string{magnet}, qbt.DownloadOptions{Savepath: &dir, Category: &c.category})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "qbt download")
|
||||
}
|
||||
|
||||
return &Torrent{hash: hash, c: c.c}, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -61,6 +61,16 @@ func (c *Client) GetAll() ([]pkg.Torrent, error) {
|
||||
}
|
||||
|
||||
func (c *Client) Download(link, dir string) (pkg.Torrent, error) {
|
||||
|
||||
t, err := c.c.TorrentAdd(context.TODO(), transmissionrpc.TorrentAddPayload{
|
||||
Filename: &link,
|
||||
DownloadDir: &dir,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Debugf("get torrent info: %+v", t)
|
||||
|
||||
magnet, err := utils.Link2Magnet(link)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", link, err)
|
||||
@@ -71,12 +81,6 @@ func (c *Client) Download(link, dir string) (pkg.Torrent, error) {
|
||||
return nil, errors.Wrap(err, "get hash")
|
||||
}
|
||||
|
||||
t, err := c.c.TorrentAdd(context.TODO(), transmissionrpc.TorrentAddPayload{
|
||||
Filename: &magnet,
|
||||
DownloadDir: &dir,
|
||||
})
|
||||
log.Debugf("get torrent info: %+v", t)
|
||||
|
||||
return &Torrent{
|
||||
hash: hash,
|
||||
c: c.c,
|
||||
|
||||
12
pkg/utils/utils_test.go
Normal file
12
pkg/utils/utils_test.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"polaris/log"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLink2Magnet(t *testing.T) {
|
||||
s, err := Link2Magnet("https://api.m-team.cc/api/rss/dlv2?useHttps=true&type=ipv6&sign=2ecfdb9d1317fce1edc123d024be1d65&t=1738309528&tid=900434&uid=346577")
|
||||
log.Errorf("%v", err)
|
||||
log.Infof("%v", s)
|
||||
}
|
||||
@@ -33,10 +33,10 @@ func (c *Client) DownloadEpisodeTorrent(r1 torznab.Result, seriesId, seasonNum i
|
||||
return nil, errors.New("no enough space")
|
||||
}
|
||||
|
||||
magnet, err := utils.Link2Magnet(r1.Link)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", r1.Link, err)
|
||||
}
|
||||
// magnet, err := utils.Link2Magnet(r1.Link)
|
||||
// if err != nil {
|
||||
// return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", r1.Link, err)
|
||||
// }
|
||||
|
||||
dir := fmt.Sprintf("%s/Season %02d/", series.TargetDir, seasonNum)
|
||||
|
||||
@@ -70,7 +70,7 @@ func (c *Client) DownloadEpisodeTorrent(r1 torznab.Result, seriesId, seasonNum i
|
||||
Status: history.StatusRunning,
|
||||
Size: int(r1.Size),
|
||||
//Saved: torrent.Save(),
|
||||
Link: magnet,
|
||||
Link: r1.Link,
|
||||
DownloadClientID: dlc.ID,
|
||||
IndexerID: r1.IndexerId,
|
||||
})
|
||||
@@ -78,7 +78,7 @@ func (c *Client) DownloadEpisodeTorrent(r1 torznab.Result, seriesId, seasonNum i
|
||||
return nil, errors.Wrap(err, "save record")
|
||||
}
|
||||
|
||||
torrent, err := trc.Download(magnet, downloadDir)
|
||||
torrent, err := trc.Download(r1.Link, downloadDir)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "downloading")
|
||||
}
|
||||
@@ -197,12 +197,12 @@ func (c *Client) DownloadMovie(m *ent.Media, link, name string, size int64, inde
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "connect transmission")
|
||||
}
|
||||
magnet, err := utils.Link2Magnet(link)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", link, err)
|
||||
}
|
||||
// magnet, err := utils.Link2Magnet(link)
|
||||
// if err != nil {
|
||||
// return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", link, err)
|
||||
// }
|
||||
|
||||
torrent, err := trc.Download(magnet, c.db.GetDownloadDir())
|
||||
torrent, err := trc.Download(link, c.db.GetDownloadDir())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "downloading")
|
||||
}
|
||||
@@ -221,7 +221,7 @@ func (c *Client) DownloadMovie(m *ent.Media, link, name string, size int64, inde
|
||||
Status: history.StatusRunning,
|
||||
Size: int(size),
|
||||
//Saved: torrent.Save(),
|
||||
Link: magnet,
|
||||
Link: link,
|
||||
DownloadClientID: dlc.ID,
|
||||
IndexerID: indexerID,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user