Skip to content

Commit caf52fa

Browse files
committed
fix brawler id data gotten, only modify the passed in brawler if it is a str
1 parent 6338548 commit caf52fa

5 files changed

Lines changed: 6 additions & 4 deletions

File tree

brawlstats/brawlapi/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, base_url, version=1):
3939
self.BRAWLERS = {}
4040
else:
4141
if data:
42-
self.BRAWLERS = {b['tID'].lower(): b['scId'] for b in data['characters'] if b['tID']}
42+
self.BRAWLERS = {b['tID'].lower(): str(b['scId'])[:2] + '0' + str(b['scId'])[2:] for b in data['characters'] if b['tID']}
4343
else:
4444
self.BRAWLERS = {}
4545

brawlstats/constants.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

brawlstats/officialapi/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def get_rankings(self, ranking_type: str, limit: int=200, region='global', brawl
254254
255255
Returns Ranking
256256
"""
257-
if brawler:
257+
if type(brawler) == str:
258258
brawler = brawler.lower()
259259
if brawler not in self.api.BRAWLERS and ranking_type not in ['players', 'clubs', 'brawlers']:
260260
raise ValueError("Please enter 'players', 'clubs' or a brawler.")

brawlstats/officialapi/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, base_url, version=1):
2727
self.BRAWLERS = {}
2828
else:
2929
if data:
30-
self.BRAWLERS = {b['tID'].lower(): b['scId'] for b in data['characters'] if b['tID']}
30+
self.BRAWLERS = {b['tID'].lower(): str(b['scId'])[:2] + '0' + str(b['scId'])[2:] for b in data['characters'] if b['tID']}
3131
else:
3232
self.BRAWLERS = {}
3333

tests/officialapi/test_blocking.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def test_get_rankings_club(self):
5353
def test_get_rankings_brawler(self):
5454
lb = self.client.get_rankings('brawlers', brawler='shelly')
5555
self.assertTrue(isinstance(lb, brawlstats.officialapi.Ranking))
56+
rankings = self.client.get_rankings('brawlers', brawler=16000000)
57+
self.assertTrue(isinstance(rankings, brawlstats.officialapi.Ranking))
5658

5759
def test_get_constants(self):
5860
default = self.client.get_constants()

0 commit comments

Comments
 (0)