()
| 22 | |
| 23 | |
| 24 | def get_trending_videos(): |
| 25 | youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=API_KEY) |
| 26 | |
| 27 | # Call the API to get the top 10 trending videos |
| 28 | request = youtube.videos().list( |
| 29 | part="snippet,statistics", |
| 30 | chart="mostPopular", |
| 31 | regionCode="IN", # Change this to your region code |
| 32 | maxResults=10, |
| 33 | ) |
| 34 | response = request.execute() |
| 35 | |
| 36 | # Print the video details |
| 37 | for item in response["items"]: |
| 38 | title = item["snippet"]["title"] |
| 39 | channel = item["snippet"]["channelTitle"] |
| 40 | views = item["statistics"]["viewCount"] |
| 41 | print(f"Title: {title}\nChannel: {channel}\nViews: {views}\n") |
| 42 | |
| 43 | |
| 44 | if __name__ == "__main__": |
no outgoing calls
no test coverage detected