KiranGershenfeld / VisualizingTwitchCommunities

Graphing communities on Twitch.tv in a visually intuitive way
MIT License
345 stars 43 forks source link

GetTwitchData.py Streamer name doesn't match Twitch url #6

Open apoordev opened 3 years ago

apoordev commented 3 years ago

GetTwitchData.py has an issue with some user names and will run into an error.

Getting viewers for 악어...
Traceback (most recent call last):
  File "C:/Scripts/VisualizingTwitchCommunities/DataCollection/main.py", line 17, in <module>
    main()
  File "C:/Scripts/VisualizingTwitchCommunities/DataCollection/main.py", line 11, in main
    dict = GetTwitchData.GetDictOfStreamersAndViewers(json) #Create a dictionary of {streamer:[viewers]} from those 100 streams
  File "C:\Scripts\VisualizingTwitchCommunities\DataCollection\GetTwitchData.py", line 44, in GetDictOfStreamersAndViewers
    viewers = getCurrentViewersForChannel(streamer.lower()) #Get viewers for a particular streamer
  File "C:\Scripts\VisualizingTwitchCommunities\DataCollection\GetTwitchData.py", line 29, in getCurrentViewersForChannel
    r = requests.get('http://tmi.twitch.tv/group/user/'+ channel.lower() +'/chatters').json()
  File "C:\Users\%User%\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)

I was able to fix it by just changing line 41 in GetTwitchData.py from user_name to user_login. user_login uses the streamers url name in cases where the streamers stream name and url are different

    streamers = [element['user_login'] for element in j['data']] #Get just the list of streamers