【问题标题】:Youtube video id (or URL) to "user" and "channel"Youtube 视频 ID(或 URL)到“用户”和“频道”
【发布时间】:2026-01-01 19:35:01
【问题描述】:

给定一个 Youtube 视频的 URL 或 ID,是否可以获取 (1) 上传该视频的“用户”的名称和 (2) 该视频所属的频道?如果有,API 请求是什么?

因此,例如:假设我有一个视频 ID:“VulCl5QfewE”,对应的视频位于:https://www.youtube.com/watch?v=VulCl5QfewE

  1. 然后我想提取用户名,即:“TheYoungTurks”,用户的 URL 是: https://www.youtube.com/user/TheYoungTurks

  2. 我还希望能够提取频道名称,即:“UC1yBKRuGpC1tSM73A0ZjYjQ”,频道网址为:

https://www.youtube.com/channel/UC1yBKRuGpC1tSM73A0ZjYjQ

最后,(作为“侧面,辅助问题”)我有点困惑“渠道”和“用户”之间的区别。一个用户可以有多个频道吗?我确实在这里阅读了链接:https://www.reddit.com/r/youtube/comments/2vsyit/whats_the_difference_between_user_and_channel/,但我正在尝试了解它背后的用例。

干杯

【问题讨论】:

    标签: youtube youtube-api youtube-data-api android-youtube-api youtube-channels


    【解决方案1】:

    如果你想从一个videoId中获取频道信息,你需要使用资源videos.list和参数:

    part: snippet
    id: "VulCl5QfewE" //for example
    
    GET https://www.googleapis.com/youtube/v3/videos?part=snippet&id=VulCl5QfewE&key={YOUR_API_KEY}
    

    结果显示用户的频道ID:

     "items": [
      {
    
       "kind": "youtube#video",
       "etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/IcNtD4uunskZTQuIeM0YQRcc5HY\"",
       "id": "VulCl5QfewE",
       "snippet": {
        "publishedAt": "2015-08-05T01:11:24.000Z",
        "channelId": "UC1yBKRuGpC1tSM73A0ZjYjQ",
    

    然后使用此信息获取资源为channel.list的频道名称

    part: snippet
    id: UC1yBKRuGpC1tSM73A0ZjYjQ
    
    GET https://www.googleapis.com/youtube/v3/channels?part=snippet&id=UC1yBKRuGpC1tSM73A0ZjYjQ&key={YOUR_API_KEY}
    

    部分结果:

      "snippet": {
        "title": "The Young Turks",
        "description": "The Largest Online News Show in the World. Hosted by Cenk Uygur & Ana Kasparian. LIVE weekdays 6-8pm ET. \n\nYoung Turk (n), 1. Young progressive or insurgent member of an institution, movement, or political party. 2. Young person who rebels against authority or societal expectations. (American Heritage Dictionary)\n\nThe Young Turks were the first original talk show on Sirius satellite radio and the first live, daily webcast on the internet. But that is not the revolution.\n\nWe are a rare show that combines all of the news that people care about in one place. We are not afraid to talk about politics and entertainment and sports and pop culture. But that is not the revolution either. \n\nGet The Young Turks\u200b Mobile App Today! \n\nDownload the iOS version here: https://itunes.apple.com/us/app/the-young-turks/id412793195? \n\nDownload the Android version here: https://play.google.com/store/apps/details?id=com.tyt",
        "publishedAt": "2005-12-21T20:46:51.000Z",
    

    最后,(作为“附带的辅助问题”)我有点困惑什么是 “渠道”和“用户”的区别。用户能否拥有 多个渠道?我确实在这里阅读了链接: https://www.reddit.com/r/youtube/comments/2vsyit/whats_the_difference_between_user_and_channel/ 但我试图了解它背后的用例。

    有一个与 Google+ 帐户的链接,请查看https://productforums.google.com/forum/#!topic/youtube/3MsBApaK2Hw

    【讨论】:

    • 为了给出一些上下文,给定一个视频,我试图获取该用户最近上传的 5 次。所以你的意思是如果我从频道获得 5 个最近上传的内容,它是一样的吗?无论如何,有没有办法获取用户名,因为上面的例子既有用户名又有频道名。
    • “有没有办法获取用户名”?我给你方法,我不明白这个问题。 “最近 5 次上传”使用 video.list 和频道的频道 ID