mirror of
https://github.com/ihabunek/twitch-dl
synced 2024-08-30 18:32:25 +00:00
Fix bug in accessing video qualities
This commit is contained in:
parent
28f1977d1c
commit
d6390bc7a2
@ -20,7 +20,7 @@ from twitchdl.entities import DownloadOptions
|
|||||||
from twitchdl.exceptions import ConsoleError
|
from twitchdl.exceptions import ConsoleError
|
||||||
from twitchdl.http import download_all
|
from twitchdl.http import download_all
|
||||||
from twitchdl.output import blue, bold, dim, green, print_log, yellow
|
from twitchdl.output import blue, bold, dim, green, print_log, yellow
|
||||||
from twitchdl.twitch import Chapter, Clip, Video
|
from twitchdl.twitch import Chapter, Clip, ClipAccessToken, Video
|
||||||
|
|
||||||
|
|
||||||
def download(ids: list[str], args: DownloadOptions):
|
def download(ids: list[str], args: DownloadOptions):
|
||||||
@ -211,8 +211,8 @@ def _crete_temp_dir(base_uri: str) -> str:
|
|||||||
return str(temp_dir)
|
return str(temp_dir)
|
||||||
|
|
||||||
|
|
||||||
def _get_clip_url(clip: Clip, quality: str) -> str:
|
def _get_clip_url(access_token: ClipAccessToken, quality: str) -> str:
|
||||||
qualities = clip["videoQualities"]
|
qualities = access_token["videoQualities"]
|
||||||
|
|
||||||
# Quality given as an argument
|
# Quality given as an argument
|
||||||
if quality:
|
if quality:
|
||||||
@ -250,8 +250,8 @@ def get_clip_authenticated_url(slug: str, quality: str):
|
|||||||
|
|
||||||
query = urlencode(
|
query = urlencode(
|
||||||
{
|
{
|
||||||
"sig": access_token["signature"],
|
"sig": access_token["playbackAccessToken"]["signature"],
|
||||||
"token": access_token["value"],
|
"token": access_token["playbackAccessToken"]["value"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -38,6 +38,12 @@ class VideoQuality(TypedDict):
|
|||||||
sourceURL: str
|
sourceURL: str
|
||||||
|
|
||||||
|
|
||||||
|
class ClipAccessToken(TypedDict):
|
||||||
|
id: str
|
||||||
|
playbackAccessToken: AccessToken
|
||||||
|
videoQualities: list[VideoQuality]
|
||||||
|
|
||||||
|
|
||||||
class Clip(TypedDict):
|
class Clip(TypedDict):
|
||||||
id: str
|
id: str
|
||||||
slug: str
|
slug: str
|
||||||
@ -183,7 +189,7 @@ def get_clip(slug: str) -> Clip | None:
|
|||||||
return response["data"]["clip"]
|
return response["data"]["clip"]
|
||||||
|
|
||||||
|
|
||||||
def get_clip_access_token(slug: str) -> AccessToken:
|
def get_clip_access_token(slug: str) -> ClipAccessToken:
|
||||||
query = f"""
|
query = f"""
|
||||||
{{
|
{{
|
||||||
"operationName": "VideoAccessToken_Clip",
|
"operationName": "VideoAccessToken_Clip",
|
||||||
@ -200,7 +206,7 @@ def get_clip_access_token(slug: str) -> AccessToken:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
response = gql_post(query.strip())
|
response = gql_post(query.strip())
|
||||||
return response["data"]["clip"]["playbackAccessToken"]
|
return response["data"]["clip"]
|
||||||
|
|
||||||
|
|
||||||
def get_channel_clips(channel_id: str, period: ClipsPeriod, limit: int, after: str | None = None):
|
def get_channel_clips(channel_id: str, period: ClipsPeriod, limit: int, after: str | None = None):
|
||||||
|
Loading…
Reference in New Issue
Block a user