hltv-async-api 0.6.2__tar.gz → 0.6.3__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.6.2
3
+ Version: 0.6.3
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
@@ -6,4 +6,4 @@
6
6
  from .aiohltv import Hltv
7
7
 
8
8
  __author__ = 'akimerslys'
9
- __version__ = '0.6.1'
9
+ __version__ = '0.6.3'
@@ -26,12 +26,11 @@ class Hltv:
26
26
  max_retries: int = 0,
27
27
  proxy_protocol: str | None = None,
28
28
  proxy_one_time: bool = False,
29
- one_time_session: bool = True,
30
29
  ):
31
30
  self.headers = {
32
31
  "referer": "https://www.hltv.org/stats",
33
32
  "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
34
- "hltvTimeZone": "UTC"
33
+ "hltvTimeZone": "Europe/Copenhagen" # TODO Timezone settings???
35
34
  }
36
35
  self.MAX_DELAY = max_delay
37
36
  self.timeout = timeout
@@ -360,12 +359,38 @@ class Hltv:
360
359
  f"{event_title.replace(' ', '-')}")
361
360
  if not r:
362
361
  return
362
+ status_ = {'Match over': 0, 'LIVE': 1}
363
363
 
364
364
  status = r.find('div', {'class': 'countdown'}).text
365
365
 
366
+ status_int = status_[status] if status in status_ else 2
367
+
368
+ if status_int == 2:
369
+ components = status.split(" : ")
370
+
371
+ days, hours, minutes, seconds = 0, 0, 0, 0
372
+
373
+ for component in components:
374
+ if 'd' in component:
375
+ days = int(component.replace("d", ""))
376
+ elif 'h' in component:
377
+ hours = int(component.replace("h", ""))
378
+ elif 'm' in component:
379
+ minutes = int(component.replace("m", ""))
380
+ elif 's' in component:
381
+ seconds = int(component.replace("s", ""))
382
+
383
+ date_ = datetime.now(tz=pytz.timezone('Europe/Copenhagen')) + timedelta(days=days,
384
+ hours=hours,
385
+ minutes=minutes,
386
+ seconds=seconds)
387
+
388
+ status = date_.strftime('%d-%m-%Y-%H-%M')
389
+
390
+
366
391
  score1, score2 = 0, 0
367
392
 
368
- if status == 'Match over':
393
+ if status_int == 0:
369
394
  scores = r.find_all('div', class_='team')
370
395
  score1 = scores[0].get_text().replace('\n', '')[-1]
371
396
  score2 = scores[1].get_text().replace('\n', '')[-1]
@@ -384,7 +409,7 @@ class Hltv:
384
409
  maps.append({'mapname': mapname, 'r_team1': r_team1, 'r_team2': r_team2})
385
410
 
386
411
  stats_ = []
387
- if stats and status == 'Match over':
412
+ if stats and status_int == 0:
388
413
  for table_div in r.find_all('table', {'class': 'table totalstats'})[:2]:
389
414
  for player in table_div.find_all('tr')[1:]:
390
415
  player_id = player.find('a', class_='flagAlign')['href'].split('/')[2]
@@ -402,17 +427,18 @@ class Hltv:
402
427
  'rating': rating
403
428
  })
404
429
 
405
- if status == "LIVE":
430
+ if status_int == 1:
406
431
  for map in maps:
432
+ len_ = len(map)
407
433
  if map["r_team1"] == '13':
408
- if len(map) != 1:
434
+ if len_ != 1:
409
435
  score1 += 1
410
436
  else:
411
437
  score1 = 13
412
438
  score2 = int(map["r_team2"])
413
439
 
414
440
  elif map["r_team1"] == '13':
415
- if len(map) != 1:
441
+ if len_ != 1:
416
442
  score2 += 1
417
443
  else:
418
444
  score2 = 13
@@ -642,7 +668,7 @@ class Hltv:
642
668
 
643
669
  return events
644
670
 
645
- async def get_events(self, featured=True, outgoing=True, future=True, max_events=10):
671
+ async def get_events(self, outgoing=True, future=True, max_events=10):
646
672
  """Returns events
647
673
  :params:
648
674
  outgoing - include live tournaments
@@ -961,7 +987,8 @@ class Hltv:
961
987
 
962
988
  async def main():
963
989
  hltv = Hltv()
964
- print(await hltv.get_matches())
990
+ print(await hltv.get_matches(live=False))
991
+ print(await hltv.get_match_info(2371706, 'Guild Eagles', 'sangal', 'CCT Season 2 Europe Series 1'))
965
992
 
966
993
  if __name__ == '__main__':
967
994
  asyncio.run(main())
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "hltv_async_api"
3
- version = "0.6.2"
3
+ version = "0.6.3"
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
File without changes