mirror of
https://github.com/ihabunek/twitch-dl
synced 2024-08-30 18:32:25 +00:00
Pass request as content instead of data
data works, but should be used for form data passed as a dict, while content takes bytes or str
This commit is contained in:
parent
3c0f8a8ece
commit
3fa8bcef73
@ -87,10 +87,10 @@ class GQLError(click.ClickException):
|
|||||||
super().__init__(message)
|
super().__init__(message)
|
||||||
|
|
||||||
|
|
||||||
def authenticated_post(url, data=None, json=None, headers={}):
|
def authenticated_post(url, content=None, json=None, headers={}):
|
||||||
headers["Client-ID"] = CLIENT_ID
|
headers["Client-ID"] = CLIENT_ID
|
||||||
|
|
||||||
response = httpx.post(url, data=data, json=json, headers=headers)
|
response = httpx.post(url, content=content, json=json, headers=headers)
|
||||||
if response.status_code == 400:
|
if response.status_code == 400:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
raise ConsoleError(data["message"])
|
raise ConsoleError(data["message"])
|
||||||
@ -102,7 +102,7 @@ def authenticated_post(url, data=None, json=None, headers={}):
|
|||||||
|
|
||||||
def gql_post(query: str):
|
def gql_post(query: str):
|
||||||
url = "https://gql.twitch.tv/gql"
|
url = "https://gql.twitch.tv/gql"
|
||||||
response = authenticated_post(url, data=query)
|
response = authenticated_post(url, content=query)
|
||||||
gql_raise_on_error(response)
|
gql_raise_on_error(response)
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user