How to get the public channel URL from YouTubeVideoFeed object using the YouTube API?

 ̄綄美尐妖づ 提交于 2019-12-07 19:20:28

Well, the youtube.com/user/USERNAME is a pretty safe bet if you want to construct the URL yourself, but I think what you want is the link rel='alternate'

You have to get the link array from the feed and iterate to find alternate, then grab the href

something like:

client = gdata.youtube.service.YouTubeService()

feed = client.GetYouTubeVideoFeed('http://gdata.youtube.com/feeds/api/users/username/uploads')

for link in feed.link:
  if link.rel == 'alternate':
    print link.href

Output:

http://www.youtube.com/profile_videos?user=username

The most correct thing would be to grab the 'alternate' link from the user profile feed, as technically the above URL goes to the uploaded videos, not the main channel page

feed = client.GetYouTubeUserEntry('http://gdata.youtube.com/feeds/api/users/username')

for link in feed.link:
  if link.rel == 'alternate':
    print link.href

output: http://www.youtube.com/profile?user=username

you might be confusing usernames... when I use my username I get my public page http://gdata.youtube.com/feeds/api/users/drdredel/uploads They have some wacky distinction between your gmail username and your youtube username. Or am I misunderstanding your question?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!