Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

KeyError when executing my code on youtube ape (multiple youtube ids)

$
0
0

I have a problem when executing my code with multiple youtube ids and here are my code

from googleapiclient.discovery import buildimport pandas as pdimport seaborn as snsapi_key = 'AIzaSy...'channel_ids = ['UCoUM-UJ7rirJYP8CQ0EIaHA' #Bruno Mars'UCqECaJ8Gagnn7YCbPEzWH6g' #Taylor Swift'UC9CoOnJkIBMdeijd9qYoT_g' #Ariana Grande'UC0C-w0YjGpqDXGB8IHb662A' #Ed Sheeran'UCBVjMGOIkavEAhyqpxJ73Dw'] #Maroon 5youtube = build('youtube','v3',developerKey=api_key)def get_channel_stats(youtube, channel_ids):    all_data = []    request = youtube.channels().list(                part='snippet,contentDetails,statistics',                id=','.join(channel_ids)                )    response = request.execute()    for i in range(len(response['items'])):         data = dict(channel_name = response['items'][i]['snippet']['title'],                subscribers = response['items'][i]['statistics']['subscriberCount'],                views = response['items'][i]['statistics']['viewCount'],                total_videos = response['items'][i]['statistics']['videoCount'])     all_data.append(data)    return all_data

however when i run the code its show this error

enter image description here

is there any solution on this?


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>