I want to create a random video picker in Python, where you input a (YouTube) channel's name, and it picks a random video from this channel. I saw an internet tutorial, which said to use youtube.channels().list(part="contentDetails",forUsername="GoogleDevelopers") and then take the playlist ID from this and call youtube.playlistItems().list(part="snippet",maxResults=50,playlistId="playlistId"). The problem is: how can I take just the playlist ID from youtube.channels().list(), instead of this long thing it normally outputs? This response is stored in a variable and even if there is no way to get just the playlist ID, is there a way to just read the uploads value from the variable?
The normal output looks like this:
{
'kind': 'youtube#channelListResponse',
'etag': 'h612UhyviV63eK7y4HMgXE59VnY',
'pageInfo':
{
'totalResults': 1,
'resultsPerPage': 5
},
'items': [
{
'kind': 'youtube#channel',
'etag': 'tjfVDNBL4GkV4fzZBO9NE36KY5o',
'id': 'UC_x5XG1OV2P6uZZ5FSM9Ttw',
'contentDetails':
{
'relatedPlaylists':
{
'likes': '',
'uploads': 'UU_x5XG1OV2P6uZZ5FSM9Ttw'
}
}
}]
}
Sorry if my English isn't clear and please tell me to provide any further information.