hltv-async-api 0.2.7__tar.gz → 0.2.8__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.7 → hltv_async_api-0.2.8}/PKG-INFO +1 -1
- {hltv_async_api-0.2.7 → hltv_async_api-0.2.8}/hltv_async_api/__init__.py +1 -1
- {hltv_async_api-0.2.7 → hltv_async_api-0.2.8}/hltv_async_api/aiohltv.py +12 -13
- {hltv_async_api-0.2.7 → hltv_async_api-0.2.8}/hltv_async_api.egg-info/PKG-INFO +1 -1
- {hltv_async_api-0.2.7 → hltv_async_api-0.2.8}/pyproject.toml +1 -1
- {hltv_async_api-0.2.7 → hltv_async_api-0.2.8}/setup.py +1 -1
- {hltv_async_api-0.2.7 → hltv_async_api-0.2.8}/LICENSE +0 -0
- {hltv_async_api-0.2.7 → hltv_async_api-0.2.8}/README.md +0 -0
- {hltv_async_api-0.2.7 → hltv_async_api-0.2.8}/hltv_async_api.egg-info/SOURCES.txt +0 -0
- {hltv_async_api-0.2.7 → hltv_async_api-0.2.8}/hltv_async_api.egg-info/dependency_links.txt +0 -0
- {hltv_async_api-0.2.7 → hltv_async_api-0.2.8}/hltv_async_api.egg-info/top_level.txt +0 -0
- {hltv_async_api-0.2.7 → hltv_async_api-0.2.8}/setup.cfg +0 -0
|
@@ -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
|
+
import aiofiles
|
|
5
5
|
from bs4 import BeautifulSoup
|
|
6
6
|
import asyncio
|
|
7
7
|
from asyncio import get_running_loop
|
|
@@ -76,11 +76,11 @@ class Hltv:
|
|
|
76
76
|
self.DEBUG = debug
|
|
77
77
|
self._configure_logging()
|
|
78
78
|
|
|
79
|
-
def get_proxy(self):
|
|
79
|
+
async def get_proxy(self):
|
|
80
80
|
proxy = ''
|
|
81
81
|
if self.PROXY_PATH:
|
|
82
|
-
with open(self.PROXY_PATH, "r") as file:
|
|
83
|
-
new_proxy = file.readline().strip()
|
|
82
|
+
async with aiofiles.open(self.PROXY_PATH, "r") as file:
|
|
83
|
+
new_proxy = await file.readline().strip()
|
|
84
84
|
if new_proxy:
|
|
85
85
|
proxy = new_proxy
|
|
86
86
|
|
|
@@ -88,7 +88,7 @@ class Hltv:
|
|
|
88
88
|
proxy = self.PROXY_LIST[0]
|
|
89
89
|
|
|
90
90
|
if self.PROXY_PROTOCOL and proxy != '' and self.PROXY_PROTOCOL not in proxy:
|
|
91
|
-
|
|
91
|
+
proxy = self.PROXY_PROTOCOL + '://' + proxy
|
|
92
92
|
|
|
93
93
|
return proxy
|
|
94
94
|
|
|
@@ -96,14 +96,14 @@ class Hltv:
|
|
|
96
96
|
if self.PROXY_PATH:
|
|
97
97
|
if self.PROXY_PROTOCOL:
|
|
98
98
|
proxy = proxy.replace(self.PROXY_PROTOCOL + '://', '')
|
|
99
|
-
with open(self.PROXY_PATH, "r+") as file:
|
|
100
|
-
proxies = file.readlines()
|
|
101
|
-
file.seek(0)
|
|
99
|
+
async with aiofiles.open(self.PROXY_PATH, "r+") as file:
|
|
100
|
+
proxies = await file.readlines()
|
|
101
|
+
await file.seek(0)
|
|
102
102
|
for line in proxies:
|
|
103
103
|
if line.strip() != proxy:
|
|
104
|
-
file.write(line)
|
|
104
|
+
await file.write(line)
|
|
105
105
|
if not self.REMOVE_PROXY:
|
|
106
|
-
file.write(proxy + "\n")
|
|
106
|
+
await file.write(proxy + "\n")
|
|
107
107
|
else:
|
|
108
108
|
self.PROXY_LIST = self.PROXY_LIST[1:] + [self.PROXY_LIST[0]]
|
|
109
109
|
|
|
@@ -123,7 +123,7 @@ class Hltv:
|
|
|
123
123
|
if self.USE_PROXY:
|
|
124
124
|
self.logger.debug(f"Switching proxy {proxy}")
|
|
125
125
|
await self.switch_proxy(proxy)
|
|
126
|
-
self.logger.info(f"New proxy: {self.get_proxy()}")
|
|
126
|
+
self.logger.info(f"New proxy: {await self.get_proxy()}")
|
|
127
127
|
else:
|
|
128
128
|
if delay < self.MAX_DELAY:
|
|
129
129
|
delay += 1
|
|
@@ -137,7 +137,7 @@ class Hltv:
|
|
|
137
137
|
proxy = ''
|
|
138
138
|
# setup new proxy, cuz old one was switched
|
|
139
139
|
if self.USE_PROXY:
|
|
140
|
-
proxy = self.get_proxy()
|
|
140
|
+
proxy = await self.get_proxy()
|
|
141
141
|
else:
|
|
142
142
|
# delay, only for non proxy users. (default = 1-15s)
|
|
143
143
|
await asyncio.sleep(delay)
|
|
@@ -633,7 +633,6 @@ class Hltv:
|
|
|
633
633
|
|
|
634
634
|
return players
|
|
635
635
|
|
|
636
|
-
# TODO WRITE
|
|
637
636
|
async def get_last_news(self, max_reg_news=2, only_today=True, only_featured=False):
|
|
638
637
|
r = await self.fetch('https://www.hltv.org/')
|
|
639
638
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|