all repos — fixyoutube-go @ c5f478be5cffb0aeb698446718dc8a50e3914c30

A better way to embed YouTube videos everywhere (inspired by FixTweet).

better invidious error handling
Bi-Rabittoh andronacomarco@gmail.com
Sun, 18 Feb 2024 13:15:14 +0100
commit

c5f478be5cffb0aeb698446718dc8a50e3914c30

parent

ca543233e814d5ac68644a39d8de37ee43f2119f

1 files changed, 5 insertions(+), 4 deletions(-)

jump to
M invidious/api.goinvidious/api.go

@@ -26,12 +26,13 @@ return nil, http.StatusInternalServerError

} defer resp.Body.Close() + if resp.StatusCode == http.StatusNotFound { + return nil, http.StatusNotFound + } + if resp.StatusCode != http.StatusOK { logger.Warn("Invidious gave the following status code: ", resp.StatusCode) - if resp.StatusCode == http.StatusForbidden { - return nil, http.StatusInternalServerError - } - return nil, http.StatusNotFound + return nil, resp.StatusCode } body, err := io.ReadAll(resp.Body)