Fix repair worker
This commit is contained in:
+6
-4
@@ -3,7 +3,6 @@ package arr
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
@@ -15,9 +14,7 @@ func (a *Arr) GetMedia(tvId string) ([]Content, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if resp.StatusCode == http.StatusNotFound {
|
if resp.StatusCode == http.StatusNotFound {
|
||||||
// This is Radarr
|
// This is likely Radarr
|
||||||
log.Println("Radarr detected")
|
|
||||||
a.Type = Radarr
|
|
||||||
return GetMovies(a, tvId)
|
return GetMovies(a, tvId)
|
||||||
}
|
}
|
||||||
a.Type = Sonarr
|
a.Type = Sonarr
|
||||||
@@ -87,6 +84,11 @@ func GetMovies(a *Arr, tvId string) ([]Content, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if resp.StatusCode == http.StatusNotFound {
|
||||||
|
// This is likely Lidarr or Readarr
|
||||||
|
return nil, fmt.Errorf("failed to get movies: %s", resp.Status)
|
||||||
|
}
|
||||||
|
a.Type = Radarr
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
var movies []Movie
|
var movies []Movie
|
||||||
if err = json.NewDecoder(resp.Body).Decode(&movies); err != nil {
|
if err = json.NewDecoder(resp.Body).Decode(&movies); err != nil {
|
||||||
|
|||||||
@@ -156,9 +156,9 @@ func (r *Repair) Start(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
case t := <-ticker.C:
|
case t := <-ticker.C:
|
||||||
r.logger.Info().Msgf("Running repair at %v", t.Format("15:04:05"))
|
r.logger.Info().Msgf("Running repair at %v", t.Format("15:04:05"))
|
||||||
if err := r.Repair(r.arrs.GetAll(), []string{}); err != nil {
|
err := r.Repair(r.arrs.GetAll(), []string{})
|
||||||
|
if err != nil {
|
||||||
r.logger.Info().Msgf("Error during repair: %v", err)
|
r.logger.Info().Msgf("Error during repair: %v", err)
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If using time-of-day schedule, reset the ticker for next day
|
// If using time-of-day schedule, reset the ticker for next day
|
||||||
|
|||||||
Reference in New Issue
Block a user