mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-06 10:07:45 +08:00
update
This commit is contained in:
@@ -16,10 +16,10 @@ func (s *Server) searchTvWithTorznab(name string, season, episode int) []torznab
|
||||
|
||||
var res []torznab.Result
|
||||
allTorznab := s.db.GetAllTorznabInfo()
|
||||
for name, setting := range allTorznab {
|
||||
resp, err := torznab.Search(setting.URL, setting.ApiKey, q)
|
||||
for _, tor := range allTorznab {
|
||||
resp, err := torznab.Search(tor.URL, tor.ApiKey, q)
|
||||
if err != nil {
|
||||
log.Errorf("search %s error: %v", name, err)
|
||||
log.Errorf("search %s error: %v", tor.Name, err)
|
||||
continue
|
||||
}
|
||||
res = append(res, resp...)
|
||||
@@ -48,6 +48,14 @@ func (s *Server) AddTorznabInfo(c *gin.Context) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Server) GetAllIndexers(c *gin.Context) (interface{}, error) {
|
||||
indexers := s.db.GetAllTorznabInfo()
|
||||
if len(indexers) == 0 {
|
||||
return nil, fmt.Errorf("no indexer found")
|
||||
}
|
||||
return indexers, nil
|
||||
}
|
||||
|
||||
type searchAndDownloadIn struct {
|
||||
ID int `json:"id"`
|
||||
Season int `json:"season"`
|
||||
@@ -109,3 +117,11 @@ func (s *Server) AddDownloadClient(c *gin.Context) (interface{}, error) {
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Server) GetAllDonloadClients(c *gin.Context) (interface{}, error) {
|
||||
res := s.db.GetAllDonloadClients()
|
||||
if len(res) == 0 {
|
||||
return nil, fmt.Errorf("no download client")
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
@@ -64,12 +64,14 @@ func (s *Server) Serve() error {
|
||||
}
|
||||
indexer := api.Group("/indexer")
|
||||
{
|
||||
indexer.GET("/", HttpHandler(s.GetAllIndexers))
|
||||
indexer.POST("/add", HttpHandler(s.AddTorznabInfo))
|
||||
indexer.POST("/download", HttpHandler(s.SearchAndDownload))
|
||||
}
|
||||
|
||||
downloader := api.Group("/downloader")
|
||||
{
|
||||
downloader.GET("/", HttpHandler(s.GetAllDonloadClients))
|
||||
downloader.POST("/add", HttpHandler(s.AddDownloadClient))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user