I was wondering how you can obtain your own channel ID using youtube API, or printing a list of the specific channelIDs from your user, since you can have multiple channels on your own user.(im using client_secrets)
i've been watchin alot of the documentation for youtube, but aint finding anything relevant for just this.(maybe im wrong, hehe)
i was watching this: How to retrieve a channel id from a channel name or url
and that was for a search for every channel, but it should be an easier solution just for your own user.(tell me if im wrong)
and is the right path to go?:
channels_list = youtube.channels().list(
part="id",
mine=True
).execute()
channelID = channel_list["items"]["id"]
im going to use the channelId to upload a specific video to the channel. I hope someone can help!
Judging from the docs, I'd say you're on the right track.
channels_list = youtube.channels().list(mine=True)
Should return a list of your owned channels, if you're sending an authenticated request
.
You can then simply access the list directly by calling
channels_list['items']
Note that the ChannelItem
is a dict within a list, so you'll have to access the channel item's index
, and then the key
channels_list['items'][0]['items']['id']
If you'd like to get your channel ids in a single step, this might be what you're looking for:
chan_ids = [chan['items']['id'] for chan in youtube.channels().list(mine=True)['items']]
This section here might be of help to you, as well.