I'm having trouble getting the video ID, which is live, using YouTube API v3. I use the "playlists" query to get the current videos from the channel, all right, but there is no live broadcast in this data. The problem can be solved by applying the query "search", but it weighs 100 quotas, and this is not suitable for me. Does anyone know a possible solution to this problem?
I solved this problem, here is my code on python.
from lxml import html
import requests
page = requests.get(f"https://www.youtube.com/embed/live_stream?channel={channel_id}")
if page.status_code == 200:
tree = html.fromstring(page.content)
links = tree.xpath('//link[@rel="canonical"]')
if links:
id = links[0].attrib['href'].split("watch?v=")[1]
Collected from the Internet
Please contact javaer1[email protected] to delete if infringement.
Comments