Skip to content

Commit d568f43

Browse files
authored
plugins.youtube: fix consent dialog (#3672)
1 parent 0db69be commit d568f43

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/streamlink/plugins/youtube.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,20 @@ def _create_adaptive_streams(self, info, streams):
222222
return streams
223223

224224
def _find_video_id(self, url):
225-
226225
m = _url_re.match(url)
227226
if m.group("video_id"):
228227
log.debug("Video ID from URL")
229228
return m.group("video_id")
230229

231230
res = self.session.http.get(url)
231+
if urlparse(res.url).netloc == "consent.youtube.com":
232+
c_data = {}
233+
for _i in itertags(res.text, "input"):
234+
if _i.attributes.get("type") == "hidden":
235+
c_data[_i.attributes.get("name")] = _i.attributes.get("value")
236+
log.debug(f"c_data_keys: {', '.join(c_data.keys())}")
237+
res = self.session.http.post("https://consent.youtube.com/s", data=c_data)
238+
232239
datam = _ytdata_re.search(res.text)
233240
if datam:
234241
data = parse_json(datam.group(1))

0 commit comments

Comments
 (0)