hltv-async-api 0.2.5__tar.gz → 0.2.6__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.2.5
3
+ Version: 0.2.6
4
4
  Summary: Hltv-aio An unofficial asynchronous HLTV API Wrapper for Python
5
5
  Home-page: https://github.com/akimerslys/aiohltv
6
6
  Author: akimerslys
@@ -6,4 +6,4 @@
6
6
  from .aiohltv import Hltv
7
7
 
8
8
  __author__ = 'akimerslys'
9
- __version__ = '0.2.5'
9
+ __version__ = '0.2.6'
@@ -86,8 +86,8 @@ class Hltv:
86
86
  else:
87
87
  proxy = self.PROXY_LIST[0]
88
88
 
89
- if self.PROXY_PROTOCOL not in proxy and proxy != '':
90
- proxy = self.PROXY_PROTOCOL + '://' + proxy
89
+ if self.PROXY_PROTOCOL and proxy != '' and self.PROXY_PROTOCOL not in proxy:
90
+ proxy = self.PROXY_PROTOCOL + '://' + proxy
91
91
 
92
92
  return proxy
93
93
 
@@ -213,18 +213,60 @@ class Hltv:
213
213
  stars = [line.get('stars') for line in liveMatchContainer]
214
214
  return [{'teams': teams, 'maps': maps, 'stars': stars} for teams, maps, stars in zip(matches, maps, stars)]
215
215
 
216
- async def get_upcoming_matches(self):
216
+ async def get_upcoming_matches(self, days: int = 7, star_rating: int = 1):
217
217
  """returns a list of all upcoming matches on HLTV"""
218
218
  r = await self.fetch("https://www.hltv.org/matches")
219
- if not r:
220
- return
219
+ if not r:return
220
+
221
+ matches = []
221
222
  try:
222
- teams = [line.getText() for line in r.find("div",
223
- {'class', "upcomingMatchesContainer"}).find_all(
224
- class_=lambda v: v is not None and (v == "team text-ellipsis" or v == "matchTeamName text-ellipsis"))]
223
+
224
+ days = 7
225
+ for i, date_div in enumerate(r.find_all('div', {'class': 'upcomingMatchesSection'}), start=1):
226
+ if i > days:
227
+ break
228
+ date_ = date_div.find('span', {'class': 'matchDayHeadline'}).text.split()[-1]
229
+ matches_today = []
230
+
231
+ for match in date_div.find_all('div', {'class': 'upcomingMatch'}):
232
+ time_ = match.find('div', {'class': 'matchTime'}).text
233
+ rating = int(match['stars'])
234
+ if rating >= star_rating:
235
+ maps = match.find('div', {'class': 'matchMeta'}).text[-1:]
236
+ try:
237
+ teams = match.find_all('div', {'class': 'matchTeamName text-ellipsis'})
238
+
239
+ team1 = teams[0].text
240
+ team2 = teams[1].text
241
+ except (IndexError, AttributeError):
242
+ team1 = 'TBD'
243
+ team2 = 'TBD'
244
+
245
+ try:
246
+ event = match.find('div', {'class', 'matchEventName gtSmartphone-only'}).text
247
+ except AttributeError:
248
+
249
+ try:
250
+ event = match.find('span', {'class': 'line-clamp-3'}).text
251
+ except AttributeError:
252
+ event = ''
253
+
254
+ matches_today.append({
255
+ 'team1': team1,
256
+ 'team2': team2,
257
+ 'time': time_,
258
+ 'maps': maps,
259
+ 'rating': rating,
260
+ 'event': event
261
+ })
262
+
263
+ matches.append({
264
+ 'date': date_,
265
+ 'matches': matches_today
266
+ })
225
267
  except AttributeError:
226
268
  return None
227
- return [(team1, team2) for team1, team2 in tuple(zip(teams, teams[1:]))[::2]]
269
+ return matches
228
270
 
229
271
  async def get_important_upcoming_matches(self, star_rating=1):
230
272
  """returns a list of all upcoming matches on HLTV with the star rating argument (should be between 0 and 5)"""
@@ -597,7 +639,7 @@ class Hltv:
597
639
 
598
640
  async def test():
599
641
  hltv = Hltv()
600
- print(await hltv.get_event_info(7148, 'pgl-cs2-major-copenhagen-2024'))
642
+ print(await hltv.get_upcoming_matches())
601
643
 
602
644
 
603
645
  if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hltv_async_api
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Summary: Hltv-aio An unofficial asynchronous HLTV API Wrapper for Python
5
5
  Home-page: https://github.com/akimerslys/aiohltv
6
6
  Author: akimerslys
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "hltv_async_api"
3
- version = "0.2.5"
3
+ version = "0.2.6"
4
4
  authors = [
5
5
  { name="Akim Slys", email="akimslys2003@gmail.com" },
6
6
  ]
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='hltv_async_api',
5
- version='0.2.5',
5
+ version='0.2.6',
6
6
  author='akimerslys',
7
7
  author_email='akimslys2003@gmail.com',
8
8
  description='Hltv-aio: An unofficial asynchronous HLTV API Wrapper for Python',
File without changes
File without changes
File without changes