Youtube频道列表brandingSettings为空,带有forUsername,但没有id



使用Youtube Data API的频道:带有brandingSettings部分的列表在使用id过滤器时有效,但对我来说不使用forUsername过滤器。

例如,GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&forUsername=h3h3Productions&key={YOUR_API_KEY}会导致以下内容,缺少brandSettings:

{
 "kind": "youtube#channelListResponse",
 "etag": ""0KG1mRN7bm3nResDPKHQZpg5-do/Qagk6ayL_umilQ398UZyAHwxK_g"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 5
 },
 "items": [
  {
   "kind": "youtube#channel",
   "etag": ""0KG1mRN7bm3nResDPKHQZpg5-do/tTzKQvYs0Y2GpqN2wqgudxB2TnQ"",
   "id": "UCDWIvJwLJsE4LG1Atne2blQ"
  }
 ]
}

但是GET https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&id=UCDWIvJwLJsE4LG1Atne2blQ&key={YOUR_API_KEY}(您会注意到它使用了同一用户的ID)保持原样:

{
 "kind": "youtube#channelListResponse",
 "etag": ""0KG1mRN7bm3nResDPKHQZpg5-do/2ZOHdezDOZFRR9xisREY04R4OOg"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#channel",
   "etag": ""0KG1mRN7bm3nResDPKHQZpg5-do/58_5G5_Hi-64MiC8m5NC76sDIOA"",
   "id": "UCDWIvJwLJsE4LG1Atne2blQ",
   "brandingSettings": {
    "channel": {
     "title": "h3h3Productions",
     "description": "Wacky, zany, goofy comedy. ",
     "keywords": "comedy humor satire parody funny sketch "sketch comedy" reaction "reaction video" review h3h3 h3h3productions",
     "showRelatedChannels": true,
     "showBrowseView": true,
     "featuredChannelsTitle": "SECOND CHANNEL",
     "featuredChannelsUrls": [
      "UC7pp40MU_6rLK5pvJYG3d0Q"
     ],
     "unsubscribedTrailer": "tVaAv0cPRok",
     "profileColor": "#000000",
     "country": "US"
    },
    "image": {
     "bannerImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1060-fcrop64=1,00005a57ffffa5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerMobileImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w640-fcrop64=1,32b75a57cd48a5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerTabletLowImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1138-fcrop64=1,00005a57ffffa5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerTabletImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1707-fcrop64=1,00005a57ffffa5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerTabletHdImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w2276-fcrop64=1,00005a57ffffa5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerTabletExtraHdImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w2560-fcrop64=1,00005a57ffffa5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerMobileLowImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w320-fcrop64=1,32b75a57cd48a5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerMobileMediumHdImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w960-fcrop64=1,32b75a57cd48a5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerMobileHdImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1280-fcrop64=1,32b75a57cd48a5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerMobileExtraHdImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1440-fcrop64=1,32b75a57cd48a5a8-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerTvImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w2120-fcrop64=1,00000000ffffffff-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerTvLowImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w854-fcrop64=1,00000000ffffffff-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerTvMediumImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1280-fcrop64=1,00000000ffffffff-nd/youtube%2Bnew%2Bbanner14.jpg",
     "bannerTvHighImageUrl": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w1920-fcrop64=1,00000000ffffffff-nd/youtube%2Bnew%2Bbanner14.jpg"
    },
    "hints": [
     {
      "property": "channel.banner.mobile.medium.image.url",
      "value": "https://yt3.ggpht.com/-DFbgqVWqgm8/VDV_M-xkJtI/AAAAAAAAAOE/zQeoRrTR-qA/w640-fcrop64=1,32b75a57cd48a5a8-nd/youtube%2Bnew%2Bbanner14.jpg"
     },
     {
      "property": "channel.banner.image_height.int",
      "value": "0"
     },
     {
      "property": "channel.featured_tab.template.string",
      "value": "Everything"
     },
     {
      "property": "channel.modules.show_comments.bool",
      "value": "True"
     }
    ]
   }
  }
 ]
}

我做错什么了吗?保持一切不变,但将零件切换到snippetstatistics,在这两种情况下都会如您所期望的那样工作。我也在其他几个频道上尝试过,得到了同样的结果。

我认为这是按预期工作的。请参阅YouTube API-不返回按用户名查询的频道品牌设置。Tl;dr:尽管你可以通过使用频道的用户名来寻找频道,但从V2的迁移带来了一个事实,即并非每个YouTube频道都有一个唯一的用户名,所以这就是为什么当你使用频道ID(它是唯一的)时它能正确工作。我还通过指定forMine而不是通道ID进行了尝试,结果不出所料。

相关内容

  • 没有找到相关文章

最新更新