本文介绍了检索“Vanity"的 YouTube 频道信息;渠道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个频道的虚 URL"(例如 youtube.com/wheelockcollege,指向 youtube.com/wheelockmarketing1),有没有办法检索频道详细信息?

Given a "vanity url" for a channel (e.g. youtube.com/wheelockcollege, which points to youtube.com/wheelockmarketing1), is there a way to retrieve the channel details?

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

I'm using the new version 3 of the API, with the latest Python package.

推荐答案

可能先使用搜索:

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

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

and then with the channel id you can get the channel details:

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

在这种情况下,结果是:

In this case the result is:

{
 "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"
   }
  }
 ]
}

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

We have a problem if the initial search returns more than one result, but I believe that it is a good strategy :)

这篇关于检索“Vanity"的 YouTube 频道信息;渠道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 07:40