hltv-async-api 0.2.8b0__tar.gz → 0.3.1__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.2.8b0 → hltv_async_api-0.3.1}/PKG-INFO +10 -5
- {hltv_async_api-0.2.8b0 → hltv_async_api-0.3.1}/README.md +9 -4
- {hltv_async_api-0.2.8b0 → hltv_async_api-0.3.1}/hltv_async_api/aiohltv.py +24 -35
- {hltv_async_api-0.2.8b0 → hltv_async_api-0.3.1}/hltv_async_api.egg-info/PKG-INFO +10 -5
- {hltv_async_api-0.2.8b0 → hltv_async_api-0.3.1}/pyproject.toml +1 -1
- {hltv_async_api-0.2.8b0 → hltv_async_api-0.3.1}/setup.py +1 -2
- {hltv_async_api-0.2.8b0 → hltv_async_api-0.3.1}/LICENSE +0 -0
- {hltv_async_api-0.2.8b0 → hltv_async_api-0.3.1}/hltv_async_api/__init__.py +0 -0
- {hltv_async_api-0.2.8b0 → hltv_async_api-0.3.1}/hltv_async_api.egg-info/SOURCES.txt +0 -0
- {hltv_async_api-0.2.8b0 → hltv_async_api-0.3.1}/hltv_async_api.egg-info/dependency_links.txt +0 -0
- {hltv_async_api-0.2.8b0 → hltv_async_api-0.3.1}/hltv_async_api.egg-info/top_level.txt +0 -0
- {hltv_async_api-0.2.8b0 → hltv_async_api-0.3.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hltv_async_api
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
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
|
|
@@ -16,6 +16,10 @@ License-File: LICENSE
|
|
|
16
16
|
|
|
17
17
|
# hltv-async-api an unofficial asynchronous HLTV API Wrapper for Python
|
|
18
18
|
|
|
19
|
+
|
|
20
|
+
**This page not completed, not all methods and configs are written**
|
|
21
|
+
|
|
22
|
+
|
|
19
23
|
# Features
|
|
20
24
|
|
|
21
25
|
* New and modern fully async library
|
|
@@ -64,13 +68,13 @@ hltv = Hltv(use_proxy=True, proxy_path='PATH_TO_PROXY.TXT')
|
|
|
64
68
|
```
|
|
65
69
|
|
|
66
70
|
|
|
67
|
-
**
|
|
71
|
+
**One-time proxy**
|
|
68
72
|
|
|
69
73
|
```
|
|
70
|
-
hltv = Hltv(use_proxy=True, proxy_path='PATH_TO_PROXY.TXT',
|
|
74
|
+
hltv = Hltv(use_proxy=True, proxy_path='PATH_TO_PROXY.TXT', proxy_one_time=True)
|
|
71
75
|
```
|
|
72
76
|
|
|
73
|
-
**
|
|
77
|
+
**Protocol usage**
|
|
74
78
|
|
|
75
79
|
```
|
|
76
80
|
proxy_list = ['120.234.203.171:9002', '110.38.68.38:80']
|
|
@@ -80,6 +84,7 @@ hltv = Hltv(use_proxy=True, proxy_list=proxy_list, proxy_protocol='http')
|
|
|
80
84
|
|
|
81
85
|
---
|
|
82
86
|
# Methods
|
|
87
|
+
|
|
83
88
|
* get_upcoming_matches(days: int = 7, min_star_rating: int = 1)
|
|
84
89
|
|
|
85
90
|
-days (the number of days into the future to fetch matches for)
|
|
@@ -169,7 +174,7 @@ from hltv_async_api import Hltv
|
|
|
169
174
|
|
|
170
175
|
async def test():
|
|
171
176
|
|
|
172
|
-
hltv = Hltv(debug=True, use_proxy=True, proxy_path='proxy_test.txt', timeout=1,
|
|
177
|
+
hltv = Hltv(debug=True, use_proxy=True, proxy_path='proxy_test.txt', timeout=1, proxy_one_time=True, proxy_protocol='http')
|
|
173
178
|
|
|
174
179
|
print(await hltv.get_event_info(7148, 'pgl-cs2-major-copenhagen-2024'))
|
|
175
180
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# hltv-async-api an unofficial asynchronous HLTV API Wrapper for Python
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
**This page not completed, not all methods and configs are written**
|
|
5
|
+
|
|
6
|
+
|
|
3
7
|
# Features
|
|
4
8
|
|
|
5
9
|
* New and modern fully async library
|
|
@@ -48,13 +52,13 @@ hltv = Hltv(use_proxy=True, proxy_path='PATH_TO_PROXY.TXT')
|
|
|
48
52
|
```
|
|
49
53
|
|
|
50
54
|
|
|
51
|
-
**
|
|
55
|
+
**One-time proxy**
|
|
52
56
|
|
|
53
57
|
```
|
|
54
|
-
hltv = Hltv(use_proxy=True, proxy_path='PATH_TO_PROXY.TXT',
|
|
58
|
+
hltv = Hltv(use_proxy=True, proxy_path='PATH_TO_PROXY.TXT', proxy_one_time=True)
|
|
55
59
|
```
|
|
56
60
|
|
|
57
|
-
**
|
|
61
|
+
**Protocol usage**
|
|
58
62
|
|
|
59
63
|
```
|
|
60
64
|
proxy_list = ['120.234.203.171:9002', '110.38.68.38:80']
|
|
@@ -64,6 +68,7 @@ hltv = Hltv(use_proxy=True, proxy_list=proxy_list, proxy_protocol='http')
|
|
|
64
68
|
|
|
65
69
|
---
|
|
66
70
|
# Methods
|
|
71
|
+
|
|
67
72
|
* get_upcoming_matches(days: int = 7, min_star_rating: int = 1)
|
|
68
73
|
|
|
69
74
|
-days (the number of days into the future to fetch matches for)
|
|
@@ -153,7 +158,7 @@ from hltv_async_api import Hltv
|
|
|
153
158
|
|
|
154
159
|
async def test():
|
|
155
160
|
|
|
156
|
-
hltv = Hltv(debug=True, use_proxy=True, proxy_path='proxy_test.txt', timeout=1,
|
|
161
|
+
hltv = Hltv(debug=True, use_proxy=True, proxy_path='proxy_test.txt', timeout=1, proxy_one_time=True, proxy_protocol='http')
|
|
157
162
|
|
|
158
163
|
print(await hltv.get_event_info(7148, 'pgl-cs2-major-copenhagen-2024'))
|
|
159
164
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Any, List
|
|
2
2
|
from datetime import date, datetime, timedelta
|
|
3
3
|
import pytz
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
from bs4 import BeautifulSoup
|
|
6
6
|
import asyncio
|
|
7
7
|
from asyncio import get_running_loop
|
|
@@ -23,7 +23,7 @@ class Hltv:
|
|
|
23
23
|
debug: bool = False,
|
|
24
24
|
max_retries: int = 0,
|
|
25
25
|
proxy_protocol: str | None = None,
|
|
26
|
-
|
|
26
|
+
proxy_one_time: bool = False
|
|
27
27
|
):
|
|
28
28
|
self.headers = {
|
|
29
29
|
"referer": "https://www.hltv.org/stats",
|
|
@@ -37,11 +37,15 @@ class Hltv:
|
|
|
37
37
|
self.PROXY_PATH = proxy_path
|
|
38
38
|
self.PROXY_LIST = proxy_list
|
|
39
39
|
self.PROXY_PROTOCOL = proxy_protocol
|
|
40
|
-
self.
|
|
40
|
+
self.PROXY_ONCE = proxy_one_time
|
|
41
41
|
self.DEBUG = debug
|
|
42
42
|
self._configure_logging()
|
|
43
43
|
self.logger = logging.getLogger(__name__)
|
|
44
44
|
|
|
45
|
+
if self.PROXY_PATH:
|
|
46
|
+
with open(self.PROXY_PATH, "r") as file:
|
|
47
|
+
self.PROXY_LIST = [line.strip() for line in file.readlines()]
|
|
48
|
+
|
|
45
49
|
def _configure_logging(self):
|
|
46
50
|
level = logging.DEBUG if self.DEBUG else logging.INFO
|
|
47
51
|
logging.basicConfig(level=level, format="%(message)s")
|
|
@@ -54,7 +58,7 @@ class Hltv:
|
|
|
54
58
|
debug: bool | None = None,
|
|
55
59
|
max_retries: int | None = None,
|
|
56
60
|
proxy_protocol: str | None = None,
|
|
57
|
-
|
|
61
|
+
proxy_one_time: bool | None = None,
|
|
58
62
|
):
|
|
59
63
|
if max_delay:
|
|
60
64
|
self.MAX_DELAY = max_delay
|
|
@@ -62,50 +66,37 @@ class Hltv:
|
|
|
62
66
|
self.timeout = timeout
|
|
63
67
|
if use_proxy:
|
|
64
68
|
self.USE_PROXY = use_proxy
|
|
65
|
-
if proxy_file_path:
|
|
66
|
-
self.PROXY_PATH = proxy_file_path
|
|
67
69
|
if proxy_list:
|
|
68
70
|
self.PROXY_LIST = proxy_list
|
|
69
71
|
if max_retries:
|
|
70
72
|
self.max_retries = max_retries
|
|
71
73
|
if proxy_protocol:
|
|
72
74
|
self.PROXY_PROTOCOL = proxy_protocol
|
|
73
|
-
if
|
|
74
|
-
self.
|
|
75
|
+
if proxy_one_time:
|
|
76
|
+
self.PROXY_ONCE = proxy_one_time
|
|
75
77
|
if debug:
|
|
76
78
|
self.DEBUG = debug
|
|
77
79
|
self._configure_logging()
|
|
80
|
+
if proxy_file_path:
|
|
81
|
+
with open(self.PROXY_PATH, "r") as file:
|
|
82
|
+
self.PROXY_LIST = [line.strip() for line in file.readlines()]
|
|
78
83
|
|
|
79
84
|
async def get_proxy(self):
|
|
80
|
-
proxy =
|
|
81
|
-
if self.PROXY_PATH:
|
|
82
|
-
async with aiofiles.open(self.PROXY_PATH, "r") as file:
|
|
83
|
-
new_proxy = await file.readline().strip()
|
|
84
|
-
if new_proxy:
|
|
85
|
-
proxy = new_proxy
|
|
86
|
-
|
|
87
|
-
else:
|
|
88
|
-
proxy = self.PROXY_LIST[0]
|
|
85
|
+
proxy = self.PROXY_LIST[0]
|
|
89
86
|
|
|
90
87
|
if self.PROXY_PROTOCOL and proxy != '' and self.PROXY_PROTOCOL not in proxy:
|
|
91
88
|
proxy = self.PROXY_PROTOCOL + '://' + proxy
|
|
92
89
|
|
|
93
90
|
return proxy
|
|
94
91
|
|
|
95
|
-
async def switch_proxy(self
|
|
96
|
-
if self.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
async with aiofiles.open(self.PROXY_PATH, "r+") as file:
|
|
100
|
-
proxies = await file.readlines()
|
|
101
|
-
await file.seek(0)
|
|
102
|
-
for line in proxies:
|
|
103
|
-
if line.strip() != proxy:
|
|
104
|
-
await file.write(line)
|
|
105
|
-
if not self.REMOVE_PROXY:
|
|
106
|
-
await file.write(proxy + "\n")
|
|
92
|
+
async def switch_proxy(self):
|
|
93
|
+
if self.PROXY_ONCE:
|
|
94
|
+
self.logger.debug(f'Removing proxy {self.PROXY_LIST[0]}')
|
|
95
|
+
self.PROXY_LIST = self.PROXY_LIST[1:]
|
|
107
96
|
else:
|
|
108
|
-
self.
|
|
97
|
+
self.logger.debug(f"Switching proxy {self.PROXY_LIST[0]}")
|
|
98
|
+
self.PROXY_LIST = self.PROXY_LIST[1:] + self.PROXY_LIST[0]
|
|
99
|
+
self.logger.info(f"New proxy: {self.PROXY_LIST[0]}")
|
|
109
100
|
|
|
110
101
|
def f(self, result):
|
|
111
102
|
return BeautifulSoup(result, "lxml")
|
|
@@ -121,9 +112,7 @@ class Hltv:
|
|
|
121
112
|
|
|
122
113
|
async def parse_error_handler(self, proxy, delay: int = 0) -> int:
|
|
123
114
|
if self.USE_PROXY:
|
|
124
|
-
self.
|
|
125
|
-
await self.switch_proxy(proxy)
|
|
126
|
-
self.logger.info(f"New proxy: {await self.get_proxy()}")
|
|
115
|
+
await self.switch_proxy()
|
|
127
116
|
else:
|
|
128
117
|
if delay < self.MAX_DELAY:
|
|
129
118
|
delay += 1
|
|
@@ -689,9 +678,9 @@ class Hltv:
|
|
|
689
678
|
|
|
690
679
|
|
|
691
680
|
async def test():
|
|
692
|
-
hltv = Hltv()
|
|
693
|
-
print(await hltv.get_last_news(only_today=True, max_reg_news=1))
|
|
681
|
+
hltv = Hltv(use_proxy=True, proxy_path='proxies.txt', debug=True, one_time_proxy=True, proxy_protocol='http')
|
|
694
682
|
|
|
683
|
+
print(await hltv.get_last_news(only_today=True, max_reg_news=1))
|
|
695
684
|
|
|
696
685
|
if __name__ == "__main__":
|
|
697
686
|
asyncio.run(test())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hltv_async_api
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
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
|
|
@@ -16,6 +16,10 @@ License-File: LICENSE
|
|
|
16
16
|
|
|
17
17
|
# hltv-async-api an unofficial asynchronous HLTV API Wrapper for Python
|
|
18
18
|
|
|
19
|
+
|
|
20
|
+
**This page not completed, not all methods and configs are written**
|
|
21
|
+
|
|
22
|
+
|
|
19
23
|
# Features
|
|
20
24
|
|
|
21
25
|
* New and modern fully async library
|
|
@@ -64,13 +68,13 @@ hltv = Hltv(use_proxy=True, proxy_path='PATH_TO_PROXY.TXT')
|
|
|
64
68
|
```
|
|
65
69
|
|
|
66
70
|
|
|
67
|
-
**
|
|
71
|
+
**One-time proxy**
|
|
68
72
|
|
|
69
73
|
```
|
|
70
|
-
hltv = Hltv(use_proxy=True, proxy_path='PATH_TO_PROXY.TXT',
|
|
74
|
+
hltv = Hltv(use_proxy=True, proxy_path='PATH_TO_PROXY.TXT', proxy_one_time=True)
|
|
71
75
|
```
|
|
72
76
|
|
|
73
|
-
**
|
|
77
|
+
**Protocol usage**
|
|
74
78
|
|
|
75
79
|
```
|
|
76
80
|
proxy_list = ['120.234.203.171:9002', '110.38.68.38:80']
|
|
@@ -80,6 +84,7 @@ hltv = Hltv(use_proxy=True, proxy_list=proxy_list, proxy_protocol='http')
|
|
|
80
84
|
|
|
81
85
|
---
|
|
82
86
|
# Methods
|
|
87
|
+
|
|
83
88
|
* get_upcoming_matches(days: int = 7, min_star_rating: int = 1)
|
|
84
89
|
|
|
85
90
|
-days (the number of days into the future to fetch matches for)
|
|
@@ -169,7 +174,7 @@ from hltv_async_api import Hltv
|
|
|
169
174
|
|
|
170
175
|
async def test():
|
|
171
176
|
|
|
172
|
-
hltv = Hltv(debug=True, use_proxy=True, proxy_path='proxy_test.txt', timeout=1,
|
|
177
|
+
hltv = Hltv(debug=True, use_proxy=True, proxy_path='proxy_test.txt', timeout=1, proxy_one_time=True, proxy_protocol='http')
|
|
173
178
|
|
|
174
179
|
print(await hltv.get_event_info(7148, 'pgl-cs2-major-copenhagen-2024'))
|
|
175
180
|
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name='hltv_async_api',
|
|
5
|
-
version='0.
|
|
5
|
+
version='0.3.1',
|
|
6
6
|
author='akimerslys',
|
|
7
7
|
author_email='akimslys2003@gmail.com',
|
|
8
8
|
description='Hltv-aio: An unofficial asynchronous HLTV API Wrapper for Python',
|
|
@@ -14,7 +14,6 @@ setup(
|
|
|
14
14
|
install_requires=[
|
|
15
15
|
'aiohttp==3.9.3',
|
|
16
16
|
'aiosignal==1.3.1',
|
|
17
|
-
'aiofiles==23.2.1',
|
|
18
17
|
'attrs==23.2.0',
|
|
19
18
|
'beautifulsoup4==4.12.3',
|
|
20
19
|
'frozenlist==1.4.1',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hltv_async_api-0.2.8b0 → hltv_async_api-0.3.1}/hltv_async_api.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|