【问题标题】:Getting video id "Live Stream" from Youtube从 Youtube 获取视频 ID“Live Stream”
【发布时间】:2020-11-28 02:54:00
【问题描述】:

我无法使用 YouTube API v3 获取实时视频 ID。我用"playlists"查询从频道中获取当前视频,可以,但是这个数据中没有直播。这个问题可以通过查询"search"来解决,但是它有100个配额,这不适合我。有谁知道这个问题的可能解决方案?

【问题讨论】:

    标签: youtube youtube-api


    【解决方案1】:

    我解决了这个问题,这是我在 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]
    

    【讨论】:

      猜你喜欢
      • 2012-09-08
      • 2014-12-15
      • 1970-01-01
      • 2016-09-28
      • 2017-08-25
      • 2021-02-10
      • 1970-01-01
      • 1970-01-01
      • 2016-05-13
      相关资源
      最近更新 更多