feat: start download after save to db

This commit is contained in:
Simon Ding
2024-11-16 10:27:49 +08:00
parent b61b7f082e
commit 196ba6635f

View File

@@ -38,12 +38,6 @@ func (c *Client) DownloadEpisodeTorrent(r1 torznab.Result, seriesId, seasonNum i
return nil, errors.Errorf("converting link to magnet error, link: %v, error: %v", r1.Link, err)
}
torrent, err := trc.Download(magnet, downloadDir)
if err != nil {
return nil, errors.Wrap(err, "downloading")
}
torrent.Start()
dir := fmt.Sprintf("%s/Season %02d/", series.TargetDir, seasonNum)
if len(episodeNums) > 0 {
@@ -84,6 +78,12 @@ func (c *Client) DownloadEpisodeTorrent(r1 torznab.Result, seriesId, seasonNum i
return nil, errors.Wrap(err, "save record")
}
torrent, err := trc.Download(magnet, downloadDir)
if err != nil {
return nil, errors.Wrap(err, "downloading")
}
torrent.Start()
c.tasks[history.ID] = &Task{Torrent: torrent}
name := r1.Name