Skip to content

Commit 24e25e2

Browse files
authored
plugins.youtube: fix live playback (#3268)
Closes #3263 check for valid canonical URL The video_id "live_stream" is not a live stream id
1 parent df6ab12 commit 24e25e2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/streamlink/plugins/youtube.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ def _find_video_id(self, url):
255255
log.debug("Video ID from currentVideoEndpoint")
256256
return video_id
257257
for x in search_dict(data, 'videoRenderer'):
258+
if x.get("viewCountText", {}).get("runs"):
259+
if x.get("videoId"):
260+
log.debug("Video ID from videoRenderer (live)")
261+
return x["videoId"]
258262
for bstyle in search_dict(x.get("badges", {}), "style"):
259263
if bstyle == "BADGE_STYLE_TYPE_LIVE_NOW":
260264
if x.get("videoId"):
@@ -266,8 +270,12 @@ def _find_video_id(self, url):
266270
if link.attributes.get("rel") == "canonical":
267271
canon_link = link.attributes.get("href")
268272
if canon_link != url:
269-
log.debug("Re-directing to canonical URL: {0}".format(canon_link))
270-
return self._find_video_id(canon_link)
273+
if canon_link.endswith("v=live_stream"):
274+
log.debug("The video is not available")
275+
break
276+
else:
277+
log.debug("Re-directing to canonical URL: {0}".format(canon_link))
278+
return self._find_video_id(canon_link)
271279

272280
raise PluginError("Could not find a video on this page")
273281

0 commit comments

Comments
 (0)