Skip to content

plugins.youtube: fix consent dialog #3672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 3, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/streamlink/plugins/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,21 @@ def _create_adaptive_streams(self, info, streams):
return streams

def _find_video_id(self, url):

m = _url_re.match(url)
if m.group("video_id"):
log.debug("Video ID from URL")
return m.group("video_id")

res = self.session.http.get(url)
if urlparse(res.url).netloc == "consent.youtube.com":
c_data = {}
for _i in itertags(res.text, "input"):
if _i.attributes.get("type") == "hidden":
c_data[_i.attributes.get("name")] = _i.attributes.get("value")
log.debug(f"c_data_keys: {', '.join(c_data.keys())}")
self.session.http.post("https://consent.youtube.com/s", data=c_data)
res = self.session.http.get(url)

datam = _ytdata_re.search(res.text)
if datam:
data = parse_json(datam.group(1))
Expand Down