From aa5f17cbdbfeb5372925fad3edd423dda7ab9f88 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Mon, 12 Aug 2019 15:14:13 +0200 Subject: [PATCH] Show errors returned via HTTP 400 --- twitchdl/twitch.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/twitchdl/twitch.py b/twitchdl/twitch.py index f1d7ade..b261da1 100644 --- a/twitchdl/twitch.py +++ b/twitchdl/twitch.py @@ -1,6 +1,7 @@ import requests from twitchdl import CLIENT_ID +from twitchdl.exceptions import ConsoleError from twitchdl.parse import parse_playlists, parse_playlist @@ -8,6 +9,10 @@ def authenticated_get(url, params={}): headers = {'Client-ID': CLIENT_ID} response = requests.get(url, params, headers=headers) + if response.status_code == 400: + data = response.json() + raise ConsoleError(data["message"]) + response.raise_for_status() return response