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

KeyError: 'commentCount' while fetching youtube API [closed]

$
0
0

**Everything works in the below function except the :
****comments= video["statistics"]["commentCount"] --> gives keyerror**

def get_video_details(youtube,video_ids ):    all_video_stats= []    for i in range(0, len(video_ids), 50):         request = youtube.videos().list(         part="snippet,contentDetails,statistics",         id=",".join(video_ids[i:i+50]))    response = request.execute()     for video in response["items"]:        video_stats= dict(Title= video["snippet"]["title"],                        Published_date= video["snippet"]["publishedAt"],                        Views = video["statistics"]["viewCount"],                        Likes = video["statistics"]["likeCount"],                        comments= video["statistics"]["commentCount"]                        )        all_video_stats.append(video_stats)  return all_video_stats

I tried having a look at Youtube API documentation and got no solution for 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>