alimango
alimango

Reputation: 655

Extracting YouTube Video's author using Python and YouTubeAPI

how do I get the author/username from an object using:

GetYouTubeVideoEntry(video_id=youtube_video_id_to_output)

I'm using Google's gdata.youtube.service Python library

Thanks in advance! :)

Upvotes: 5

Views: 1406

Answers (2)

Steph Liu
Steph Liu

Reputation: 161

So because YouTube's API is based on GData, which is based on Atom, the 'author' object is an array with name objects, which can contain names, URLs, etc.

This is what you want:

>>> client = gdata.youtube.service.YouTubeService()
>>> video = client.GetYouTubeVideoEntry(video_id='CoYBkXD0QeU')
>>> video.author[0].name.text
'GoogleDevelopers'

Upvotes: 6

Hank Gay
Hank Gay

Reputation: 72019

Have you tried something like this?

foo = GetYouTubeVideoEntry(video_id=youtube_video_id_to_output)
foo.author

The docs for YouTubeVideoEntry aren't great, but the __init__ method seems to accept an author.

Upvotes: 0

Related Questions