Skip to content

Commit 5f83fdd

Browse files
committed
use participants instead of players
1 parent ce45237 commit 5f83fdd

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

vj_cms/client.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,19 @@ def games(self):
3333
return games
3434

3535
def players(self):
36-
players = self.get('players')
37-
return players
38-
36+
participants = self.get('participants')
37+
particing_players = []
38+
for participant in participants:
39+
player = {"id":participant['id'],
40+
"display_name":participant['display_name'],
41+
"twitch_channel":"",
42+
"discord_nick":""
43+
}
44+
for social in participant['social_medias']:
45+
if social['platform'] == 'TWITCH':
46+
player['twitch_channel'] = social['username']
47+
particing_players.append(player)
48+
return particing_players
3949

4050
def donations(self):
4151
donations = self.get('donations')

vj_cms/views.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ def update_timetable(request):
2525
GameInfo.objects.all().delete()
2626
for game in games:
2727
api_id = game.pop('id')
28-
game_players = game.pop('players')
28+
if "players" in game:
29+
game.pop('players')
30+
game_players = []
2931
game_participants = game.pop('participants')
32+
for participant in game_participants:
33+
if participant['role'] == "PLAYER":
34+
game_players.append(participant['participant_id'])
3035
game_, _ = GameInfo.objects.update_or_create(
3136
api_id=api_id,
3237
defaults=game

0 commit comments

Comments
 (0)