main.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import os
  2. from api import TwitchApiClient
  3. from irc import IRC
  4. # convert all files CRLF(\r\n) TO LF(\n) unix format.
  5. # Shellcommand:
  6. # for f in twitch_bot/**/*.py; do
  7. # >dos2unix $f
  8. # >done
  9. # get env vars
  10. redirect_uri = os.getenv('REDIRECT_URI')
  11. scope = os.getenv('SCOPE')
  12. client_id = os.getenv('CLIENT_ID')
  13. client_secret = os.getenv('CLIENT_SECRET')
  14. client = TwitchApiClient(client_id, client_secret)
  15. streams = client.streams('Starcraft2')
  16. for streamer in streams['data']:
  17. print('{0}|{1}: {2}'.format(streamer['game_name'], streamer['display_name'], streamer['title']))
  18. user = client.user('wardiii')
  19. data = user['data'][0]
  20. print("Name: {0}".format(data['display_name']))
  21. print("Type: {0}".format(data['type']))
  22. print("View Count: {0}".format(data['view_count']))
  23. print("Profile Image: {0}".format(data['profile_image_url']))
  24. exit()
  25. # build oAuth url
  26. url = 'https://id.twitch.tv/oauth2/authorize?'
  27. url += 'client_id={0}'.format(client_id)
  28. url += '&redirect_uri={0}'.format(redirect_uri)
  29. url += '&response_type=token'
  30. url += '&scope={0}'.format(scope)
  31. print(url)
  32. token = input("Token: ")
  33. irc = IRC('mosix_de', token)
  34. irc.login()