hltv-async-api 0.4.3__tar.gz → 0.4.4__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.
- {hltv_async_api-0.4.3 → hltv_async_api-0.4.4}/PKG-INFO +1 -1
- {hltv_async_api-0.4.3 → hltv_async_api-0.4.4}/hltv_async_api/__init__.py +1 -1
- {hltv_async_api-0.4.3 → hltv_async_api-0.4.4}/hltv_async_api/aiohltv.py +44 -45
- {hltv_async_api-0.4.3 → hltv_async_api-0.4.4}/hltv_async_api.egg-info/PKG-INFO +1 -1
- {hltv_async_api-0.4.3 → hltv_async_api-0.4.4}/pyproject.toml +1 -1
- {hltv_async_api-0.4.3 → hltv_async_api-0.4.4}/setup.py +1 -1
- {hltv_async_api-0.4.3 → hltv_async_api-0.4.4}/LICENSE +0 -0
- {hltv_async_api-0.4.3 → hltv_async_api-0.4.4}/README.md +0 -0
- {hltv_async_api-0.4.3 → hltv_async_api-0.4.4}/hltv_async_api.egg-info/SOURCES.txt +0 -0
- {hltv_async_api-0.4.3 → hltv_async_api-0.4.4}/hltv_async_api.egg-info/dependency_links.txt +0 -0
- {hltv_async_api-0.4.3 → hltv_async_api-0.4.4}/hltv_async_api.egg-info/top_level.txt +0 -0
- {hltv_async_api-0.4.3 → hltv_async_api-0.4.4}/setup.cfg +0 -0
|
@@ -12,7 +12,6 @@ from aiohttp.client_exceptions import ClientProxyConnectionError, ClientResponse
|
|
|
12
12
|
ServerDisconnectedError, ClientHttpProxyError
|
|
13
13
|
import re
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
import logging
|
|
17
16
|
|
|
18
17
|
|
|
@@ -236,7 +235,7 @@ class Hltv:
|
|
|
236
235
|
else:
|
|
237
236
|
return await self.get_top_teams()
|
|
238
237
|
|
|
239
|
-
async def get_live_matches(self, max_
|
|
238
|
+
async def get_live_matches(self, max_=10):
|
|
240
239
|
"""returns a list of all LIVE matches on HLTV along with the maps being played and the star ratings"""
|
|
241
240
|
r = await self._fetch("https://www.hltv.org/matches")
|
|
242
241
|
if not r:
|
|
@@ -244,30 +243,28 @@ class Hltv:
|
|
|
244
243
|
|
|
245
244
|
live_matches = r.find("div", {'class', "liveMatchesContainer"})
|
|
246
245
|
|
|
247
|
-
#cant find a way, mby use socketio by hltv-score-bot ?? | other url ?
|
|
248
|
-
|
|
246
|
+
# cant find a way, mby use socketio by hltv-score-bot ?? | other url ?
|
|
249
247
|
|
|
250
248
|
async def get_upcoming_matches(self, days: int = 7, min_rating: int = 1):
|
|
251
249
|
"""returns a list of all upcoming matches on HLTV"""
|
|
252
250
|
r = await self._fetch("https://www.hltv.org/matches")
|
|
253
|
-
if not r:return
|
|
251
|
+
if not r: return
|
|
254
252
|
|
|
255
253
|
matches = []
|
|
256
254
|
try:
|
|
257
255
|
|
|
258
|
-
|
|
259
256
|
for i, date_div in enumerate(r.find_all('div', {'class': 'upcomingMatchesSection'}), start=1):
|
|
260
257
|
if i > days:
|
|
261
258
|
break
|
|
262
259
|
date_ = date_div.find('span', {'class': 'matchDayHeadline'}).text.split()[-1]
|
|
263
|
-
matches_today = []
|
|
264
260
|
|
|
265
261
|
for match in date_div.find_all('div', {'class': 'upcomingMatch'}):
|
|
266
262
|
time_ = match.find('div', {'class': 'matchTime'}).text
|
|
267
263
|
rating = int(match['stars'])
|
|
268
264
|
if rating >= min_rating:
|
|
269
265
|
match_id_ = match.find('a')['href'].split('/')[2]
|
|
270
|
-
|
|
266
|
+
t1_id = match['team1']
|
|
267
|
+
t2_id = match['team2']
|
|
271
268
|
maps = match.find('div', {'class': 'matchMeta'}).text[-1:]
|
|
272
269
|
try:
|
|
273
270
|
teams = match.find_all('div', {'class': 'matchTeamName text-ellipsis'})
|
|
@@ -287,29 +284,28 @@ class Hltv:
|
|
|
287
284
|
except AttributeError:
|
|
288
285
|
event = ''
|
|
289
286
|
|
|
290
|
-
|
|
291
|
-
'
|
|
287
|
+
matches.append({
|
|
288
|
+
'id': match_id_,
|
|
289
|
+
'date': date_,
|
|
290
|
+
'time': time_,
|
|
292
291
|
'team1': team1,
|
|
293
292
|
'team2': team2,
|
|
294
|
-
'
|
|
293
|
+
't1_id': t1_id,
|
|
294
|
+
't2_id': t2_id,
|
|
295
295
|
'maps': maps,
|
|
296
296
|
'rating': rating,
|
|
297
297
|
'event': event
|
|
298
|
-
|
|
298
|
+
})
|
|
299
299
|
|
|
300
|
-
matches.append({
|
|
301
|
-
'date': date_,
|
|
302
|
-
'matches': matches_today
|
|
303
|
-
})
|
|
304
300
|
except AttributeError:
|
|
305
301
|
return None
|
|
306
302
|
return matches
|
|
307
303
|
|
|
308
304
|
async def get_match_info(self, match_id: str, team1: str, team2: str, event_title: str, stats: bool = True):
|
|
309
305
|
r = await self._fetch(f"https://www.hltv.org/matches/{match_id}/"
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
306
|
+
f"{team1.replace(' ', '-')}-vs-"
|
|
307
|
+
f"{team2.replace(' ', '-')}-"
|
|
308
|
+
f"{event_title.replace(' ', '-')}")
|
|
313
309
|
if not r:
|
|
314
310
|
return
|
|
315
311
|
|
|
@@ -322,19 +318,18 @@ class Hltv:
|
|
|
322
318
|
score1 = scores[0].get_text().replace('\n', '')[-1]
|
|
323
319
|
score2 = scores[1].get_text().replace('\n', '')[-1]
|
|
324
320
|
|
|
325
|
-
|
|
326
321
|
maps = []
|
|
327
322
|
for map_div in r.find_all('div', {'class': 'mapholder'}):
|
|
328
323
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
324
|
+
mapname = map_div.find('div', {'class': 'mapname'}).text
|
|
325
|
+
try:
|
|
326
|
+
r_teams = map_div.find_all('div', {'class': 'results-team-score'})
|
|
327
|
+
r_team1 = r_teams[0].text
|
|
328
|
+
r_team2 = r_teams[1].text
|
|
329
|
+
except AttributeError:
|
|
330
|
+
r_team1 = '0'
|
|
331
|
+
r_team2 = '0'
|
|
332
|
+
maps.append({'mapname': mapname, 'r_team1': r_team1, 'r_team2': r_team2})
|
|
338
333
|
|
|
339
334
|
stats_ = []
|
|
340
335
|
if stats and status == 'Match over':
|
|
@@ -373,7 +368,6 @@ class Hltv:
|
|
|
373
368
|
|
|
374
369
|
return match_id, score1, score2, status, maps, stats_
|
|
375
370
|
|
|
376
|
-
|
|
377
371
|
async def get_big_results(self, offset=0) -> list[dict[str, Any]] | None:
|
|
378
372
|
"""returns a list of big event matches results"""
|
|
379
373
|
r = await self._fetch("https://www.hltv.org/results?offset=" + str(offset))
|
|
@@ -442,7 +436,8 @@ class Hltv:
|
|
|
442
436
|
live_matches: List | Any
|
|
443
437
|
matches = []
|
|
444
438
|
try:
|
|
445
|
-
live_matches = r.find("div", {'class', 'liveMatchesSection'}).find_all("div",
|
|
439
|
+
live_matches = r.find("div", {'class', 'liveMatchesSection'}).find_all("div",
|
|
440
|
+
{'class', 'liveMatch-container'})
|
|
446
441
|
except AttributeError:
|
|
447
442
|
live_matches = []
|
|
448
443
|
for live in live_matches:
|
|
@@ -453,7 +448,6 @@ class Hltv:
|
|
|
453
448
|
t1_id = live['team1']
|
|
454
449
|
t2_id = live['team2']
|
|
455
450
|
|
|
456
|
-
|
|
457
451
|
# TODO FIX SCORES
|
|
458
452
|
"""try:
|
|
459
453
|
scores = live.find("td", class_="matchTeamScore").text.strip().split('-')
|
|
@@ -491,22 +485,24 @@ class Hltv:
|
|
|
491
485
|
pass
|
|
492
486
|
|
|
493
487
|
matches.append({
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
488
|
+
'id': id_,
|
|
489
|
+
'date': date_,
|
|
490
|
+
'time': time_,
|
|
491
|
+
'team1': team1_,
|
|
492
|
+
'team2': team2_,
|
|
493
|
+
't1_id': t1_id,
|
|
494
|
+
't2_id': t2_id
|
|
495
|
+
})
|
|
502
496
|
|
|
503
497
|
return matches
|
|
498
|
+
|
|
504
499
|
async def get_featured_events(self, max_: int = 1):
|
|
505
500
|
r = await self._fetch('https://www.hltv.org/events')
|
|
506
501
|
|
|
507
502
|
events = []
|
|
508
503
|
try:
|
|
509
|
-
for i, event in enumerate(r.find('div', {'class': 'tab-content', 'id': 'FEATURED'}).find_all('a', {
|
|
504
|
+
for i, event in enumerate(r.find('div', {'class': 'tab-content', 'id': 'FEATURED'}).find_all('a', {
|
|
505
|
+
'class': 'a-reset ongoing-event'}), start=1):
|
|
510
506
|
if i > max_:
|
|
511
507
|
break
|
|
512
508
|
event_name = event.find('div', {'class': 'text-ellipsis'}).text.strip()
|
|
@@ -527,6 +523,7 @@ class Hltv:
|
|
|
527
523
|
pass
|
|
528
524
|
|
|
529
525
|
return events
|
|
526
|
+
|
|
530
527
|
async def get_events(self, featured=True, outgoing=True, future=True, max_events=10):
|
|
531
528
|
"""Returns events
|
|
532
529
|
:params:
|
|
@@ -545,7 +542,7 @@ class Hltv:
|
|
|
545
542
|
|
|
546
543
|
if outgoing:
|
|
547
544
|
for event in r.find('div', {'class': 'tab-content', 'id': 'TODAY'}).find_all('a', {
|
|
548
|
-
|
|
545
|
+
'class': 'a-reset ongoing-event'}):
|
|
549
546
|
event_name = event.find('div', {'class': 'text-ellipsis'}).text.strip()
|
|
550
547
|
event_start_date = self._normalize_date(
|
|
551
548
|
event.find('span', {'data-time-format': 'MMM do'}).text.strip().split())
|
|
@@ -584,7 +581,7 @@ class Hltv:
|
|
|
584
581
|
return events
|
|
585
582
|
|
|
586
583
|
async def get_event_info(self, event_id: str | int, event_title: str):
|
|
587
|
-
#TODO ADD WINNER?
|
|
584
|
+
# TODO ADD WINNER?
|
|
588
585
|
|
|
589
586
|
r = await self._fetch(f"https://www.hltv.org/events/{str(event_id)}/{event_title.replace(' ', '-')}")
|
|
590
587
|
if not r:
|
|
@@ -786,7 +783,8 @@ class Hltv:
|
|
|
786
783
|
date_ = article_days[i]
|
|
787
784
|
f_news = []
|
|
788
785
|
reg_news = []
|
|
789
|
-
for featured_news_div in news_date_div.find_all('a',
|
|
786
|
+
for featured_news_div in news_date_div.find_all('a',
|
|
787
|
+
{'class': 'newsline article featured breaking-featured'}):
|
|
790
788
|
featured_id = featured_news_div['href'].split('/')[2]
|
|
791
789
|
featured_title = featured_news_div.find('div', {'class': 'featured-newstext'}).text
|
|
792
790
|
featured_description = featured_news_div.find('div', {'class': 'featured-small-newstext'}).text
|
|
@@ -798,7 +796,7 @@ class Hltv:
|
|
|
798
796
|
|
|
799
797
|
if not only_featured and reg_news_num < max_reg_news:
|
|
800
798
|
for news_div in news_date_div.find_all('a',
|
|
801
|
-
|
|
799
|
+
{'class': 'newsline article'}):
|
|
802
800
|
if reg_news_num > max_reg_news:
|
|
803
801
|
break
|
|
804
802
|
if news_div['class'] != 'newsline article featured breaking-featured':
|
|
@@ -837,5 +835,6 @@ async def test():
|
|
|
837
835
|
print(await hltv.get_top_teams())
|
|
838
836
|
print(await hltv.get_best_players())
|
|
839
837
|
|
|
838
|
+
|
|
840
839
|
if __name__ == "__main__":
|
|
841
840
|
asyncio.run(test())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|