-
Notifications
You must be signed in to change notification settings - Fork 65
Add more info from youtube. #62
Copy link
Copy link
Open
Description
currently get_video only returns "videoPrimaryInfoRenderer" part from "ytInitialData". although for some other applications having "ytInitialPlayerResponse" would be useful. like storyboards thumbnails.
def get_video(
id: str,
) -> dict:
"""Get a single video.
Parameters:
id (``str``):
The video id from the video you want to get.
"""
session = get_session()
url = f"https://www.youtube.com/watch?v={id}"
html = get_initial_data(session, url)
client = json.loads(
get_json_from_html(html, "INNERTUBE_CONTEXT", 2, '"}},') + '"}}'
)["client"]
session.headers["X-YouTube-Client-Name"] = "1"
session.headers["X-YouTube-Client-Version"] = client["clientVersion"]
data = json.loads(
get_json_from_html(html, "var ytInitialData = ", 0, "};") + "}"
)
ytInitialPlayerResponse = json.loads(
get_json_from_html(html, "var ytInitialPlayerResponse = ", 0, "};") + "}"
)
returning = next(search_dict(data, "videoPrimaryInfoRenderer"))
returning['ytInitialPlayerResponse'] = ytInitialPlayerResponse
return returningsomething like this would be appreciated.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels