我正在尝试使用YouTube Data API V3从我的频道中检索数据.
为此,我需要我的频道ID.
我试图从我的YouTube帐户中找到我的频道ID,但我在每一个方面都失败了.
如果有人对我有一个提示,我会非常高兴.
这是我用来检索数据的URL:
https://www.googleapis.com/youtube/v3/channels?id = fjTOrCPnAblTngWAzpnlMA&key = {YOUR_API_KEY}&part = snippet,contentDetails,statistics
该ID用于频道ID和密钥,我正在使用我的Google API控制台生成的API密钥替换{YOUR_API_KEY}.
我的频道ID不是:
- klauskkpm
- klausmachado
- klausmachado@gmail.com
- fjTOrCPnAblTngWAzpnlMA
@username我正在尝试编写一个简单的 Python 脚本,通过或搜索返回有关频道的一些信息UCrandomID123。
我知道您可以使用以下端点来访问频道数据:https://www.googleapis.com/youtube/v3/channels
然而,我遇到了一些可能的限制和问题。某些频道的频道 URL 中可能没有自定义“名称”:
与
我查了一下问题并发现了多个解决该问题的帖子:
但这两种解决方案都相当陈旧,我想知道现在是否有更好的解决方案来解决这个问题?
我有以下代码:
async def get_channel_id(self, channel_input):
api_url = f"https://www.googleapis.com/youtube/v3/channels"
params = {
'part': 'snippet',
'key': DEVELOPER_KEY,
'maxResults': 1
}
# Determine if the input is a channel ID or username
if channel_input.startswith('UC'):
# Channel ID provided
params['id'] = channel_input
else:
# Assume it's a custom username
params['forUsername'] = channel_input
response = await self.make_api_request(api_url, params) # Just a function to make …Run Code Online (Sandbox Code Playgroud) Youtube 似乎已经删除了其页面上的 /channel/XXXX 网址,现在是 /c/username?用户名并不是真正的“用户名”。例如
https://www.youtube.com/c/lukeemiani
通过运行查找
https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername=lukemiani&key=...
Run Code Online (Sandbox Code Playgroud)
没有返回结果。
我有一群非技术用户,他们接受过寻找 /channel/x 或 /user/x 并将正确的内容输入到我的应用程序中的培训。现在 /channel 已经消失了,我(或他们)如何将 /c/x 转换为频道 id?
我正在寻找 API 解决方案,而不是查看源代码和逆向工程代码解决方案。