Ryzenth 2.0.2__py3-none-any.whl → 2.0.4__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/__init__.py CHANGED
@@ -19,6 +19,11 @@
19
19
 
20
20
  from . import *
21
21
  from .__version__ import __version__
22
- from ._client import ApiKeyFrom, SmallConvertDot, UrHellFrom
22
+ from ._client import ApiKeyFrom, RyzenthApiClient, SmallConvertDot, UrHellFrom
23
23
 
24
- __all__ = [ "ApiKeyFrom", "UrHellFrom", "SmallConvertDot"]
24
+ __all__ = [
25
+ "ApiKeyFrom",
26
+ "RyzenthApiClient",
27
+ "UrHellFrom",
28
+ "SmallConvertDot"
29
+ ]
Ryzenth/__version__.py CHANGED
@@ -1,4 +1,10 @@
1
- __version__ = "2.0.2"
1
+ import platform
2
+
3
+
4
+ def get_user_agent() -> str:
5
+ return f"Ryzenth/Python-{platform.python_version()}"
6
+
7
+ __version__ = "2.0.4"
2
8
  __author__ = "TeamKillerX"
3
9
  __title__ = "Ryzenth"
4
10
  __description__ = "Ryzenth Python API Wrapper"
Ryzenth/_asynchisded.py CHANGED
@@ -18,11 +18,13 @@
18
18
  # along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
 
20
20
  import logging
21
+ import platform
21
22
  from typing import Union
22
23
 
23
24
  import httpx
24
25
  from box import Box
25
26
 
27
+ from .__version__ import get_user_agent
26
28
  from ._errors import InvalidModelError, WhatFuckError
27
29
  from ._shared import BASE_DICT_AI_RYZENTH, BASE_DICT_OFFICIAL, BASE_DICT_RENDER
28
30
  from .helper import (
@@ -41,7 +43,10 @@ class RyzenthXAsync:
41
43
  def __init__(self, api_key: str, base_url: str = "https://randydev-ryu-js.hf.space/api"):
42
44
  self.api_key = api_key
43
45
  self.base_url = base_url.rstrip("/")
44
- self.headers = {"x-api-key": self.api_key}
46
+ self.headers = {
47
+ "User-Agent": get_user_agent(),
48
+ "x-api-key": self.api_key
49
+ }
45
50
  self.timeout = 10
46
51
  self.params = {}
47
52
  self.images = ImagesAsync(self)
Ryzenth/_client.py CHANGED
@@ -18,10 +18,15 @@
18
18
  # along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
 
20
20
  import os
21
+ import platform
22
+ import typing as t
21
23
 
24
+ import aiohttp
22
25
  from box import Box
23
26
 
27
+ from .__version__ import get_user_agent
24
28
  from ._asynchisded import RyzenthXAsync
29
+ from ._errors import ForbiddenError, InternalError, ToolNotFoundError, WhatFuckError
25
30
  from ._synchisded import RyzenthXSync
26
31
  from .helper import Decorators
27
32
 
@@ -59,3 +64,97 @@ class SmallConvertDot:
59
64
 
60
65
  def to_dot(self):
61
66
  return Box(self.obj if self.obj is not None else {})
67
+
68
+ TOOL_DOMAIN_MAP = {
69
+ "itzpire": "https://itzpire.com",
70
+ "ryzenth": "https://randydev-ryu-js.hf.space",
71
+ }
72
+
73
+ class RyzenthApiClient:
74
+ def __init__(
75
+ self,
76
+ *,
77
+ api_key: str,
78
+ tools_name: list[str],
79
+ use_default_headers: bool = False
80
+ ) -> None:
81
+ if not api_key:
82
+ raise WhatFuckError("API Key cannot be empty.")
83
+ if not tools_name:
84
+ raise WhatFuckError("A non-empty list of tool names must be provided for 'tools_name'.")
85
+
86
+ self._api_key: str = api_key
87
+ self._use_default_headers: bool = use_default_headers
88
+ self._session: aiohttp.ClientSession = aiohttp.ClientSession(
89
+ headers={
90
+ "User-Agent": get_user_agent(),
91
+ **({"x-api-key": self._api_key} if self._use_default_headers else {})
92
+ }
93
+ )
94
+ self._tools: dict[str, str] = {
95
+ name: TOOL_DOMAIN_MAP.get(name)
96
+ for name in tools_name
97
+ }
98
+
99
+ def get_base_url(self, tool: str) -> str:
100
+ check_ok = self._tools.get(tool, None)
101
+ if check_ok is None:
102
+ raise ToolNotFoundError(f"Base URL for tool '{tool}' not found.")
103
+ return check_ok
104
+
105
+ @classmethod
106
+ def from_env(cls) -> "RyzenthApiClient":
107
+ api_key: t.Optional[str] = os.environ.get("RYZENTH_API_KEY")
108
+ if not api_key:
109
+ raise WhatFuckError("API Key cannot be empty.")
110
+ return cls(api_key=api_key)
111
+
112
+ async def _status_resp_error(self, resp):
113
+ if resp.status == 403:
114
+ raise ForbiddenError("Access Forbidden: You may be blocked or banned.")
115
+ if resp.status == 500:
116
+ raise InternalError("Error requests status code 5000")
117
+
118
+ async def get(
119
+ self,
120
+ tool: str,
121
+ path: str,
122
+ params: t.Optional[dict] = None
123
+ ) -> dict:
124
+ base_url = self.get_base_url(tool)
125
+ url = f"{base_url}{path}"
126
+ try:
127
+ async with self._session.get(url, params=params) as resp:
128
+ await self._status_resp_error(resp)
129
+ resp.raise_for_status()
130
+ return await resp.json()
131
+ except ForbiddenError as e:
132
+ return {"error": str(e)}
133
+ except aiohttp.ClientResponseError as e:
134
+ return {"error": f"HTTP Error: {e.status} {e.message}"}
135
+ except Exception as e:
136
+ return {"error": str(e)}
137
+
138
+ async def post(
139
+ self,
140
+ tool: str,
141
+ path: str,
142
+ data: t.Optional[dict] = None,
143
+ json: t.Optional[dict] = None
144
+ ) -> dict:
145
+ base_url = self.get_base_url(tool)
146
+ url = f"{base_url}{path}"
147
+ try:
148
+ async with self._session.post(url, data=data, json=json) as resp:
149
+ await self._status_resp_error(resp)
150
+ resp.raise_for_status()
151
+ return await resp.json()
152
+ except ForbiddenError as e:
153
+ return {"error": str(e)}
154
+ except aiohttp.ClientResponseError as e:
155
+ return {"error": f"HTTP Error: {e.status} {e.message}"}
156
+ except Exception as e:
157
+ return {"error": str(e)}
158
+
159
+ async def close(self):
160
+ await self._session.close()
Ryzenth/_errors.py CHANGED
@@ -26,6 +26,18 @@ class WhatFuckError(Exception):
26
26
  class ParamsRequiredError(ValueError):
27
27
  pass
28
28
 
29
+ class ForbiddenError(Exception):
30
+ """Custom exception for 403 Forbidden"""
31
+ pass
32
+
33
+ class ToolNotFoundError(Exception):
34
+ """Raised when a base URL for a requested tool cannot be found."""
35
+ pass
36
+
37
+ class InternalError(Exception):
38
+ """Custom exception for 500 Error"""
39
+ pass
40
+
29
41
  class RequiredError(ValueError):
30
42
  pass
31
43
 
@@ -46,6 +58,9 @@ class InvalidEmptyError(ValueError):
46
58
 
47
59
  __all__ = [
48
60
  "WhatFuckError",
61
+ "ForbiddenError",
62
+ "InternalError",
63
+ "ToolNotFoundError",
49
64
  "ParamsRequiredError",
50
65
  "InvalidVersionError",
51
66
  "InvalidJSONDecodeError",
Ryzenth/_synchisded.py CHANGED
@@ -18,11 +18,13 @@
18
18
  # along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
 
20
20
  import logging
21
+ import platform
21
22
  from typing import Union
22
23
 
23
24
  import httpx
24
25
  from box import Box
25
26
 
27
+ from .__version__ import get_user_agent
26
28
  from ._errors import InvalidModelError, WhatFuckError
27
29
  from ._shared import BASE_DICT_AI_RYZENTH, BASE_DICT_OFFICIAL, BASE_DICT_RENDER
28
30
  from .helper import (
@@ -41,7 +43,10 @@ class RyzenthXSync:
41
43
  def __init__(self, api_key: str, base_url: str = "https://randydev-ryu-js.hf.space/api"):
42
44
  self.api_key = api_key
43
45
  self.base_url = base_url.rstrip("/")
44
- self.headers = {"x-api-key": self.api_key}
46
+ self.headers = {
47
+ "User-Agent": get_user_agent(),
48
+ "x-api-key": self.api_key
49
+ }
45
50
  self.timeout = 10
46
51
  self.params = {}
47
52
  self.images = ImagesSync(self)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Ryzenth
3
- Version: 2.0.2
3
+ Version: 2.0.4
4
4
  Summary: Ryzenth Python Wrapper For Perfomance
5
5
  Author: TeamKillerX
6
6
  License: MIT
@@ -122,11 +122,22 @@ You can skip passing the API key directly by setting it via environment:
122
122
  export RYZENTH_API_KEY=your-api-key
123
123
  ```
124
124
 
125
+ ## Web scrapers
126
+ * [`itzpire`](https://itzpire.com) - Team Developer
127
+
125
128
  ## Credits
126
129
 
127
130
  * Built with love by [xtdevs](https://t.me/xtdevs)
128
131
  * Inspired by early work on AkenoX API
129
132
  * Thanks to Google Dev tools for AI integration concepts
133
+ * All Web scraper original
134
+
135
+ ## Donation
136
+ * Your donation helps us continue our work!
137
+
138
+ To send payments via DANA, use the following Bank Jago account number:
139
+
140
+ Bank Jago: `100201327349`
130
141
 
131
142
  ## License
132
143
 
@@ -1,10 +1,10 @@
1
- Ryzenth/__init__.py,sha256=vM1IVkgRFQT5o15KYKx8kY59114Jw5taP8ytm9YJy94,996
2
- Ryzenth/__version__.py,sha256=Nectpr0IFeoxYbiVVqKO_wyuoU3bX3HGYudTPZQiIus,118
3
- Ryzenth/_asynchisded.py,sha256=FiEkjfkgSUaUERgJz1l9TRPIN1yi0qG-Kzk1sW4OgxU,4929
4
- Ryzenth/_client.py,sha256=1DhB0Ey-XM8kSpP3ztNkGkrevyLssdFAwLf4mjI6DWU,1867
5
- Ryzenth/_errors.py,sha256=PwXVGoRQQYw05YYsh7bCRxr3jpV5k31fXCNNweag8LY,1456
1
+ Ryzenth/__init__.py,sha256=ON7RbtPrgK-Fw414Vro5J2OAGocv0522rRIojMNX2Q0,1043
2
+ Ryzenth/__version__.py,sha256=Q04fL4sPvcvdeXFCEVrdKyedK87dQO--pzGS5kN23dI,223
3
+ Ryzenth/_asynchisded.py,sha256=5ZjrXZzMSZw3T6kQ3eg-owgH1Y2dmGWJy9AOQqcoFUQ,5051
4
+ Ryzenth/_client.py,sha256=LinE_H_5LpBT2k_ulgH693IV0lkh884wNxOotmHIA_g,5226
5
+ Ryzenth/_errors.py,sha256=bOqi0_DElcmRrBqyDim6K248Ys-JQRSOvd32sJGW3aw,1812
6
6
  Ryzenth/_shared.py,sha256=zlERjX4XmYsDbkei8BRQ_-G1ozPlsn0SSalsAN6roT0,1682
7
- Ryzenth/_synchisded.py,sha256=iN-nyZMPW7KawYd5gBzskxj0NNOqhN5ddNzBFKGAxHk,4800
7
+ Ryzenth/_synchisded.py,sha256=Ns0F4iA4kWUg2j5u0Tyqj2E1mXIMs29IoQZCYW5G1Gw,4922
8
8
  Ryzenth/helper/__init__.py,sha256=BkP6fQ3IJnOqyXn07jD7anumVPlm8lVPNkFnK9b6XpE,1447
9
9
  Ryzenth/helper/_decorators.py,sha256=rEdJRoQrJfqd4LqNOiFfPwEQwMU4uVuEsoqRuQfw99I,2125
10
10
  Ryzenth/helper/_federation.py,sha256=pfqqGjg179f-olvW1Z7aX1nQf0GQJdSK4NDMaMDxmbA,14552
@@ -21,8 +21,8 @@ Ryzenth/tests/test_moderator.py,sha256=wc9A_0gx3LobMD7CDS-h2eTNPNYxeJk_rqtd2QTt4
21
21
  Ryzenth/tests/test_send.py,sha256=yPQV3XRsPKBo4eSsz5kc2R6BEuru0zmMexYshX0Ac3s,573
22
22
  Ryzenth/tests/test_send_downloader.py,sha256=23Lkq6bkh5SVDZ2hRH1Q3nlqpl-dqqGMSznDkmgDbhc,1318
23
23
  Ryzenth/types/__init__.py,sha256=2q3Oy7wCtgHa1cVY1JVN6cJht7uEAva3yFijSiJxYdI,1392
24
- ryzenth-2.0.2.dist-info/licenses/LICENSE,sha256=C73aiGSgoCAVNzvAHs-TROaf5vV8yCj9nqpGrmfNHHo,1068
25
- ryzenth-2.0.2.dist-info/METADATA,sha256=lBPbgE8B-b6NIa056bG4g3SU12FU5Il3zBY1osuG1s8,4390
26
- ryzenth-2.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
- ryzenth-2.0.2.dist-info/top_level.txt,sha256=0vIhjOjoQuCxLeZO0of8VCx2jsri-bLHV28nh8wWDnc,8
28
- ryzenth-2.0.2.dist-info/RECORD,,
24
+ ryzenth-2.0.4.dist-info/licenses/LICENSE,sha256=C73aiGSgoCAVNzvAHs-TROaf5vV8yCj9nqpGrmfNHHo,1068
25
+ ryzenth-2.0.4.dist-info/METADATA,sha256=pujr79wsNKFr6W8UJqVJODRvlN0HyuY-xh9PllIE3Jg,4642
26
+ ryzenth-2.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ ryzenth-2.0.4.dist-info/top_level.txt,sha256=0vIhjOjoQuCxLeZO0of8VCx2jsri-bLHV28nh8wWDnc,8
28
+ ryzenth-2.0.4.dist-info/RECORD,,