Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
import os import google_auth_oauthlib.flow import googleapiclient.discovery import googleapiclient.errors scopes = ["https://www.googleapis.com/auth/youtube.readonly"] def main(): # Disable OAuthlib's HTTPS verification when running locally. # *DO NOT* leave this option enabled in production. os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1" api_service_name = "youtube" api_version = "v3" client_secrets_file = "YOUR_CLIENT_SECRET_FILE.json" # Get credentials and create an API client flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file( client_secrets_file, scopes) credentials = flow.run_console() youtube = googleapiclient.discovery.build( api_service_name, api_version, credentials=credentials) lb_request = youtube.liveBroadcasts().list( #LiveBroadcast request. Get LiveChatID part="snippet", broadcastStatus="active", broadcastType="all" ) lb_response = lb_request.execute() lci = lb_response.items[0].snippet.liveChatId #Get LiveChatID print(lci) LCM_request = youtube.liveChatMessages().list( #Get LiveChatMessages, authordetails. liveChatId="lci", part="snippet,authorDetails" ) response = LCM_request.execute() print(response) if __name__ == "__main__": main()
Вот весь код, копировал с офф сайта, просто менял значения на нужные мне.