Skip to content

Commit

Permalink
Fix AD check in status endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
doingodswork committed Oct 10, 2020
1 parent ff64939 commit d1fbba7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmd/deflix-stremio/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,10 @@ func createStatusHandler(magnetSearchers map[string]imdb2torrent.MagnetSearcher,
logger.Debug("statusHandler called", zap.String("request", fmt.Sprintf("%+v", &c.Fasthttp.Request)))

imdbID := c.Query("imdbid", "")
apiToken := c.Query("apitoken", "")
if imdbID == "" || apiToken == "" {
logger.Warn("\"/status\" was called without IMDb ID or API token")
rdToken := c.Query("rdtoken", "")
adKey := c.Query("adkey", "")
if imdbID == "" || rdToken == "" || adKey == "" {
logger.Warn("\"/status\" was called without IMDb ID or RD API token or AD API key")
c.SendStatus(fiber.StatusBadRequest)
}

Expand Down Expand Up @@ -333,7 +334,7 @@ func createStatusHandler(magnetSearchers map[string]imdb2torrent.MagnetSearcher,

res += "\t" + `"RD": {` + "\n"
startRD := time.Now()
streamURL, err := rdClient.GetStreamURL(c.Context(), bigBuckBunnyMagnet, apiToken, false)
streamURL, err := rdClient.GetStreamURL(c.Context(), bigBuckBunnyMagnet, rdToken, false)
if err != nil {
res += "\t\t" + `"err":"` + err.Error() + `",` + "\n"
} else {
Expand All @@ -347,7 +348,7 @@ func createStatusHandler(magnetSearchers map[string]imdb2torrent.MagnetSearcher,

res += "\t" + `"AD": {` + "\n"
startAD := time.Now()
streamURL, err = adClient.GetStreamURL(c.Context(), bigBuckBunnyMagnet, apiToken)
streamURL, err = adClient.GetStreamURL(c.Context(), bigBuckBunnyMagnet, adKey)
if err != nil {
res += "\t\t" + `"err":"` + err.Error() + `",` + "\n"
} else {
Expand Down

0 comments on commit d1fbba7

Please sign in to comment.