mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 03:27:39 +08:00
feat: download per media feature
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"polaris/log"
|
||||
"polaris/pkg/torznab"
|
||||
"polaris/server/core"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pkg/errors"
|
||||
@@ -167,3 +168,21 @@ func (s *Server) DownloadTorrent(c *gin.Context) (interface{}, error) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *Server) DownloadAll(c *gin.Context) (interface{}, error) {
|
||||
ids := c.Param("id")
|
||||
id, err := strconv.Atoi(ids)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "convert")
|
||||
}
|
||||
m, err := s.db.GetMedia(id)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get media")
|
||||
}
|
||||
if m.MediaType == media.MediaTypeTv {
|
||||
return s.core.DownloadSeriesAllEpisodes(m.ID)
|
||||
}
|
||||
name, err := s.core.DownloadMovieByID(m.ID)
|
||||
|
||||
return []string{name}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user