Ryzenth 2.0.6__py3-none-any.whl → 2.0.7__py3-none-any.whl
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.
- Ryzenth/__version__.py +1 -1
- Ryzenth/_benchmark.py +34 -0
- Ryzenth/_client.py +91 -10
- Ryzenth/_shared.py +45 -2
- Ryzenth/enums/__init__.py +3 -0
- Ryzenth/enums/types.py +8 -0
- Ryzenth/tests/test_ryzenthapiclient.py +17 -0
- Ryzenth/tests/test_send_downloader.py +0 -10
- {ryzenth-2.0.6.dist-info → ryzenth-2.0.7.dist-info}/METADATA +1 -1
- {ryzenth-2.0.6.dist-info → ryzenth-2.0.7.dist-info}/RECORD +13 -9
- {ryzenth-2.0.6.dist-info → ryzenth-2.0.7.dist-info}/WHEEL +0 -0
- {ryzenth-2.0.6.dist-info → ryzenth-2.0.7.dist-info}/licenses/LICENSE +0 -0
- {ryzenth-2.0.6.dist-info → ryzenth-2.0.7.dist-info}/top_level.txt +0 -0
Ryzenth/__version__.py
CHANGED
Ryzenth/_benchmark.py
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
import logging
|
2
|
+
import time
|
3
|
+
from functools import wraps
|
4
|
+
|
5
|
+
logger = logging.getLogger(__name__)
|
6
|
+
|
7
|
+
class Benchmark:
|
8
|
+
@classmethod
|
9
|
+
def performance(cls, level=logging.INFO):
|
10
|
+
def decorator(func):
|
11
|
+
@wraps(func)
|
12
|
+
async def wrapper(*args, **kwargs):
|
13
|
+
start_time = time.perf_counter()
|
14
|
+
result = await func(*args, **kwargs)
|
15
|
+
end_time = time.perf_counter()
|
16
|
+
msg = f"[BENCH] {func.__name__} executed in {end_time - start_time:.2f}s"
|
17
|
+
logger.log(level, msg)
|
18
|
+
return result
|
19
|
+
return wrapper
|
20
|
+
return decorator
|
21
|
+
|
22
|
+
@classmethod
|
23
|
+
def sync(cls, level=logging.INFO):
|
24
|
+
def decorator(func):
|
25
|
+
@wraps(func)
|
26
|
+
def wrapper(*args, **kwargs):
|
27
|
+
start_time = time.perf_counter()
|
28
|
+
result = func(*args, **kwargs)
|
29
|
+
end_time = time.perf_counter()
|
30
|
+
msg = f"[BENCH] {func.__name__} executed in {end_time - start_time:.2f}s"
|
31
|
+
logger.log(level, msg)
|
32
|
+
return result
|
33
|
+
return wrapper
|
34
|
+
return decorator
|
Ryzenth/_client.py
CHANGED
@@ -27,10 +27,13 @@ from os import getenv
|
|
27
27
|
|
28
28
|
import aiohttp
|
29
29
|
import httpx
|
30
|
+
import requests
|
30
31
|
|
31
32
|
from .__version__ import get_user_agent
|
33
|
+
from ._benchmark import Benchmark
|
32
34
|
from ._errors import ForbiddenError, InternalError, ToolNotFoundError, WhatFuckError
|
33
35
|
from ._shared import TOOL_DOMAIN_MAP
|
36
|
+
from .enums import ResponseType
|
34
37
|
from .helper import AutoRetry
|
35
38
|
from .tl import LoggerService
|
36
39
|
|
@@ -66,6 +69,7 @@ class RyzenthApiClient:
|
|
66
69
|
name: TOOL_DOMAIN_MAP.get(name)
|
67
70
|
for name in tools_name
|
68
71
|
}
|
72
|
+
self._sync_session = requests.Session()
|
69
73
|
self._session = (
|
70
74
|
httpx.AsyncClient()
|
71
75
|
if use_httpx else
|
@@ -153,14 +157,43 @@ class RyzenthApiClient:
|
|
153
157
|
elif resp.status == 500:
|
154
158
|
raise InternalError("Error requests status code 500")
|
155
159
|
|
160
|
+
def request(self, method, url, **kwargs):
|
161
|
+
return self._sync_session.request(method=method, url=url, **kwargs)
|
162
|
+
|
163
|
+
@Benchmark.sync(level=logging.DEBUG)
|
164
|
+
def sync_get(
|
165
|
+
self,
|
166
|
+
tool: str,
|
167
|
+
path: str,
|
168
|
+
params: t.Optional[dict] = None,
|
169
|
+
use_type: ResponseType = ResponseType.JSON
|
170
|
+
) -> t.Union[dict, bytes, str]:
|
171
|
+
base_url = self.get_base_url(tool)
|
172
|
+
url = f"{base_url}{path}"
|
173
|
+
headers = self._get_headers_for_tool(tool)
|
174
|
+
resp = self.request("get", url, params=params, headers=headers)
|
175
|
+
if resp.status_code == 403:
|
176
|
+
raise ForbiddenError("Access Forbidden: You may be blocked or banned.")
|
177
|
+
elif resp.status_code == 401:
|
178
|
+
raise ForbiddenError("Access Forbidden: Required API key or invalid params.")
|
179
|
+
elif resp.status_code == 500:
|
180
|
+
raise InternalError("Error requests status code 500")
|
181
|
+
resp.raise_for_status()
|
182
|
+
if use_type == ResponseType.IMAGE:
|
183
|
+
return resp.content
|
184
|
+
elif use_type in [ResponseType.TEXT, ResponseType.HTML]:
|
185
|
+
return resp.text
|
186
|
+
return resp.json()
|
187
|
+
|
188
|
+
@Benchmark.performance(level=logging.DEBUG)
|
156
189
|
@AutoRetry(max_retries=3, delay=1.5)
|
157
190
|
async def get(
|
158
191
|
self,
|
159
192
|
tool: str,
|
160
193
|
path: str,
|
161
194
|
params: t.Optional[dict] = None,
|
162
|
-
|
163
|
-
) -> t.Union[dict, bytes]:
|
195
|
+
use_type: ResponseType = ResponseType.JSON
|
196
|
+
) -> t.Union[dict, bytes, str]:
|
164
197
|
await self._throttle()
|
165
198
|
base_url = self.get_base_url(tool)
|
166
199
|
url = f"{base_url}{path}"
|
@@ -170,17 +203,53 @@ class RyzenthApiClient:
|
|
170
203
|
resp = await self._session.get(url, params=params, headers=headers)
|
171
204
|
await self._status_resp_error(resp, status_httpx=True)
|
172
205
|
resp.raise_for_status()
|
173
|
-
|
206
|
+
if use_type == ResponseType.IMAGE:
|
207
|
+
data = resp.content
|
208
|
+
elif use_type in [ResponseType.TEXT, ResponseType.HTML]:
|
209
|
+
data = resp.text
|
210
|
+
else:
|
211
|
+
data = resp.json()
|
174
212
|
else:
|
175
213
|
async with self._session.get(url, params=params, headers=headers) as resp:
|
176
214
|
await self._status_resp_error(resp, status_httpx=False)
|
177
215
|
resp.raise_for_status()
|
178
|
-
|
179
|
-
|
216
|
+
if use_type == ResponseType.IMAGE:
|
217
|
+
data = await resp.read()
|
218
|
+
elif use_type in [ResponseType.TEXT, ResponseType.HTML]:
|
219
|
+
data = await resp.text()
|
220
|
+
else:
|
221
|
+
data = await resp.json()
|
180
222
|
if self._logger:
|
181
223
|
await self._logger.log(f"[GET {tool}] ✅ Success: {url}")
|
182
224
|
return data
|
183
225
|
|
226
|
+
@Benchmark.sync(level=logging.DEBUG)
|
227
|
+
def sync_post(
|
228
|
+
self,
|
229
|
+
tool: str,
|
230
|
+
path: str,
|
231
|
+
data: t.Optional[dict] = None,
|
232
|
+
json: t.Optional[dict] = None,
|
233
|
+
use_type: ResponseType = ResponseType.JSON
|
234
|
+
) -> t.Union[dict, bytes, str]:
|
235
|
+
base_url = self.get_base_url(tool)
|
236
|
+
url = f"{base_url}{path}"
|
237
|
+
headers = self._get_headers_for_tool(tool)
|
238
|
+
resp = self.request("post", url, data=data, json=json, headers=headers)
|
239
|
+
if resp.status_code == 403:
|
240
|
+
raise ForbiddenError("Access Forbidden: You may be blocked or banned.")
|
241
|
+
elif resp.status_code == 401:
|
242
|
+
raise ForbiddenError("Access Forbidden: Required API key or invalid params.")
|
243
|
+
elif resp.status_code == 500:
|
244
|
+
raise InternalError("Error requests status code 500")
|
245
|
+
resp.raise_for_status()
|
246
|
+
if use_type == ResponseType.IMAGE:
|
247
|
+
return resp.content
|
248
|
+
elif use_type in [ResponseType.TEXT, ResponseType.HTML]:
|
249
|
+
return resp.text
|
250
|
+
return resp.json()
|
251
|
+
|
252
|
+
@Benchmark.performance(level=logging.DEBUG)
|
184
253
|
@AutoRetry(max_retries=3, delay=1.5)
|
185
254
|
async def post(
|
186
255
|
self,
|
@@ -188,8 +257,8 @@ class RyzenthApiClient:
|
|
188
257
|
path: str,
|
189
258
|
data: t.Optional[dict] = None,
|
190
259
|
json: t.Optional[dict] = None,
|
191
|
-
|
192
|
-
) -> t.Union[dict, bytes]:
|
260
|
+
use_type: ResponseType = ResponseType.JSON
|
261
|
+
) -> t.Union[dict, bytes, str]:
|
193
262
|
await self._throttle()
|
194
263
|
base_url = self.get_base_url(tool)
|
195
264
|
url = f"{base_url}{path}"
|
@@ -199,16 +268,28 @@ class RyzenthApiClient:
|
|
199
268
|
resp = await self._session.post(url, data=data, json=json, headers=headers)
|
200
269
|
await self._status_resp_error(resp, status_httpx=True)
|
201
270
|
resp.raise_for_status()
|
202
|
-
|
271
|
+
if use_type == ResponseType.IMAGE:
|
272
|
+
data = resp.content
|
273
|
+
elif use_type in [ResponseType.TEXT, ResponseType.HTML]:
|
274
|
+
data = resp.text
|
275
|
+
else:
|
276
|
+
data = resp.json()
|
203
277
|
else:
|
204
278
|
async with self._session.post(url, data=data, json=json, headers=headers) as resp:
|
205
279
|
await self._status_resp_error(resp, status_httpx=False)
|
206
280
|
resp.raise_for_status()
|
207
|
-
|
208
|
-
|
281
|
+
if use_type == ResponseType.IMAGE:
|
282
|
+
data = await resp.read()
|
283
|
+
elif use_type in [ResponseType.TEXT, ResponseType.HTML]:
|
284
|
+
data = await resp.text()
|
285
|
+
else:
|
286
|
+
data = await resp.json()
|
209
287
|
if self._logger:
|
210
288
|
await self._logger.log(f"[POST {tool}] ✅ Success: {url}")
|
211
289
|
return data
|
212
290
|
|
291
|
+
def sync_close(self):
|
292
|
+
return self._sync_session.close()
|
293
|
+
|
213
294
|
async def close(self):
|
214
295
|
return await self._session.aclose() if self._use_httpx else await self._session.close()
|
Ryzenth/_shared.py
CHANGED
@@ -1,15 +1,58 @@
|
|
1
|
+
# Expired 2026 💀
|
1
2
|
UNKNOWN_TEST = "YWtlbm9fVUtRRVFNdDk5MWtoMkVoaDdKcUpZS2FweDhDQ3llQw=="
|
2
3
|
|
3
4
|
TOOL_DOMAIN_MAP = {
|
4
5
|
"itzpire": "https://itzpire.com",
|
5
6
|
"ryzenth": "https://randydev-ryu-js.hf.space",
|
6
7
|
"onrender": "https://x-api-js.onrender.com",
|
8
|
+
"deepseek": "https://api.deepseek.com",
|
7
9
|
"openai": "https://api.openai.com/v1",
|
8
|
-
"
|
10
|
+
"alibaba": "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
|
11
|
+
"gemini": "https://generativelanguage.googleapis.com/v1beta",
|
12
|
+
"gemini-openai": "https://generativelanguage.googleapis.com/v1beta/openai"
|
9
13
|
}
|
10
14
|
|
11
|
-
|
15
|
+
###-------------AI-----------------###
|
16
|
+
# ALIBABA
|
17
|
+
"""
|
18
|
+
headers = {
|
19
|
+
'Authorization': 'Bearer {api_key}',
|
20
|
+
'Content-Type': 'application/json'
|
21
|
+
}
|
22
|
+
alibaba_response = await clients.post(
|
23
|
+
tool="alibaba",
|
24
|
+
path="/chat/completions",
|
25
|
+
json={
|
26
|
+
"model": "qwen-plus",
|
27
|
+
"messages": [
|
28
|
+
{"role": "user", "content": "hello world!"}
|
29
|
+
],
|
30
|
+
"temperature": 0.7
|
31
|
+
}
|
32
|
+
)
|
33
|
+
"""
|
12
34
|
|
35
|
+
# DEEPSEEK
|
36
|
+
"""
|
37
|
+
headers = {
|
38
|
+
'Authorization': 'Bearer {api_key}',
|
39
|
+
'Content-Type': 'application/json'
|
40
|
+
}
|
41
|
+
deepseek_response = await clients.post(
|
42
|
+
tool="deepseek",
|
43
|
+
path="/chat/completions",
|
44
|
+
json={
|
45
|
+
"model": "deepseek-chat",
|
46
|
+
"messages": [
|
47
|
+
{"role": "user", "content": "hello world!"}
|
48
|
+
],
|
49
|
+
"temperature": 0.7
|
50
|
+
}
|
51
|
+
)
|
52
|
+
"""
|
53
|
+
###-------------END AI-----------------###
|
54
|
+
|
55
|
+
# this API is different
|
13
56
|
BASE_DICT_RENDER = {
|
14
57
|
"transcript": "transcript-dl", #url #render
|
15
58
|
"pinterest": "pinterest-dl", #url #render
|
Ryzenth/enums/types.py
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
from Ryzenth import RyzenthApiClient
|
2
|
+
from Ryzenth.enums import ResponseType
|
3
|
+
|
4
|
+
clients = RyzenthApiClient(
|
5
|
+
tools_name=["itzpire"],
|
6
|
+
api_key={"itzpire": [{}]},
|
7
|
+
rate_limit=100,
|
8
|
+
use_httpx=True # Fixed Aiohttp RuntimeError: no running event loop
|
9
|
+
)
|
10
|
+
|
11
|
+
def test_itzpire():
|
12
|
+
result = clients.sync_get(
|
13
|
+
tool="itzpire",
|
14
|
+
path="/games/siapakah-aku",
|
15
|
+
use_type=ResponseType.JSON
|
16
|
+
)
|
17
|
+
assert result is not None
|
@@ -24,16 +24,6 @@ def test_yt_username():
|
|
24
24
|
)
|
25
25
|
assert result is not None
|
26
26
|
|
27
|
-
def test_hentai_anime():
|
28
|
-
ryz = RyzenthXSync("test", base_url="https://x-api-js.onrender.com/api")
|
29
|
-
result = ryz.send_downloader(
|
30
|
-
switch_name="hentai-anime",
|
31
|
-
params=None,
|
32
|
-
params_only=False,
|
33
|
-
on_render=True
|
34
|
-
)
|
35
|
-
assert result is not None
|
36
|
-
|
37
27
|
def test_xnxxdl():
|
38
28
|
ryz = RyzenthXSync("test", base_url="https://x-api-js.onrender.com/api")
|
39
29
|
result = ryz.send_downloader(
|
@@ -1,11 +1,14 @@
|
|
1
1
|
Ryzenth/__init__.py,sha256=tUSSKb2xEQGDZFg1g-9PsSuWAPvuUBG9cAXyIHyBmMg,1066
|
2
|
-
Ryzenth/__version__.py,sha256=
|
2
|
+
Ryzenth/__version__.py,sha256=veVwJEAurqkYKy2C6Ejt7eKkpeq2yOG9QGXSjUBNHcs,223
|
3
3
|
Ryzenth/_asynchisded.py,sha256=5ZjrXZzMSZw3T6kQ3eg-owgH1Y2dmGWJy9AOQqcoFUQ,5051
|
4
4
|
Ryzenth/_base_client.py,sha256=9oVkoYduSILsk38T2_jvT0frsl2B7ISD2YsR4BJ3Rfk,2032
|
5
|
-
Ryzenth/
|
5
|
+
Ryzenth/_benchmark.py,sha256=ldXzfxOXzZhMC_yaNLxaBbPrC5BuWzDzlypftK4Eq_U,1143
|
6
|
+
Ryzenth/_client.py,sha256=8hH40oHL0zu2HuiaBwXMSN5rN1XEALe9q_gIx897i9I,11290
|
6
7
|
Ryzenth/_errors.py,sha256=bOqi0_DElcmRrBqyDim6K248Ys-JQRSOvd32sJGW3aw,1812
|
7
|
-
Ryzenth/_shared.py,sha256=
|
8
|
+
Ryzenth/_shared.py,sha256=Hr72hnxpoG5sFFb0YK47_7cD5TGjgyXIyzykZeldk0Q,3061
|
8
9
|
Ryzenth/_synchisded.py,sha256=Ns0F4iA4kWUg2j5u0Tyqj2E1mXIMs29IoQZCYW5G1Gw,4922
|
10
|
+
Ryzenth/enums/__init__.py,sha256=5V6-BcLESFrWFhSDQ7IwmSccAITjb82HgpYi7NQeIeU,60
|
11
|
+
Ryzenth/enums/types.py,sha256=FE7d5qdAGRCRqs5HAyiJZPPMcn5MAm7WHuGz5GTQuTo,129
|
9
12
|
Ryzenth/helper/__init__.py,sha256=ZditYtDnZOtTJ_odPgWH0Nrj-qQJ868zjy41_DzK_ns,1473
|
10
13
|
Ryzenth/helper/_decorators.py,sha256=8uKdcseA7Cbq5sy2twgujZhbwqjaLwX13BT70diNRFs,2782
|
11
14
|
Ryzenth/helper/_federation.py,sha256=pfqqGjg179f-olvW1Z7aX1nQf0GQJdSK4NDMaMDxmbA,14552
|
@@ -19,13 +22,14 @@ Ryzenth/pyoraddons/__init__.py,sha256=Xt4w4YHoFKwMZe8QslhLKp6mHBjBowvYjzkN95ikpj
|
|
19
22
|
Ryzenth/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
23
|
Ryzenth/tests/test_deepseek.py,sha256=_KbYr-haKBt5Xc-YULBL9Ic5OM02SX17hvQWWjYpNAk,255
|
21
24
|
Ryzenth/tests/test_moderator.py,sha256=wc9A_0gx3LobMD7CDS-h2eTNPNYxeJk_rqtd2QTt428,291
|
25
|
+
Ryzenth/tests/test_ryzenthapiclient.py,sha256=U0WuYg2bc4p3jQK0P77eez4cKxkfiZjUKLKO0oe0rCc,440
|
22
26
|
Ryzenth/tests/test_send.py,sha256=yPQV3XRsPKBo4eSsz5kc2R6BEuru0zmMexYshX0Ac3s,573
|
23
|
-
Ryzenth/tests/test_send_downloader.py,sha256=
|
27
|
+
Ryzenth/tests/test_send_downloader.py,sha256=LvS7QSO4XyjG1UXH8pHvXCCMpvAs9_QVMfh7J9w_xdM,1038
|
24
28
|
Ryzenth/tl/__init__.py,sha256=SDoC1aFqHf682PasjkCIWzBdqvOJQ-Wn7ybDOxhHmMo,71
|
25
29
|
Ryzenth/tl/logger_service.py,sha256=23Mdi9obe-aF9SWBwgbRlk3hgQJdK9JYfg1iOsaUAW0,2651
|
26
30
|
Ryzenth/types/__init__.py,sha256=2q3Oy7wCtgHa1cVY1JVN6cJht7uEAva3yFijSiJxYdI,1392
|
27
|
-
ryzenth-2.0.
|
28
|
-
ryzenth-2.0.
|
29
|
-
ryzenth-2.0.
|
30
|
-
ryzenth-2.0.
|
31
|
-
ryzenth-2.0.
|
31
|
+
ryzenth-2.0.7.dist-info/licenses/LICENSE,sha256=C73aiGSgoCAVNzvAHs-TROaf5vV8yCj9nqpGrmfNHHo,1068
|
32
|
+
ryzenth-2.0.7.dist-info/METADATA,sha256=2H9iYtByjZbowDYzReZnjMT8gWDfJHLeykKulu1r7oc,5250
|
33
|
+
ryzenth-2.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
34
|
+
ryzenth-2.0.7.dist-info/top_level.txt,sha256=0vIhjOjoQuCxLeZO0of8VCx2jsri-bLHV28nh8wWDnc,8
|
35
|
+
ryzenth-2.0.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|