diff --git a/Dockerfile b/Dockerfile index c63f5bb..6936aef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,11 +9,13 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ FROM alpine -RUN apk --no-cache add --no-check-certificate ca-certificates \ +RUN apk --no-cache add --no-check-certificate ca-certificates dumb-init \ && update-ca-certificates COPY --from=build /app/main /ryd-proxy +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + EXPOSE 3000 -CMD [ "/ryd-proxy" ] +CMD "/ryd-proxy" diff --git a/main.go b/main.go index 152c11b..cd2a0f3 100644 --- a/main.go +++ b/main.go @@ -77,7 +77,7 @@ func getVotes(c *fiber.Ctx, videoId string) error { return c.Status(400).SendString("Invalid video id") } - for true { + for { req, _ := http.NewRequest("GET", "https://returnyoutubedislikeapi.com/Votes?videoId="+videoId+"&likeCount=", nil) req.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0") @@ -91,7 +91,13 @@ func getVotes(c *fiber.Ctx, videoId string) error { resp, err := client.Do(req) - if err != nil || resp.StatusCode == 429 { + if err != nil { + continue + } + + defer resp.Body.Close() + + if resp.StatusCode == 429 { continue } @@ -109,7 +115,4 @@ func getVotes(c *fiber.Ctx, videoId string) error { return c.Status(resp.StatusCode).SendStream(stream) } - - // Should never be reached - return nil }