Ryzenth 2.0.6__py3-none-any.whl → 2.0.8__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 CHANGED
@@ -4,7 +4,7 @@ import platform
4
4
  def get_user_agent() -> str:
5
5
  return f"Ryzenth/Python-{platform.python_version()}"
6
6
 
7
- __version__ = "2.0.6"
7
+ __version__ = "2.0.8"
8
8
  __author__ = "TeamKillerX"
9
9
  __title__ = "Ryzenth"
10
10
  __description__ = "Ryzenth Python API Wrapper"
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,14 @@ from os import getenv
27
27
 
28
28
  import aiohttp
29
29
  import httpx
30
+ import requests
31
+ from box import Box
30
32
 
31
33
  from .__version__ import get_user_agent
34
+ from ._benchmark import Benchmark
32
35
  from ._errors import ForbiddenError, InternalError, ToolNotFoundError, WhatFuckError
33
36
  from ._shared import TOOL_DOMAIN_MAP
37
+ from .enums import ResponseType
34
38
  from .helper import AutoRetry
35
39
  from .tl import LoggerService
36
40
 
@@ -66,6 +70,7 @@ class RyzenthApiClient:
66
70
  name: TOOL_DOMAIN_MAP.get(name)
67
71
  for name in tools_name
68
72
  }
73
+ self._sync_session = requests.Session()
69
74
  self._session = (
70
75
  httpx.AsyncClient()
71
76
  if use_httpx else
@@ -87,6 +92,12 @@ class RyzenthApiClient:
87
92
  logging.getLogger("httpx").setLevel(logging.CRITICAL)
88
93
  logging.getLogger("httpcore").setLevel(logging.CRITICAL)
89
94
 
95
+ def dict_convert_to_dot(self, obj):
96
+ return Box(obj if obj is not None else {})
97
+
98
+ def get_kwargs(self, **params):
99
+ return {k: v for k, v in params.items() if v is not None}
100
+
90
101
  def get_base_url(self, tool: str) -> str:
91
102
  check_ok = self._tools.get(tool, None)
92
103
  if check_ok is None:
@@ -153,14 +164,43 @@ class RyzenthApiClient:
153
164
  elif resp.status == 500:
154
165
  raise InternalError("Error requests status code 500")
155
166
 
167
+ def request(self, method, url, **kwargs):
168
+ return self._sync_session.request(method=method, url=url, **kwargs)
169
+
170
+ @Benchmark.sync(level=logging.DEBUG)
171
+ def sync_get(
172
+ self,
173
+ tool: str,
174
+ path: str,
175
+ params: t.Optional[dict] = None,
176
+ use_type: ResponseType = ResponseType.JSON
177
+ ) -> t.Union[dict, bytes, str]:
178
+ base_url = self.get_base_url(tool)
179
+ url = f"{base_url}{path}"
180
+ headers = self._get_headers_for_tool(tool)
181
+ resp = self.request("get", url, params=params, headers=headers)
182
+ if resp.status_code == 403:
183
+ raise ForbiddenError("Access Forbidden: You may be blocked or banned.")
184
+ elif resp.status_code == 401:
185
+ raise ForbiddenError("Access Forbidden: Required API key or invalid params.")
186
+ elif resp.status_code == 500:
187
+ raise InternalError("Error requests status code 500")
188
+ resp.raise_for_status()
189
+ if use_type == ResponseType.IMAGE:
190
+ return resp.content
191
+ elif use_type in [ResponseType.TEXT, ResponseType.HTML]:
192
+ return resp.text
193
+ return resp.json()
194
+
195
+ @Benchmark.performance(level=logging.DEBUG)
156
196
  @AutoRetry(max_retries=3, delay=1.5)
157
197
  async def get(
158
198
  self,
159
199
  tool: str,
160
200
  path: str,
161
201
  params: t.Optional[dict] = None,
162
- use_image_content: bool = False
163
- ) -> t.Union[dict, bytes]:
202
+ use_type: ResponseType = ResponseType.JSON
203
+ ) -> t.Union[dict, bytes, str]:
164
204
  await self._throttle()
165
205
  base_url = self.get_base_url(tool)
166
206
  url = f"{base_url}{path}"
@@ -170,17 +210,53 @@ class RyzenthApiClient:
170
210
  resp = await self._session.get(url, params=params, headers=headers)
171
211
  await self._status_resp_error(resp, status_httpx=True)
172
212
  resp.raise_for_status()
173
- data = resp.content if use_image_content else resp.json()
213
+ if use_type == ResponseType.IMAGE:
214
+ data = resp.content
215
+ elif use_type in [ResponseType.TEXT, ResponseType.HTML]:
216
+ data = resp.text
217
+ else:
218
+ data = resp.json()
174
219
  else:
175
220
  async with self._session.get(url, params=params, headers=headers) as resp:
176
221
  await self._status_resp_error(resp, status_httpx=False)
177
222
  resp.raise_for_status()
178
- data = await resp.read() if use_image_content else await resp.json()
179
-
223
+ if use_type == ResponseType.IMAGE:
224
+ data = await resp.read()
225
+ elif use_type in [ResponseType.TEXT, ResponseType.HTML]:
226
+ data = await resp.text()
227
+ else:
228
+ data = await resp.json()
180
229
  if self._logger:
181
230
  await self._logger.log(f"[GET {tool}] ✅ Success: {url}")
182
231
  return data
183
232
 
233
+ @Benchmark.sync(level=logging.DEBUG)
234
+ def sync_post(
235
+ self,
236
+ tool: str,
237
+ path: str,
238
+ data: t.Optional[dict] = None,
239
+ json: t.Optional[dict] = None,
240
+ use_type: ResponseType = ResponseType.JSON
241
+ ) -> t.Union[dict, bytes, str]:
242
+ base_url = self.get_base_url(tool)
243
+ url = f"{base_url}{path}"
244
+ headers = self._get_headers_for_tool(tool)
245
+ resp = self.request("post", url, data=data, json=json, headers=headers)
246
+ if resp.status_code == 403:
247
+ raise ForbiddenError("Access Forbidden: You may be blocked or banned.")
248
+ elif resp.status_code == 401:
249
+ raise ForbiddenError("Access Forbidden: Required API key or invalid params.")
250
+ elif resp.status_code == 500:
251
+ raise InternalError("Error requests status code 500")
252
+ resp.raise_for_status()
253
+ if use_type == ResponseType.IMAGE:
254
+ return resp.content
255
+ elif use_type in [ResponseType.TEXT, ResponseType.HTML]:
256
+ return resp.text
257
+ return resp.json()
258
+
259
+ @Benchmark.performance(level=logging.DEBUG)
184
260
  @AutoRetry(max_retries=3, delay=1.5)
185
261
  async def post(
186
262
  self,
@@ -188,8 +264,8 @@ class RyzenthApiClient:
188
264
  path: str,
189
265
  data: t.Optional[dict] = None,
190
266
  json: t.Optional[dict] = None,
191
- use_image_content: bool = False
192
- ) -> t.Union[dict, bytes]:
267
+ use_type: ResponseType = ResponseType.JSON
268
+ ) -> t.Union[dict, bytes, str]:
193
269
  await self._throttle()
194
270
  base_url = self.get_base_url(tool)
195
271
  url = f"{base_url}{path}"
@@ -199,16 +275,28 @@ class RyzenthApiClient:
199
275
  resp = await self._session.post(url, data=data, json=json, headers=headers)
200
276
  await self._status_resp_error(resp, status_httpx=True)
201
277
  resp.raise_for_status()
202
- data = resp.content if use_image_content else resp.json()
278
+ if use_type == ResponseType.IMAGE:
279
+ data = resp.content
280
+ elif use_type in [ResponseType.TEXT, ResponseType.HTML]:
281
+ data = resp.text
282
+ else:
283
+ data = resp.json()
203
284
  else:
204
285
  async with self._session.post(url, data=data, json=json, headers=headers) as resp:
205
286
  await self._status_resp_error(resp, status_httpx=False)
206
287
  resp.raise_for_status()
207
- data = await resp.read() if use_image_content else await resp.json()
208
-
288
+ if use_type == ResponseType.IMAGE:
289
+ data = await resp.read()
290
+ elif use_type in [ResponseType.TEXT, ResponseType.HTML]:
291
+ data = await resp.text()
292
+ else:
293
+ data = await resp.json()
209
294
  if self._logger:
210
295
  await self._logger.log(f"[POST {tool}] ✅ Success: {url}")
211
296
  return data
212
297
 
298
+ def sync_close(self):
299
+ return self._sync_session.close()
300
+
213
301
  async def close(self):
214
302
  return await self._session.aclose() if self._use_httpx else await self._session.close()
Ryzenth/_shared.py CHANGED
@@ -1,15 +1,101 @@
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
- "gemini": "https://generativelanguage.googleapis.com/v1"
10
+ "cohere": "https://api.cohere.com/v1",
11
+ "claude": "https://api.anthropic.com/v1",
12
+ "grok": "https://api.x.ai/v1",
13
+ "alibaba": "https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
14
+ "gemini": "https://generativelanguage.googleapis.com/v1beta",
15
+ "gemini-openai": "https://generativelanguage.googleapis.com/v1beta/openai"
9
16
  }
10
17
 
11
- # this API is different
18
+ ###-------------AI-----------------###
19
+
20
+ # GROK AI
21
+ """
22
+ headers = {
23
+ 'accept: application/json',
24
+ 'Authorization': 'Bearer {api_key}',
25
+ 'Content-Type': 'application/json'
26
+ }
27
+ grok_response = await clients.post(
28
+ tool="grok",
29
+ path="/chat/completions",
30
+ json={
31
+ "model": "grok-3",
32
+ "messages": [
33
+ {"role": "user", "content": "hello world!"}
34
+ ],
35
+ "temperature": 0.7
36
+ }
37
+ )
38
+ """
39
+
40
+
41
+ # COHERE
42
+ """
43
+ headers = {
44
+ 'accept: application/json',
45
+ 'Authorization': 'Bearer {api_key}',
46
+ 'Content-Type': 'application/json'
47
+ }
48
+ cohere_response = await clients.post(
49
+ tool="cohere",
50
+ path="/chat",
51
+ json={
52
+ "chat_history": [],
53
+ "message": "What year was he born?",
54
+ "connectors": [{"id": "web-search"}]
55
+ }
56
+ )
57
+ """
12
58
 
59
+ # ALIBABA
60
+ """
61
+ headers = {
62
+ 'Authorization': 'Bearer {api_key}',
63
+ 'Content-Type': 'application/json'
64
+ }
65
+ alibaba_response = await clients.post(
66
+ tool="alibaba",
67
+ path="/chat/completions",
68
+ json={
69
+ "model": "qwen-plus",
70
+ "messages": [
71
+ {"role": "user", "content": "hello world!"}
72
+ ],
73
+ "temperature": 0.7
74
+ }
75
+ )
76
+ """
77
+
78
+ # DEEPSEEK
79
+ """
80
+ headers = {
81
+ 'Authorization': 'Bearer {api_key}',
82
+ 'Content-Type': 'application/json'
83
+ }
84
+ deepseek_response = await clients.post(
85
+ tool="deepseek",
86
+ path="/chat/completions",
87
+ json={
88
+ "model": "deepseek-chat",
89
+ "messages": [
90
+ {"role": "user", "content": "hello world!"}
91
+ ],
92
+ "temperature": 0.7
93
+ }
94
+ )
95
+ """
96
+ ###-------------END AI-----------------###
97
+
98
+ # this API is different
13
99
  BASE_DICT_RENDER = {
14
100
  "transcript": "transcript-dl", #url #render
15
101
  "pinterest": "pinterest-dl", #url #render
@@ -0,0 +1,3 @@
1
+ from .types import ResponseType
2
+
3
+ __all__ = ["ResponseType"]
Ryzenth/enums/types.py ADDED
@@ -0,0 +1,8 @@
1
+ from enum import Enum
2
+
3
+
4
+ class ResponseType(str, Enum):
5
+ JSON = "json"
6
+ IMAGE = "image"
7
+ TEXT = "text"
8
+ HTML = "html"
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Ryzenth
3
- Version: 2.0.6
3
+ Version: 2.0.8
4
4
  Summary: Ryzenth Python Wrapper For Perfomance
5
5
  Author: TeamKillerX
6
6
  License: MIT
@@ -134,12 +134,28 @@ export RYZENTH_API_KEY=your-api-key
134
134
  ```
135
135
 
136
136
  ## Web scrapers
137
- * [`itzpire`](https://itzpire.com) - Team Developer
137
+ > Without authentication
138
+ >
139
+ > Free unlimited
140
+ - [`itzpire`](https://itzpire.com) - Team Developer
141
+ - [`x-api-js`](https://x-api-js.onrender.com/docs) - Ryzenth Developer
138
142
 
139
143
  ## Tool Developer
140
144
  ~ Artificial Intelligence
141
145
  - [`OpenAI`](https://platform.openai.com/docs) - OpenAI Docs
142
146
  - [`Gemini AI`](https://ai.google.dev) - Gemini AI Docs
147
+ - [`Cohere AI`](https://docs.cohere.com/) - Cohere AI Docs
148
+ - [`Qwen AI`](https://www.alibabacloud.com/help/en/model-studio/use-qwen-by-calling-api) - Alibaba AI Docs
149
+ - [`Claude AI`](https://docs.anthropic.com/) - Claude AI Docs
150
+ - [`Grok AI key`](https://docs.x.ai/docs) - Grok AI Docs
151
+
152
+ ## How to get api key?
153
+ - [`Ryzenth API key`](https://t.me/RyzenthKeyBot) - Telegram bot
154
+ - [`Openai API key`](https://platform.openai.com/api-keys) - Website official
155
+ - [`Cohere API key`](https://dashboard.cohere.com/api-keys) - Website official
156
+ - [`Alibaba API key`](https://bailian.console.alibabacloud.com/?tab=playground#/api-key) - Website official
157
+ - [`Claude API key`](https://console.anthropic.com/settings/keys) - Website official
158
+ - [`Grok API key`](https://console.x.ai/team/default/api-keys) - Website official
143
159
 
144
160
  ## Credits
145
161
 
@@ -1,11 +1,14 @@
1
1
  Ryzenth/__init__.py,sha256=tUSSKb2xEQGDZFg1g-9PsSuWAPvuUBG9cAXyIHyBmMg,1066
2
- Ryzenth/__version__.py,sha256=_TA3rYUCdqJrMGE_VClpMOuFcVFr0KLvvOY2ER_Ic98,223
2
+ Ryzenth/__version__.py,sha256=m9xP6yOfI-M2jibbin3T0a8E0EriRHVjV6ciG13nvnY,223
3
3
  Ryzenth/_asynchisded.py,sha256=5ZjrXZzMSZw3T6kQ3eg-owgH1Y2dmGWJy9AOQqcoFUQ,5051
4
4
  Ryzenth/_base_client.py,sha256=9oVkoYduSILsk38T2_jvT0frsl2B7ISD2YsR4BJ3Rfk,2032
5
- Ryzenth/_client.py,sha256=hbt3U5szOrBuJkszY6jTmAoxHs89_mEfRZHvFXOnVWk,8028
5
+ Ryzenth/_benchmark.py,sha256=ldXzfxOXzZhMC_yaNLxaBbPrC5BuWzDzlypftK4Eq_U,1143
6
+ Ryzenth/_client.py,sha256=iJpNS5zdztzom8GpNUSrbaFnAdpm8lbqzx1ySuxzJ9E,11505
6
7
  Ryzenth/_errors.py,sha256=bOqi0_DElcmRrBqyDim6K248Ys-JQRSOvd32sJGW3aw,1812
7
- Ryzenth/_shared.py,sha256=GfKOf7SPmtS5xJS9Sd5t846atH_1Ox9oCjhpqO4PXMA,2018
8
+ Ryzenth/_shared.py,sha256=_mR8q62I9aQGDSJBwaEvOztbUHPuYLXrxKL1YASiybI,3933
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=23Lkq6bkh5SVDZ2hRH1Q3nlqpl-dqqGMSznDkmgDbhc,1318
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.6.dist-info/licenses/LICENSE,sha256=C73aiGSgoCAVNzvAHs-TROaf5vV8yCj9nqpGrmfNHHo,1068
28
- ryzenth-2.0.6.dist-info/METADATA,sha256=rJu9rxGBq-7Ds5maFxs5rYugNOQGin7BVx7vZiiRkUI,5250
29
- ryzenth-2.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
- ryzenth-2.0.6.dist-info/top_level.txt,sha256=0vIhjOjoQuCxLeZO0of8VCx2jsri-bLHV28nh8wWDnc,8
31
- ryzenth-2.0.6.dist-info/RECORD,,
31
+ ryzenth-2.0.8.dist-info/licenses/LICENSE,sha256=C73aiGSgoCAVNzvAHs-TROaf5vV8yCj9nqpGrmfNHHo,1068
32
+ ryzenth-2.0.8.dist-info/METADATA,sha256=eqnaTb1atsdgMoixCgQDuv_tTn7o7M77sqCJYHgB6yQ,6171
33
+ ryzenth-2.0.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ ryzenth-2.0.8.dist-info/top_level.txt,sha256=0vIhjOjoQuCxLeZO0of8VCx2jsri-bLHV28nh8wWDnc,8
35
+ ryzenth-2.0.8.dist-info/RECORD,,