【问题标题】:Issue getting the IDs of trending news videos on YouTube?在 YouTube 上获取热门新闻视频的 ID 时遇到问题?
【发布时间】:2021-05-03 18:32:02
【问题描述】:

我一直在尝试使用 YouTube 数据 API 从美国获取热门新闻视频。但是,虽然我没有收到错误,但我没有收到任何结果。我很难相信没有结果,因为 YouTube 的热门新闻页面显示了很多视频。

我得到了什么:

{'kind': 'youtube#videoListResponse', 'etag': 'KtFSnIG_fmDzS9uX1a7JuXFZJbk', 'items': [], 'pageInfo': {'totalResults': 0, 'resultsPerPage': 5}}

我的代码:

youtube = build("youtube","v3", developerKey=apiKey)

  
request = youtube.videos().list(
    part = "id",
    chart = "mostPopular",
    regionCode = "US",
    videoCategoryId = "25"
)

response = request.execute()

print(response)

【问题讨论】:

  • 我确认复制您的问题。删除videoCategoryId或将其更改为10,我确实获得了视频ID列表。我建议通过其own issue tracker site 直接向 Google 提交错误报告。
  • @stvar 好的,我会提交一份大报告
  • Here 是错误报告的链接。

标签: youtube-api youtube-data-api google-api-python-client


【解决方案1】:

试试这个,看看效果如何。

result = self.youtube.search().list(
        part="snippet",
        regionCode="US",
        videoCategoryId = 25,
        order="viewCount",
        type="video",
    ).execute()

    for item in result['items']:
        print()
        print(item["id"]["videoId"])
    return result

一切顺利。

【讨论】:

  • 那行不通。我没有收到 YouTube 的热门新闻。
猜你喜欢
  • 2018-04-18
  • 2014-07-28
  • 2017-09-17
  • 2018-02-13
  • 2023-03-09
  • 1970-01-01
  • 2017-07-01
  • 1970-01-01
  • 2016-08-23
相关资源
最近更新 更多