1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import os
- from api import TwitchApiClient
- from irc import IRC
- # convert all files CRLF(\r\n) TO LF(\n) unix format.
- # Shellcommand:
- # for f in twitch_bot/**/*.py; do
- # >dos2unix $f
- # >done
- # get env vars
- redirect_uri = os.getenv('REDIRECT_URI')
- scope = os.getenv('SCOPE')
- client_id = os.getenv('CLIENT_ID')
- client_secret = os.getenv('CLIENT_SECRET')
- client = TwitchApiClient(client_id, client_secret)
- streams = client.streams('Starcraft2')
- for streamer in streams['data']:
- print('{0}|{1}: {2}'.format(streamer['game_name'], streamer['display_name'], streamer['title']))
- user = client.user('wardiii')
- data = user['data'][0]
- print("Name: {0}".format(data['display_name']))
- print("Type: {0}".format(data['type']))
- print("View Count: {0}".format(data['view_count']))
- print("Profile Image: {0}".format(data['profile_image_url']))
- exit()
- # build oAuth url
- url = 'https://id.twitch.tv/oauth2/authorize?'
- url += 'client_id={0}'.format(client_id)
- url += '&redirect_uri={0}'.format(redirect_uri)
- url += '&response_type=token'
- url += '&scope={0}'.format(scope)
- print(url)
- token = input("Token: ")
- irc = IRC('mosix_de', token)
- irc.login()
|