hltv-async-api 0.5.0__tar.gz → 0.5.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hltv_async_api
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Summary: Hltv-aio An unofficial asynchronous HLTV API Wrapper for Python
5
5
  Author: Akim Slys
6
6
  Author-email: akimslys2003@gmail.com
@@ -209,7 +209,7 @@ pip install hltv-async-api
209
209
 
210
210
  ```
211
211
 
212
- await hltv.get('matches', 2370773, 'res-regional-series-3-latam', 'FURIA', 'MIBR')
212
+ await hltv.get('matches', 2371201, 'res-regional-series-3-latam', 'IMPERIAL', 'MIBR')
213
213
 
214
214
  >>> (2371201, 0, 0, 'LIVE', [{'mapname': 'Vertigo', 'r_team1': '6', 'r_team2': '13'}, {'mapname': 'Mirage', 'r_team1': '-', 'r_team2': '-'}, {'mapname': 'Anubis', 'r_team1': '-', 'r_team2': '-'}], [])
215
215
 
@@ -186,7 +186,7 @@ pip install hltv-async-api
186
186
 
187
187
  ```
188
188
 
189
- await hltv.get('matches', 2370773, 'res-regional-series-3-latam', 'FURIA', 'MIBR')
189
+ await hltv.get('matches', 2371201, 'res-regional-series-3-latam', 'IMPERIAL', 'MIBR')
190
190
 
191
191
  >>> (2371201, 0, 0, 'LIVE', [{'mapname': 'Vertigo', 'r_team1': '6', 'r_team2': '13'}, {'mapname': 'Mirage', 'r_team1': '-', 'r_team2': '-'}, {'mapname': 'Anubis', 'r_team1': '-', 'r_team2': '-'}], [])
192
192
 
@@ -6,4 +6,4 @@
6
6
  from .aiohltv import Hltv
7
7
 
8
8
  __author__ = 'akimerslys'
9
- __version__ = '0.5.0'
9
+ __version__ = '0.5.2'
@@ -282,7 +282,7 @@ class Hltv:
282
282
  'event': event
283
283
  })
284
284
 
285
- if upcoming:
285
+ if future:
286
286
  for i, date_div in enumerate(r.find_all('div', {'class': 'upcomingMatchesSection'}), start=1):
287
287
  if i > days:
288
288
  break
@@ -292,13 +292,18 @@ class Hltv:
292
292
  time_ = match.find('div', {'class': 'matchTime'}).text
293
293
  rating = int(match['stars'])
294
294
  if rating >= min_rating:
295
+ id_ = 0
296
+ t1_id = 0
297
+ t2_id = 0
298
+ team1 = 'TBD'
299
+ team2 = 'TBD'
300
+
295
301
  try:
296
- match_id_ = match.find('a')['href'].split('/')[2]
302
+ id_ = match.find('a')['href'].split('/')[2]
297
303
  t1_id = match['team1']
298
304
  t2_id = match['team2']
299
305
  except (IndexError, AttributeError, KeyError):
300
- t1_id = 0
301
- t2_id = 0
306
+ pass
302
307
  maps = match.find('div', {'class': 'matchMeta'}).text[-1:]
303
308
  try:
304
309
  teams = match.find_all('div', {'class': 'matchTeamName text-ellipsis'})
@@ -306,8 +311,7 @@ class Hltv:
306
311
  team1 = teams[0].text
307
312
  team2 = teams[1].text
308
313
  except (IndexError, AttributeError):
309
- team1 = 'TBD'
310
- team2 = 'TBD'
314
+ pass
311
315
 
312
316
  try:
313
317
  event = match.find('div', {'class', 'matchEventName gtSmartphone-only'}).text
@@ -319,7 +323,7 @@ class Hltv:
319
323
  event = ''
320
324
 
321
325
  matches.append({
322
- 'id': match_id_,
326
+ 'id': id_,
323
327
  'date': date_,
324
328
  'time': time_,
325
329
  'team1': team1,
@@ -400,7 +404,7 @@ class Hltv:
400
404
  score2 = 13
401
405
  score1 = int(map["r_team1"])
402
406
 
403
- return match_id, score1, score2, status, maps, stats_
407
+ return {'id': match_id, 'score1': score1, 'score2': score2, 'status': status, 'maps': maps, 'stats': stats_}
404
408
 
405
409
  async def get_results(self, days: int = 1,
406
410
  min_rating: int = 1,
@@ -682,7 +686,7 @@ class Hltv:
682
686
  async def get_event_info(self, event_id: str | int, event_title: str):
683
687
  # TODO ADD WINNER?
684
688
 
685
- r = await self._fetch(f"https://www.hltv.org/events/{str(event_id)}/{event_title.replace(' ', '-')}")
689
+ r = await self._fetch(f"https://hltv.org/events/{str(event_id)}/{event_title.replace(' ', '-')}")
686
690
  if not r:
687
691
  return
688
692
 
@@ -709,7 +713,14 @@ class Hltv:
709
713
  except AttributeError:
710
714
  groups = []
711
715
 
712
- return event_id, event_title, event_start, event_end, prize, team_num, location, groups
716
+ return {'id': event_id,
717
+ 'title': event_title,
718
+ 'start': event_start,
719
+ 'end': event_end,
720
+ 'prize': prize,
721
+ 'teams': team_num,
722
+ 'location': location,
723
+ 'group': groups}
713
724
 
714
725
  async def get_top_teams(self, max_teams=30):
715
726
  """
@@ -769,7 +780,7 @@ class Hltv:
769
780
 
770
781
  return teams
771
782
 
772
- async def get_team_info(self, team_id: int | str, title: str) -> tuple | None:
783
+ async def get_team_info(self, team_id: int | str, title: str) -> dict[str, list[str]]:
773
784
  """
774
785
  Returns Information about team
775
786
  :params:
@@ -791,24 +802,35 @@ class Hltv:
791
802
  coach = ''
792
803
 
793
804
  for i, stat in enumerate(r.find_all('div', {'class': 'profile-team-stat'}), start=1):
794
- if i == 1:
795
- rank = stat.find('a').text[1:]
796
- elif i == 2:
797
- weeks = stat.find('span', {'class': 'right'}).text
798
- elif i == 3:
799
- age = stat.find('span', {'class': 'right'}).text
800
- elif i == 4:
801
- coach = stat.find('span', {'class': 'bold a-default'}).text[1:-1]
805
+ try:
806
+ if i == 1:
807
+ rank = stat.find('a').text[1:]
808
+ elif i == 2:
809
+ weeks = stat.find('span', {'class': 'right'}).text
810
+ elif i == 3:
811
+ age = stat.find('span', {'class': 'right'}).text
812
+ elif i == 4:
813
+ coach = stat.find('span', {'class': 'bold a-default'}).text[1:-1]
814
+ except AttributeError:
815
+ pass
802
816
 
803
817
  last_trophy = None
804
- total_trophys = None
818
+ total_trophies = None
805
819
  try:
806
820
  last_trophy = r.find('div', {'class': 'trophyHolder'}).find('span')['title']
807
- total_trophys = len(r.find_all('div', {'class': 'trophyHolder'}))
821
+ total_trophies = len(r.find_all('div', {'class': 'trophyHolder'}))
808
822
  except AttributeError:
809
823
  pass
810
824
 
811
- return team_id, title, rank, players, coach, age, weeks, last_trophy, total_trophys
825
+ return {'id': team_id,
826
+ 'title': title,
827
+ 'rank': rank,
828
+ 'players': players,
829
+ 'coach': coach,
830
+ 'age': age,
831
+ 'weekstop30': weeks,
832
+ 'last_trophy': last_trophy,
833
+ 'total_trophies': total_trophies}
812
834
  except AttributeError:
813
835
  raise AttributeError("Parsing error, probably page not fully loaded")
814
836
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "hltv_async_api"
3
- version = "0.5.0"
3
+ version = "0.5.2"
4
4
  authors = ["Akim Slys <akimslys2003@gmail.com>"]
5
5
  description = "Hltv-aio An unofficial asynchronous HLTV API Wrapper for Python"
6
6
  readme = "README.md"
File without changes