How to fetch the number of videos in a youtube channel

I have been working on youtube Data recently. while getting no.of videos in a particular channel I got an error: IndexError: list index out of range

`def get_channel_videos(channel_id):
res = youtube.channels().list(id = channel_id,
                              part = 'contentDetails').execute()
playlist_id = res['items'][0]['contentDetails']['relatedPlaylists']['uploads']

videos = []
next_page_token = None

while 1:
    res = youtube.playlistItems().list(playlistId=playlist_id,
                                       part = 'snippet',maxResults=50,
                                      pageToken = next_page_token).execute()
    videos += res['items']
    next_page_token = res.get('nextPageToken')

    if next_page_token is None:
        break

return videos 
videos = get_channel_videos('UUkUq-s6z57uJFUFBvZIVTyg')
Videos