首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在API v3中解析两种类型的YouTube通道URL

在API v3中解析两种类型的YouTube通道URL
EN

Stack Overflow用户
提问于 2015-06-26 11:40:30
回答 1查看 250关注 0票数 0

我把youtube网址作为用户输入。我的逻辑如下: if(URL === link_to_video)然后获取视频else if( URL == link_to_channel),然后获取all_videos_of_channel。

我是通过JavaScript和使用YouTube API v3来实现这一点的。

问题是,youtube似乎有两种类型的URL到youtube频道。

  • /channel/,例如: www.youtube.com/channel/UCaHNFIob5Ixv74f5on3lvIw
  • /user/,例如: www.youtube.com/user/CalvinHarrisVEVO

以上两个链接都将带您到同一个频道,但我当前的上传代码只支持/user/CalvinHarrisVEVO。

有没有办法使这两个网址在获得频道视频方面表现相似?

EN

回答 1

Stack Overflow用户

发布于 2015-06-26 12:14:55

一种解决方案是解析url,然后应用此逻辑:

代码语言:javascript
复制
if there is `channel` in the url link
    call the APIv3 with the **id** of the channel
    Ressource : youtube.channels.list
else if there is 'user'
    call the APIv3 with the **forUsername** of the channel
    Ressource : youtube.channels.list

检查:https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31072280

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档