You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

23 lines
579 B

  1. import googleapiclient.discovery
  2. import googleapiclient.errors
  3. import config
  4. scopes = ["https://www.googleapis.com/auth/youtube.force-ssl"]
  5. def get_videos(query):
  6. youtube = googleapiclient.discovery.build('youtube', 'v3', developerKey=config.API_KEY)
  7. request = youtube.search().list(
  8. part="snippet",
  9. q=query,
  10. maxResults=50
  11. )
  12. print(request.__dict__)
  13. response = request.execute()
  14. return [item["id"]["videoId"] for item in response['items']]
  15. if __name__ == "__main__":
  16. print(get_videos("+lofi beats to chill and relax to"))