检索“Vanity”频道的 Youtube 频道信息

Posted

技术标签:

【中文标题】检索“Vanity”频道的 Youtube 频道信息【英文标题】:Retrieve Youtube Channel info for "Vanity" channel 【发布时间】:2012-11-15 15:17:10 【问题描述】:

给定频道的“个性网址”(例如 youtube.com/wheelockcollege,它指向 youtube.com/wheelockmarketing1),有没有办法检索频道详细信息?

我正在使用 API 的新版本 3,以及最新的 Python 包。

【问题讨论】:

【参考方案1】:

可能先使用搜索:

GET https://www.googleapis.com/youtube/v3/search?part=snippet&q=wheelockcollege&type=channel&key=YOUR_API_KEY

然后使用频道 ID,您可以获取频道详细信息:

GET https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&id=UC6ltI41W4P14NShIBHU8z1Q&key=YOUR_API_KEY

在这种情况下,结果是:


 "kind": "youtube#channelListResponse",
 "etag": "\"PsChdkLfsD-u3yuH7KChIH1CRFg/fl8vHBnZ66nKyI7QvfTRQchTAAA\"",
 "pageInfo": 
  "totalResults": 1,
  "resultsPerPage": 1
 ,
 "items": [
  
   "id": "UC6ltI41W4P14NShIBHU8z1Q",
   "kind": "youtube#channel",
   "etag": "\"PsChdkLfsD-u3yuH7KChIH1CRFg/zyApGa6dWMliWq5iBE5SL4ewNaQ\"",
   "snippet": 
    "channelId": "UC6ltI41W4P14NShIBHU8z1Q",
    "title": "wheelockmarketing1",
    "description": "Since 1888, Wheelock College has been providing a transformational education to students passionate about making the world a better place—especially for children and families.\n\nWhile most of our students elect to work in the helping professions of education, social work, child life, and juvenile justice and youth advocacy, many pursue—and make exceptional contributions to—a wide variety of professions.\n\nAs a highly respected advocate for social policy, Wheelock also helps to shape and strengthen the social systems that positively impact children and families around the globe.",
    "thumbnails": 
     "default": 
      "url": "https://i3.ytimg.com/i/6ltI41W4P14NShIBHU8z1Q/1.jpg?v=4fdf2807"
     
    
   ,
   "contentDetails": 
    "relatedPlaylists": 
     "likes": "LL6ltI41W4P14NShIBHU8z1Q",
     "favorites": "FL6ltI41W4P14NShIBHU8z1Q",
     "uploads": "UU6ltI41W4P14NShIBHU8z1Q"
    
   ,
   "statistics": 
    "viewCount": "10354",
    "commentCount": "1",
    "subscriberCount": "43",
    "videoCount": "91"
   
  
 ]

如果初始搜索返回多个结果,我们会遇到问题,但我相信这是一个很好的策略 :)

【讨论】:

我已经在通过 API 的搜索功能进行此操作,但是正如您所说,多个结果会导致问题。 那些“虚荣”显示名称不一定是唯一的,所以是的,总是有可能返回多个结果。在寻找非独特的东西时,这只是生活中的一个事实。想想必须根据显示名称搜索 Google+ 用户(或 Facebook 用户...)——“John Smith”可能会返回数千个结果。 @JeffPosnick 从您的评论中,我不明白频道链接可能不是唯一的?我知道“John Smith”不会在 YouTube 上返回唯一结果,但频道 youtube.com/johnsmith 是唯一的。这是我要查找的特定频道名称。 好的,很公平。频道链接,即 URL,将始终唯一标识特定频道。 YouTube 用户名仍然是许多频道 URL 的一部分。 v3 的重点是使用唯一的频道 ID,而不是 YouTube 用户名,Matias 提到的搜索方法是目前在 YouTube 用户名和频道 ID 之间进行转换的唯一方法。 仅供参考,我们在 YouTube 开发者直播节目中将其列为“本周堆栈溢出问题”:youtube.com/watch?v=Y-dY3wRDFo8#t=1794s

以上是关于检索“Vanity”频道的 Youtube 频道信息的主要内容,如果未能解决你的问题,请参考以下文章

如何从 YouTube 频道检索所有视频 URL? json?

Youtube api v3 无法从频道中检索所有视频

如何从 Youtube API V3 中检索经过验证的频道?

YouTube API v3 未检索频道的视频

使用 PHP 代码获取特定频道的 youtube 频道视频

YouTube API:如何通过频道名称获取频道 ID?