Ryzenth 1.9.6__py3-none-any.whl → 2.0.0__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
@@ -1,4 +1,4 @@
1
- __version__ = "1.9.6"
1
+ __version__ = "2.0.0"
2
2
  __author__ = "TeamKillerX"
3
3
  __title__ = "Ryzenth"
4
4
  __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
+ from typing import Union
21
22
 
22
23
  import httpx
23
24
  from box import Box
24
25
 
25
- from ._errors import WhatFuckError
26
+ from ._errors import InvalidModelError, WhatFuckError
27
+ from ._shared import BASE_DICT_AI_RYZENTH, BASE_DICT_OFFICIAL, BASE_DICT_RENDER
26
28
  from .helper import (
27
29
  FbanAsync,
28
30
  FontsAsync,
@@ -34,7 +36,6 @@ from .helper import (
34
36
  )
35
37
  from .types import DownloaderBy, QueryParameter
36
38
 
37
- LOGS = logging.getLogger("[Ryzenth] async")
38
39
 
39
40
  class RyzenthXAsync:
40
41
  def __init__(self, api_key: str, base_url: str = "https://randydev-ryu-js.hf.space/api"):
@@ -51,92 +52,75 @@ class RyzenthXAsync:
51
52
  self.fonts = FontsAsync(self)
52
53
  self.humanizer = HumanizeAsync(self)
53
54
  self.obj = Box
55
+ self.httpx = httpx
56
+ self.logger = logging.getLogger("Ryzenth Bot")
57
+ self.logger.setLevel(logging.INFO)
58
+ logging.getLogger('httpx').setLevel(logging.WARNING)
59
+ logging.getLogger('httpcore').setLevel(logging.WARNING)
60
+ if not self.logger.handlers:
61
+ handler = logging.FileHandler("RyzenthLib.log", encoding="utf-8")
62
+ handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
63
+ self.logger.addHandler(handler)
54
64
 
55
65
  async def send_downloader(
56
66
  self,
57
- switch_name: str = None,
58
- params: DownloaderBy = None,
59
- list_key=False,
67
+ switch_name: str,
68
+ *,
69
+ params: Union[DownloaderBy, QueryParameter] = None,
70
+ on_render=False,
60
71
  dot_access=False
61
72
  ):
62
- dl_dict = {
63
- "teraboxv4": "terabox-v4",
64
- "twitterv3": "twitter-v3",
65
- "xnxxinfov2": "xnxx-info-v2",
66
- "instagramv4": "instagram-v4",
67
- "instagramv3": "instagram-v3",
68
- "instagramv2": "instagram-v2",
69
- "instagram": "instagram",
70
- "twitter": "twitter",
71
- "tiktok": "tiktok",
72
- "tiktokv2": "tiktok-v2",
73
- "facebook": "fb",
74
- "snapsave": "snapsave",
75
- "savefrom": "savefrom"
76
- }
77
- if list_key:
78
- return list(dl_dict.keys())
79
-
80
- if not switch_name:
81
- raise ValueError("`switch_name` is required. Use `list_key=True` to see all valid options.")
82
73
 
74
+ dl_dict = BASE_DICT_RENDER if on_render else BASE_DICT_OFFICIAL
83
75
  model_name = dl_dict.get(switch_name)
84
76
  if not model_name:
85
- raise ValueError(f"Invalid switch_name: {switch_name}")
77
+ raise InvalidModelError(f"Invalid switch_name: {switch_name}")
86
78
 
87
79
  async with httpx.AsyncClient() as client:
88
80
  try:
89
- response = await client.get(
90
- f"{self.base_url}/v1/dl/{model_name}",
91
- params=params.dict(),
92
- headers=self.headers,
93
- timeout=self.timeout
94
- )
81
+ response = await self._client_downloader_get(client, params, model_name)
95
82
  response.raise_for_status()
96
83
  return self.obj(response.json() or {}) if dot_access else response.json()
97
84
  except httpx.HTTPError as e:
98
- LOGS.error(f"[ASYNC] Error: {str(e)}")
85
+ self.logger.error(f"[ASYNC] Error: {str(e)}")
99
86
  raise WhatFuckError("[ASYNC] Error fetching") from e
100
87
 
88
+ async def _client_message_get(self, client, params, model_param):
89
+ return await client.get(
90
+ f"{self.base_url}/v1/ai/akenox/{model_param}",
91
+ params=params.model_dump(),
92
+ headers=self.headers,
93
+ timeout=self.timeout
94
+ )
95
+
96
+ async def _client_downloader_get(self, client, params, model_param):
97
+ return await client.get(
98
+ f"{self.base_url}/v1/dl/{model_param}",
99
+ params=params.model_dump(),
100
+ headers=self.headers,
101
+ timeout=self.timeout
102
+ )
103
+
101
104
  async def send_message(
102
105
  self,
103
- model: str = None,
106
+ model: str,
107
+ *,
104
108
  params: QueryParameter = None,
105
- list_key=False,
109
+ use_full_model_list=False,
106
110
  dot_access=False
107
111
  ):
108
- model_dict = {
109
- "hybrid": "AkenoX-1.9-Hybrid",
110
- "hybrid-english": "AkenoX-1.9-Hybrid-Englsih",
111
- "melayu": "lu-melayu",
112
- "nocodefou": "nocodefou",
113
- "mia": "mia-khalifah",
114
- "curlmcode": "curl-command-code",
115
- "quotessad": "quotes-sad",
116
- "quoteslucu": "quotes-lucu",
117
- "lirikend": "lirik-end",
118
- "alsholawat": "al-sholawat"
119
- }
120
- if list_key:
121
- return list(model_dict.keys())
122
-
123
- if not model:
124
- raise ValueError("`model` is required. Use `list_key=True` to see all valid options.")
125
112
 
113
+ model_dict = BASE_DICT_AI_RYZENTH if use_full_model_list else {"hybrid": "AkenoX-1.9-Hybrid"}
126
114
  model_param = model_dict.get(model)
115
+
127
116
  if not model_param:
128
- raise ValueError(f"Invalid model name: {model}")
117
+ raise InvalidModelError(f"Invalid model name: {model}")
129
118
 
130
119
  async with httpx.AsyncClient() as client:
131
120
  try:
132
- response = await client.get(
133
- f"{self.base_url}/v1/ai/akenox/{model_param}",
134
- params=params.dict(),
135
- headers=self.headers,
136
- timeout=self.timeout
137
- )
121
+ response = await self._client_message_get(client, params, model_param)
138
122
  response.raise_for_status()
139
123
  return self.obj(response.json() or {}) if dot_access else response.json()
140
124
  except httpx.HTTPError as e:
141
- LOGS.error(f"[ASYNC] Error: {str(e)}")
125
+ self.logger.error(f"[ASYNC] Error: {str(e)}")
142
126
  raise WhatFuckError("[ASYNC] Error fetching") from e
Ryzenth/_errors.py CHANGED
@@ -26,6 +26,15 @@ class WhatFuckError(Exception):
26
26
  class ParamsRequiredError(ValueError):
27
27
  pass
28
28
 
29
+ class RequiredError(ValueError):
30
+ pass
31
+
32
+ class InvalidModelError(ValueError):
33
+ pass
34
+
35
+ class UnauthorizedAccessError(ValueError):
36
+ pass
37
+
29
38
  class InvalidVersionError(ValueError):
30
39
  pass
31
40
 
@@ -40,5 +49,8 @@ __all__ = [
40
49
  "ParamsRequiredError",
41
50
  "InvalidVersionError",
42
51
  "InvalidJSONDecodeError",
43
- "InvalidEmptyError"
52
+ "InvalidEmptyError",
53
+ "InvalidModelError",
54
+ "UnauthorizedAccessError",
55
+ "RequiredError"
44
56
  ]
Ryzenth/_shared.py ADDED
@@ -0,0 +1,46 @@
1
+ # this API is different
2
+
3
+ BASE_DICT_RENDER = {
4
+ "transcript": "transcript-dl", #url #render
5
+ "pinterest": "pinterest-dl", #url #render
6
+ "fbvideo": "fbvideo-dl", #url #render
7
+ "fbphoto": "fbphoto-dl", #url #render
8
+ "tiktok": "tiktok-dl", #url #render
9
+ "youtube-mp3": "youtube-mp3-dl", #url #render
10
+ "youtube-mp4": "youtube-mp4-dl", #url #render
11
+ "instagram": "instagram-dl", #url # render
12
+ "lyrics-search": "lyrics-search-dl", #query #render
13
+ "yt-search": "yt-search-dl", #query #render
14
+ "google-search": "google-search-dl", #query #render
15
+ "pinterest-search": "pinterest-search-dl", #query #render
16
+ "tiktok-search": "tiktok-search-dl" #query #render
17
+ }
18
+
19
+ BASE_DICT_OFFICIAL = {
20
+ "teraboxv4": "terabox-v4",
21
+ "twitterv3": "twitter-v3",
22
+ "xnxxinfov2": "xnxx-info-v2",
23
+ "instagramv4": "instagram-v4",
24
+ "instagramv3": "instagram-v3",
25
+ "instagramv2": "instagram-v2",
26
+ "instagram-v0": "instagram",
27
+ "twitter": "twitter",
28
+ "tiktok-v0": "tiktok",
29
+ "tiktokv2": "tiktok-v2",
30
+ "facebook": "fb",
31
+ "snapsave": "snapsave",
32
+ "savefrom": "savefrom"
33
+ }
34
+
35
+ BASE_DICT_AI_RYZENTH = {
36
+ "hybrid": "AkenoX-1.9-Hybrid",
37
+ "hybrid-english": "AkenoX-1.9-Hybrid-English",
38
+ "melayu": "lu-melayu",
39
+ "nocodefou": "nocodefou",
40
+ "mia": "mia-khalifah",
41
+ "curlmcode": "curl-command-code",
42
+ "quotessad": "quotes-sad",
43
+ "quoteslucu": "quotes-lucu",
44
+ "lirikend": "lirik-end",
45
+ "alsholawat": "al-sholawat"
46
+ }
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
+ from typing import Union
21
22
 
22
23
  import httpx
23
24
  from box import Box
24
25
 
25
- from ._errors import WhatFuckError
26
+ from ._errors import InvalidModelError, WhatFuckError
27
+ from ._shared import BASE_DICT_AI_RYZENTH, BASE_DICT_OFFICIAL, BASE_DICT_RENDER
26
28
  from .helper import (
27
29
  FbanSync,
28
30
  FontsSync,
@@ -34,7 +36,6 @@ from .helper import (
34
36
  )
35
37
  from .types import DownloaderBy, QueryParameter
36
38
 
37
- LOGS = logging.getLogger("[Ryzenth] sync")
38
39
 
39
40
  class RyzenthXSync:
40
41
  def __init__(self, api_key: str, base_url: str = "https://randydev-ryu-js.hf.space/api"):
@@ -51,89 +52,69 @@ class RyzenthXSync:
51
52
  self.fonts = FontsSync(self)
52
53
  self.humanizer = HumanizeSync(self)
53
54
  self.obj = Box
55
+ self.httpx = httpx
56
+ self.logger = logging.getLogger("Ryzenth Bot")
57
+ self.logger.setLevel(logging.INFO)
58
+ logging.getLogger('httpx').setLevel(logging.WARNING)
59
+ logging.getLogger('httpcore').setLevel(logging.WARNING)
60
+ if not self.logger.handlers:
61
+ handler = logging.FileHandler("RyzenthLib.log", encoding="utf-8")
62
+ handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
63
+ self.logger.addHandler(handler)
54
64
 
55
65
  def send_downloader(
56
66
  self,
57
- switch_name: str = None,
58
- params: DownloaderBy = None,
59
- list_key=False,
67
+ switch_name: str,
68
+ *,
69
+ params: Union[DownloaderBy, QueryParameter] = None,
70
+ on_render=False,
60
71
  dot_access=False
61
72
  ):
62
- dl_dict = {
63
- "teraboxv4": "terabox-v4",
64
- "twitterv3": "twitter-v3",
65
- "xnxxinfov2": "xnxx-info-v2",
66
- "instagramv4": "instagram-v4",
67
- "instagramv3": "instagram-v3",
68
- "instagramv2": "instagram-v2",
69
- "instagram": "instagram",
70
- "twitter": "twitter",
71
- "tiktok": "tiktok",
72
- "tiktokv2": "tiktok-v2",
73
- "facebook": "fb",
74
- "snapsave": "snapsave",
75
- "savefrom": "savefrom"
76
- }
77
- if list_key:
78
- return list(dl_dict.keys())
79
-
80
- if not switch_name:
81
- raise ValueError("`switch_name` is required. Use `list_key=True` to see all valid options.")
82
-
73
+ dl_dict = BASE_DICT_RENDER if on_render else BASE_DICT_OFFICIAL
83
74
  model_name = dl_dict.get(switch_name)
84
75
  if not model_name:
85
- raise ValueError(f"Invalid switch_name: {switch_name}")
76
+ raise InvalidModelError(f"Invalid switch_name: {switch_name}")
86
77
  try:
87
78
  response = httpx.get(
88
79
  f"{self.base_url}/v1/dl/{model_name}",
89
- params=params.dict(),
80
+ params=params.model_dump(),
90
81
  headers=self.headers,
91
82
  timeout=self.timeout
92
83
  )
93
84
  response.raise_for_status()
94
85
  return self.obj(response.json() or {}) if dot_access else response.json()
95
86
  except httpx.HTTPError as e:
96
- LOGS.error(f"[SYNC] Error fetching from downloader {e}")
87
+ self.logger.error(f"[SYNC] Error fetching from downloader {e}")
97
88
  raise WhatFuckError("[SYNC] Error fetching from downloader") from e
89
+ except httpx.ReadTimeout as e:
90
+ self.logger.error(f"[SYNC] Error ReadTimeout from downloader {e}")
91
+ raise WhatFuckError("[SYNC] Error ReadTimeout from downloader ") from e
98
92
 
99
93
  def send_message(
100
94
  self,
101
- model: str = None,
95
+ model: str,
96
+ *,
102
97
  params: QueryParameter = None,
103
- list_key=False,
98
+ use_full_model_list=False,
104
99
  dot_access=False
105
100
  ):
106
- model_dict = {
107
- "hybrid": "AkenoX-1.9-Hybrid",
108
- "hybrid-english": "AkenoX-1.9-Hybrid-Englsih",
109
- "melayu": "lu-melayu",
110
- "nocodefou": "nocodefou",
111
- "mia": "mia-khalifah",
112
- "curlmcode": "curl-command-code",
113
- "quotessad": "quotes-sad",
114
- "quoteslucu": "quotes-lucu",
115
- "lirikend": "lirik-end",
116
- "alsholawat": "al-sholawat"
117
- }
118
- if list_key:
119
- return list(model_dict.keys())
120
-
121
- if not model:
122
- raise ValueError("`model` is required. Use `list_key=True` to see all valid options.")
123
-
101
+ model_dict = BASE_DICT_AI_RYZENTH if use_full_model_list else {"hybrid": "AkenoX-1.9-Hybrid"}
124
102
  model_param = model_dict.get(model)
125
103
  if not model_param:
126
- raise ValueError(f"Invalid model name: {model}")
104
+ raise InvalidModelError(f"Invalid model name: {model}")
127
105
 
128
106
  try:
129
107
  response = httpx.get(
130
108
  f"{self.base_url}/v1/ai/akenox/{model_param}",
131
- params=params.dict(),
109
+ params=params.model_dump(),
132
110
  headers=self.headers,
133
111
  timeout=self.timeout
134
112
  )
135
113
  response.raise_for_status()
136
114
  return self.obj(response.json() or {}) if dot_access else response.json()
137
115
  except httpx.HTTPError as e:
138
- LOGS.error(f"[SYNC] Error fetching from akenox: {e}")
116
+ self.logger.error(f"[SYNC] Error fetching from akenox: {e}")
139
117
  raise WhatFuckError("[SYNC] Error fetching from akenox") from e
118
+ except httpx.ReadTimeout as e:
119
+ self.logger.error(f"[SYNC] Error ReadTimeout from Akenox {e}")
120
+ raise WhatFuckError("[SYNC] Error ReadTimeout from akenox") from e
@@ -40,7 +40,10 @@ class Decorators:
40
40
  "Please provide a query after the command.", **kwargs
41
41
  )
42
42
  result = await self._clients_ai.aio.send_message(
43
- name, QueryParameter(query=query), dot_access=True
43
+ model=name,
44
+ params=QueryParameter(query=query),
45
+ use_full_model_list=True,
46
+ dot_access=True
44
47
  )
45
48
  await message.reply_text(result.results, **kwargs)
46
49
  return await func(client, message, query, *args, **kwargs)