mrtolkien / leaguepedia_parser

A parser for the Leaguepedia website, focused on gathering esports data.
MIT License
71 stars 18 forks source link

get_game_details doesn't show teams/players names #13

Closed rodrigdoliveira closed 2 years ago

rodrigdoliveira commented 2 years ago

Tested using WSL2 on both Ubuntu 20.04 and 18.04 (Python 3.8.10).

import leaguepedia_parser games = leaguepedia_parser.get_games("LPL/2021 Season/Spring Season") game = games[0] leaguepedia_parser.get_game_details(game)

output: LolGame(sources=EmptyDataclass(), duration=2050, start='2021-01-09T09:22:00+00:00', creation=None, type=None, queue_id=None, patch='11.1', gameVersion=None, winner='RED', teams=LolGameTeams(BLUE=LolGameTeam(bans=[2, 58, 142, 4, 61], players=[LolGamePlayer(primaryRuneTreeId=None, secondaryRuneTreeId=None, championId=43, id=None, inGameName=None, profileIconId=None, role='TOP', sources=EmptyDataclass(), runes=[], summonerSpells=[], endOfGameStats=None, snapshots=[], itemsEvents=[], wardsEvents=[], skillsLevelUpEvents=[], largeMonstersKills=[], levelUpEvents=[], spellsUses=[], specialKills=[]), LolGamePlayer(primaryRuneTreeId=None, secondaryRuneTreeId=None, championId=80, id=None, inGameName=None, profileIconId=None, role='JGL', sources=EmptyDataclass(), runes=[], summonerSpells=[], endOfGameStats=None, snapshots=[], itemsEvents=[], wardsEvents=[], skillsLevelUpEvents=[], largeMonstersKills=[], levelUpEvents=[], spellsUses=[], specialKills=[]), LolGamePlayer(primaryRuneTreeId=None, secondaryRuneTreeId=None, championId=134, id=None, inGameName=None, profileIconId=None, role='MID', sources=EmptyDataclass(), runes=[], summonerSpells=[], endOfGameStats=None, snapshots=[], itemsEvents=[], wardsEvents=[], skillsLevelUpEvents=[], largeMonstersKills=[], levelUpEvents=[], spellsUses=[], specialKills=[]), LolGamePlayer(primaryRuneTreeId=None, secondaryRuneTreeId=None, championId=360, id=None, inGameName=None, profileIconId=None, role='BOT', sources=EmptyDataclass(), runes=[], summonerSpells=[], endOfGameStats=None, snapshots=[], itemsEvents=[], wardsEvents=[], skillsLevelUpEvents=[], largeMonstersKills=[], levelUpEvents=[], spellsUses=[], specialKills=[]), LolGamePlayer(primaryRuneTreeId=None, secondaryRuneTreeId=None, championId=89, id=None, inGameName=None, profileIconId=None, role='SUP', sources=EmptyDataclass(), runes=[], summonerSpells=[], endOfGameStats=None, snapshots=[], itemsEvents=[], wardsEvents=[], skillsLevelUpEvents=[], largeMonstersKills=[], levelUpEvents=[], spellsUses=[], specialKills=[])], endOfGameStats=LolGameTeamEndOfGameStats(turretKills=3, inhibitorKills=None, firstTurret=None, firstInhibitor=None, riftHeraldKills=0, dragonKills=2, baronKills=0, firstRiftHerald=None, firstDragon=None, firstBaron=None), epicMonstersKills=[], buildingsKills=[], sources=EmptyDataclass(), earlySurrendered=None), RED=LolGameTeam(bans=[104, 516, 84, 85, 126], players=[LolGamePlayer(primaryRuneTreeId=None, secondaryRuneTreeId=None, championId=266, id=None, inGameName=None, profileIconId=None, role='TOP', sources=EmptyDataclass(), runes=[], summonerSpells=[], endOfGameStats=None, snapshots=[], itemsEvents=[], wardsEvents=[], skillsLevelUpEvents=[], largeMonstersKills=[], levelUpEvents=[], spellsUses=[], specialKills=[]), LolGamePlayer(primaryRuneTreeId=None, secondaryRuneTreeId=None, championId=76, id=None, inGameName=None, profileIconId=None, role='JGL', sources=EmptyDataclass(), runes=[], summonerSpells=[], endOfGameStats=None, snapshots=[], itemsEvents=[], wardsEvents=[], skillsLevelUpEvents=[], largeMonstersKills=[], levelUpEvents=[], spellsUses=[], specialKills=[]), LolGamePlayer(primaryRuneTreeId=None, secondaryRuneTreeId=None, championId=112, id=None, inGameName=None, profileIconId=None, role='MID', sources=EmptyDataclass(), runes=[], summonerSpells=[], endOfGameStats=None, snapshots=[], itemsEvents=[], wardsEvents=[], skillsLevelUpEvents=[], largeMonstersKills=[], levelUpEvents=[], spellsUses=[], specialKills=[]), LolGamePlayer(primaryRuneTreeId=None, secondaryRuneTreeId=None, championId=145, id=None, inGameName=None, profileIconId=None, role='BOT', sources=EmptyDataclass(), runes=[], summonerSpells=[], endOfGameStats=None, snapshots=[], itemsEvents=[], wardsEvents=[], skillsLevelUpEvents=[], largeMonstersKills=[], levelUpEvents=[], spellsUses=[], specialKills=[]), LolGamePlayer(primaryRuneTreeId=None, secondaryRuneTreeId=None, championId=3, id=None, inGameName=None, profileIconId=None, role='SUP', sources=EmptyDataclass(), runes=[], summonerSpells=[], endOfGameStats=None, snapshots=[], itemsEvents=[], wardsEvents=[], skillsLevelUpEvents=[], largeMonstersKills=[], levelUpEvents=[], spellsUses=[], specialKills=[])], endOfGameStats=LolGameTeamEndOfGameStats(turretKills=6, inhibitorKills=None, firstTurret=None, firstInhibitor=None, riftHeraldKills=0, dragonKills=2, baronKills=1, firstRiftHerald=None, firstDragon=None, firstBaron=None), epicMonstersKills=[], buildingsKills=[], sources=EmptyDataclass(), earlySurrendered=None)), kills=[], lobbyName=None, gameInSeries=1, vod='https://youtu.be/SQxjXoIe_2Q', picksBans=[LolPickBan(championId=2, isBan=True, team='BLUE'), LolPickBan(championId=104, isBan=True, team='RED'), LolPickBan(championId=58, isBan=True, team='BLUE'), LolPickBan(championId=516, isBan=True, team='RED'), LolPickBan(championId=142, isBan=True, team='BLUE'), LolPickBan(championId=84, isBan=True, team='RED'), LolPickBan(championId=360, isBan=False, team='BLUE'), LolPickBan(championId=145, isBan=False, team='RED'), LolPickBan(championId=266, isBan=False, team='RED'), LolPickBan(championId=89, isBan=False, team='BLUE'), LolPickBan(championId=80, isBan=False, team='BLUE'), LolPickBan(championId=76, isBan=False, team='RED'), LolPickBan(championId=85, isBan=True, team='RED'), LolPickBan(championId=4, isBan=True, team='BLUE'), LolPickBan(championId=126, isBan=True, team='RED'), LolPickBan(championId=61, isBan=True, team='BLUE'), LolPickBan(championId=3, isBan=False, team='RED'), LolPickBan(championId=134, isBan=False, team='BLUE'), LolPickBan(championId=43, isBan=False, team='BLUE'), LolPickBan(championId=112, isBan=False, team='RED')], pauses=[])

mckernant1 commented 2 years ago

I think i have figured out the issue. The problem is in the print functionality.

The empty dataclass has the items attached to it, but is still displayed as empty because of the way it was defined. https://github.com/mrtolkien/lol_dto/blob/main/lol_dto/classes/sources/empty_dataclass.py

 ~/Desktop/leaguepedia_parser | master !1  poetry run python
Python 3.8.5 (default, Sep  4 2020, 02:22:02)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from lol_dto.classes.sources.empty_dataclass import EmptyDataclass
>>> x = EmptyDataclass()
>>> x.asdf = 2
>>> x
EmptyDataclass()
>>> x.asdf
2
>>>

I think if this field is adjustable it should be set to a dict by default or some other internal object.

edit: This explains the missing player info, but not the missing team info. I dont see fields for the team name etc...

mrtolkien commented 2 years ago

Yeah the EmptyDataclass() solution is not elegant. The data is there, but it's not very obvious.

I think it's possible to make this clean with Pydantic models, so any PR is welcome. As this is not a bug, I'll be closing the issue.

sergiplanes commented 2 years ago

Sorry about my ignorance, but someone can point me how I can translate the EmptyDataclass into the actual data? Got the data already.