webscout 8.2.8__py3-none-any.whl → 8.2.9__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.
Files changed (184) hide show
  1. webscout/AIauto.py +32 -14
  2. webscout/AIbase.py +96 -37
  3. webscout/AIutel.py +491 -87
  4. webscout/Bard.py +441 -323
  5. webscout/Extra/GitToolkit/__init__.py +10 -10
  6. webscout/Extra/YTToolkit/ytapi/video.py +232 -232
  7. webscout/Litlogger/README.md +10 -0
  8. webscout/Litlogger/__init__.py +7 -59
  9. webscout/Litlogger/formats.py +4 -0
  10. webscout/Litlogger/handlers.py +103 -0
  11. webscout/Litlogger/levels.py +13 -0
  12. webscout/Litlogger/logger.py +92 -0
  13. webscout/Provider/AISEARCH/Perplexity.py +332 -358
  14. webscout/Provider/AISEARCH/felo_search.py +9 -35
  15. webscout/Provider/AISEARCH/genspark_search.py +30 -56
  16. webscout/Provider/AISEARCH/hika_search.py +4 -16
  17. webscout/Provider/AISEARCH/iask_search.py +410 -436
  18. webscout/Provider/AISEARCH/monica_search.py +4 -30
  19. webscout/Provider/AISEARCH/scira_search.py +6 -32
  20. webscout/Provider/AISEARCH/webpilotai_search.py +38 -64
  21. webscout/Provider/Blackboxai.py +153 -35
  22. webscout/Provider/Deepinfra.py +339 -339
  23. webscout/Provider/ExaChat.py +358 -358
  24. webscout/Provider/Gemini.py +169 -169
  25. webscout/Provider/GithubChat.py +1 -2
  26. webscout/Provider/Glider.py +3 -3
  27. webscout/Provider/HeckAI.py +171 -81
  28. webscout/Provider/OPENAI/BLACKBOXAI.py +766 -735
  29. webscout/Provider/OPENAI/Cloudflare.py +7 -7
  30. webscout/Provider/OPENAI/FreeGemini.py +6 -5
  31. webscout/Provider/OPENAI/NEMOTRON.py +8 -20
  32. webscout/Provider/OPENAI/Qwen3.py +283 -0
  33. webscout/Provider/OPENAI/README.md +952 -1253
  34. webscout/Provider/OPENAI/TwoAI.py +357 -0
  35. webscout/Provider/OPENAI/__init__.py +5 -1
  36. webscout/Provider/OPENAI/ai4chat.py +40 -40
  37. webscout/Provider/OPENAI/api.py +808 -649
  38. webscout/Provider/OPENAI/c4ai.py +3 -3
  39. webscout/Provider/OPENAI/chatgpt.py +555 -555
  40. webscout/Provider/OPENAI/chatgptclone.py +493 -487
  41. webscout/Provider/OPENAI/chatsandbox.py +4 -3
  42. webscout/Provider/OPENAI/copilot.py +242 -0
  43. webscout/Provider/OPENAI/deepinfra.py +5 -2
  44. webscout/Provider/OPENAI/e2b.py +63 -5
  45. webscout/Provider/OPENAI/exaai.py +416 -410
  46. webscout/Provider/OPENAI/exachat.py +444 -443
  47. webscout/Provider/OPENAI/freeaichat.py +2 -2
  48. webscout/Provider/OPENAI/glider.py +5 -2
  49. webscout/Provider/OPENAI/groq.py +5 -2
  50. webscout/Provider/OPENAI/heckai.py +308 -307
  51. webscout/Provider/OPENAI/mcpcore.py +8 -2
  52. webscout/Provider/OPENAI/multichat.py +4 -4
  53. webscout/Provider/OPENAI/netwrck.py +6 -5
  54. webscout/Provider/OPENAI/oivscode.py +287 -0
  55. webscout/Provider/OPENAI/opkfc.py +496 -496
  56. webscout/Provider/OPENAI/pydantic_imports.py +172 -0
  57. webscout/Provider/OPENAI/scirachat.py +15 -9
  58. webscout/Provider/OPENAI/sonus.py +304 -303
  59. webscout/Provider/OPENAI/standardinput.py +433 -433
  60. webscout/Provider/OPENAI/textpollinations.py +4 -4
  61. webscout/Provider/OPENAI/toolbaz.py +413 -413
  62. webscout/Provider/OPENAI/typefully.py +3 -3
  63. webscout/Provider/OPENAI/typegpt.py +11 -5
  64. webscout/Provider/OPENAI/uncovrAI.py +463 -462
  65. webscout/Provider/OPENAI/utils.py +90 -79
  66. webscout/Provider/OPENAI/venice.py +431 -425
  67. webscout/Provider/OPENAI/wisecat.py +387 -381
  68. webscout/Provider/OPENAI/writecream.py +3 -3
  69. webscout/Provider/OPENAI/x0gpt.py +365 -378
  70. webscout/Provider/OPENAI/yep.py +39 -13
  71. webscout/Provider/TTI/README.md +55 -101
  72. webscout/Provider/TTI/__init__.py +4 -9
  73. webscout/Provider/TTI/aiarta.py +365 -0
  74. webscout/Provider/TTI/artbit.py +0 -0
  75. webscout/Provider/TTI/base.py +64 -0
  76. webscout/Provider/TTI/fastflux.py +200 -0
  77. webscout/Provider/TTI/magicstudio.py +201 -0
  78. webscout/Provider/TTI/piclumen.py +203 -0
  79. webscout/Provider/TTI/pixelmuse.py +225 -0
  80. webscout/Provider/TTI/pollinations.py +221 -0
  81. webscout/Provider/TTI/utils.py +11 -0
  82. webscout/Provider/TTS/__init__.py +2 -1
  83. webscout/Provider/TTS/base.py +159 -159
  84. webscout/Provider/TTS/openai_fm.py +129 -0
  85. webscout/Provider/TextPollinationsAI.py +308 -308
  86. webscout/Provider/TwoAI.py +239 -44
  87. webscout/Provider/UNFINISHED/Youchat.py +330 -330
  88. webscout/Provider/UNFINISHED/puterjs.py +635 -0
  89. webscout/Provider/UNFINISHED/test_lmarena.py +119 -119
  90. webscout/Provider/Writecream.py +246 -246
  91. webscout/Provider/__init__.py +2 -0
  92. webscout/Provider/ai4chat.py +33 -8
  93. webscout/Provider/koala.py +169 -169
  94. webscout/Provider/oivscode.py +309 -0
  95. webscout/Provider/samurai.py +3 -2
  96. webscout/Provider/typegpt.py +3 -3
  97. webscout/Provider/uncovr.py +368 -368
  98. webscout/client.py +70 -0
  99. webscout/litprinter/__init__.py +58 -58
  100. webscout/optimizers.py +419 -419
  101. webscout/scout/README.md +3 -1
  102. webscout/scout/core/crawler.py +134 -64
  103. webscout/scout/core/scout.py +148 -109
  104. webscout/scout/element.py +106 -88
  105. webscout/swiftcli/Readme.md +323 -323
  106. webscout/swiftcli/plugins/manager.py +9 -2
  107. webscout/version.py +1 -1
  108. webscout/zeroart/__init__.py +134 -134
  109. webscout/zeroart/effects.py +100 -100
  110. webscout/zeroart/fonts.py +1238 -1238
  111. {webscout-8.2.8.dist-info → webscout-8.2.9.dist-info}/METADATA +159 -35
  112. {webscout-8.2.8.dist-info → webscout-8.2.9.dist-info}/RECORD +116 -161
  113. {webscout-8.2.8.dist-info → webscout-8.2.9.dist-info}/WHEEL +1 -1
  114. {webscout-8.2.8.dist-info → webscout-8.2.9.dist-info}/entry_points.txt +1 -0
  115. webscout/Litlogger/Readme.md +0 -175
  116. webscout/Litlogger/core/__init__.py +0 -6
  117. webscout/Litlogger/core/level.py +0 -23
  118. webscout/Litlogger/core/logger.py +0 -165
  119. webscout/Litlogger/handlers/__init__.py +0 -12
  120. webscout/Litlogger/handlers/console.py +0 -33
  121. webscout/Litlogger/handlers/file.py +0 -143
  122. webscout/Litlogger/handlers/network.py +0 -173
  123. webscout/Litlogger/styles/__init__.py +0 -7
  124. webscout/Litlogger/styles/colors.py +0 -249
  125. webscout/Litlogger/styles/formats.py +0 -458
  126. webscout/Litlogger/styles/text.py +0 -87
  127. webscout/Litlogger/utils/__init__.py +0 -6
  128. webscout/Litlogger/utils/detectors.py +0 -153
  129. webscout/Litlogger/utils/formatters.py +0 -200
  130. webscout/Provider/TTI/AiForce/README.md +0 -159
  131. webscout/Provider/TTI/AiForce/__init__.py +0 -22
  132. webscout/Provider/TTI/AiForce/async_aiforce.py +0 -224
  133. webscout/Provider/TTI/AiForce/sync_aiforce.py +0 -245
  134. webscout/Provider/TTI/FreeAIPlayground/README.md +0 -99
  135. webscout/Provider/TTI/FreeAIPlayground/__init__.py +0 -9
  136. webscout/Provider/TTI/FreeAIPlayground/async_freeaiplayground.py +0 -181
  137. webscout/Provider/TTI/FreeAIPlayground/sync_freeaiplayground.py +0 -180
  138. webscout/Provider/TTI/ImgSys/README.md +0 -174
  139. webscout/Provider/TTI/ImgSys/__init__.py +0 -23
  140. webscout/Provider/TTI/ImgSys/async_imgsys.py +0 -202
  141. webscout/Provider/TTI/ImgSys/sync_imgsys.py +0 -195
  142. webscout/Provider/TTI/MagicStudio/README.md +0 -101
  143. webscout/Provider/TTI/MagicStudio/__init__.py +0 -2
  144. webscout/Provider/TTI/MagicStudio/async_magicstudio.py +0 -111
  145. webscout/Provider/TTI/MagicStudio/sync_magicstudio.py +0 -109
  146. webscout/Provider/TTI/Nexra/README.md +0 -155
  147. webscout/Provider/TTI/Nexra/__init__.py +0 -22
  148. webscout/Provider/TTI/Nexra/async_nexra.py +0 -286
  149. webscout/Provider/TTI/Nexra/sync_nexra.py +0 -258
  150. webscout/Provider/TTI/PollinationsAI/README.md +0 -146
  151. webscout/Provider/TTI/PollinationsAI/__init__.py +0 -23
  152. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +0 -311
  153. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +0 -265
  154. webscout/Provider/TTI/aiarta/README.md +0 -134
  155. webscout/Provider/TTI/aiarta/__init__.py +0 -2
  156. webscout/Provider/TTI/aiarta/async_aiarta.py +0 -482
  157. webscout/Provider/TTI/aiarta/sync_aiarta.py +0 -440
  158. webscout/Provider/TTI/artbit/README.md +0 -100
  159. webscout/Provider/TTI/artbit/__init__.py +0 -22
  160. webscout/Provider/TTI/artbit/async_artbit.py +0 -155
  161. webscout/Provider/TTI/artbit/sync_artbit.py +0 -148
  162. webscout/Provider/TTI/fastflux/README.md +0 -129
  163. webscout/Provider/TTI/fastflux/__init__.py +0 -22
  164. webscout/Provider/TTI/fastflux/async_fastflux.py +0 -261
  165. webscout/Provider/TTI/fastflux/sync_fastflux.py +0 -252
  166. webscout/Provider/TTI/huggingface/README.md +0 -114
  167. webscout/Provider/TTI/huggingface/__init__.py +0 -22
  168. webscout/Provider/TTI/huggingface/async_huggingface.py +0 -199
  169. webscout/Provider/TTI/huggingface/sync_huggingface.py +0 -195
  170. webscout/Provider/TTI/piclumen/README.md +0 -161
  171. webscout/Provider/TTI/piclumen/__init__.py +0 -23
  172. webscout/Provider/TTI/piclumen/async_piclumen.py +0 -268
  173. webscout/Provider/TTI/piclumen/sync_piclumen.py +0 -233
  174. webscout/Provider/TTI/pixelmuse/README.md +0 -79
  175. webscout/Provider/TTI/pixelmuse/__init__.py +0 -4
  176. webscout/Provider/TTI/pixelmuse/async_pixelmuse.py +0 -249
  177. webscout/Provider/TTI/pixelmuse/sync_pixelmuse.py +0 -182
  178. webscout/Provider/TTI/talkai/README.md +0 -139
  179. webscout/Provider/TTI/talkai/__init__.py +0 -4
  180. webscout/Provider/TTI/talkai/async_talkai.py +0 -229
  181. webscout/Provider/TTI/talkai/sync_talkai.py +0 -207
  182. webscout/Provider/UNFINISHED/oivscode.py +0 -351
  183. {webscout-8.2.8.dist-info → webscout-8.2.9.dist-info}/licenses/LICENSE.md +0 -0
  184. {webscout-8.2.8.dist-info → webscout-8.2.9.dist-info}/top_level.txt +0 -0
@@ -1,202 +0,0 @@
1
- """ImgSys Asynchronous Provider - Generate images from multiple providers! 🔥
2
-
3
- Examples:
4
- >>> import asyncio
5
- >>> from webscout import AsyncImgSys
6
- >>>
7
- >>> async def main():
8
- ... provider = AsyncImgSys()
9
- ... # Generate images
10
- ... images = await provider.generate("A cool cyberpunk city at night")
11
- ... await provider.save(images, dir="my_images")
12
- >>> asyncio.run(main())
13
- """
14
-
15
- import aiohttp
16
- import os
17
- import time
18
- import asyncio
19
- from typing import List, Optional, Union
20
- from aiohttp import ClientError
21
- from pathlib import Path
22
-
23
- from webscout.AIbase import ImageProvider
24
- from webscout.litagent import LitAgent
25
-
26
- # Get a fresh user agent! 🔄
27
- agent = LitAgent()
28
-
29
- class AsyncImgSys(ImageProvider):
30
- """Your homie for generating fire images using imgsys.org! 🎨
31
-
32
- This provider generates images from multiple providers, with built-in retry logic
33
- and error handling to make sure you get your images no cap! 💯
34
-
35
- Examples:
36
- >>> import asyncio
37
- >>> from webscout import AsyncImgSys
38
- >>> async def main():
39
- ... provider = AsyncImgSys()
40
- ... # Generate images
41
- ... images = await provider.generate("A futuristic city")
42
- ... await provider.save(images, "city.jpg")
43
- >>> asyncio.run(main())
44
- """
45
-
46
- def __init__(
47
- self,
48
- timeout: int = 60,
49
- proxies: Optional[dict] = None
50
- ):
51
- """Initialize your AsyncImgSys provider with custom settings
52
-
53
- Examples:
54
- >>> provider = AsyncImgSys(timeout=30)
55
- >>> provider = AsyncImgSys(proxies={"http": "http://proxy:8080"})
56
-
57
- Args:
58
- timeout (int): HTTP request timeout in seconds (default: 60)
59
- proxies (dict, optional): Proxy configuration for requests
60
- """
61
- self.request_id_endpoint = "https://imgsys.org/api/initiate"
62
- self.image_response_endpoint = "https://imgsys.org/api/get"
63
- self.image_provider_endpoint = "https://imgsys.org/api/submit"
64
-
65
- self.headers = {
66
- "Accept": "application/json",
67
- "Content-Type": "application/json",
68
- "User-Agent": agent.random(),
69
- }
70
- self.timeout = aiohttp.ClientTimeout(total=timeout)
71
- self.proxies = proxies
72
- self.prompt: str = "AI-generated image - webscout"
73
- self.image_extension: str = "jpeg"
74
-
75
- async def generate(
76
- self,
77
- prompt: str,
78
- max_retries: int = 3,
79
- retry_delay: int = 5,
80
- ) -> List[bytes]:
81
- """Generate some fire images from your prompt! 🎨
82
-
83
- Args:
84
- prompt (str): Your image description
85
- max_retries (int): Max retry attempts if something fails (default: 3)
86
- retry_delay (int): Seconds to wait between retries (default: 5)
87
-
88
- Returns:
89
- List[bytes]: Your generated images as bytes
90
-
91
- Raises:
92
- ValueError: If the inputs ain't valid
93
- ClientError: If the API calls fail after retries
94
- """
95
- # Input validation
96
- if not prompt:
97
- raise ValueError("Yo fam, the prompt can't be empty! 🤔")
98
-
99
- self.prompt = prompt
100
- response = []
101
-
102
- async with aiohttp.ClientSession(headers=self.headers, timeout=self.timeout) as session:
103
- # Get request ID
104
- data = {"prompt": prompt}
105
- async with session.post(self.request_id_endpoint, json=data) as resp:
106
- resp.raise_for_status()
107
- request_id = (await resp.json())["requestId"]
108
-
109
- # Poll for results
110
- for attempt in range(max_retries):
111
- try:
112
- # Get image URLs
113
- async with session.get(
114
- f"{self.image_response_endpoint}?requestId={request_id}"
115
- ) as resp:
116
- resp.raise_for_status()
117
- image_data = await resp.json()
118
-
119
- if "results" in image_data and len(image_data["results"]) >= 2:
120
- # Get provider names
121
- async with session.post(
122
- self.image_provider_endpoint,
123
- json={"requestId": request_id, "preference": 0}
124
- ) as resp:
125
- resp.raise_for_status()
126
- provider_data = await resp.json()
127
-
128
- # Download images
129
- for i, url in enumerate(image_data["results"][:2]):
130
- async with session.get(url) as resp:
131
- resp.raise_for_status()
132
- response.append(await resp.read())
133
-
134
- break
135
- else:
136
- if attempt == max_retries - 1:
137
- raise ClientError("Failed to get image results after max retries")
138
- await asyncio.sleep(retry_delay)
139
-
140
- except ClientError as e:
141
- if attempt == max_retries - 1:
142
- raise
143
- await asyncio.sleep(retry_delay)
144
-
145
- return response
146
-
147
- async def save(
148
- self,
149
- response: List[bytes],
150
- name: Optional[str] = None,
151
- dir: Optional[Union[str, Path]] = None,
152
- filenames_prefix: str = "",
153
- ) -> List[str]:
154
- """Save your fire generated images! 💾
155
-
156
- Examples:
157
- >>> import asyncio
158
- >>> from webscout import AsyncImgSys
159
- >>> async def main():
160
- ... provider = AsyncImgSys()
161
- ... images = await provider.generate("Cool art")
162
- ... # Save with default settings
163
- ... paths = await provider.save(images)
164
- ... # Save with custom name and directory
165
- ... paths = await provider.save(
166
- ... images,
167
- ... name="my_art",
168
- ... dir="my_images",
169
- ... filenames_prefix="test_"
170
- ... )
171
- >>> asyncio.run(main())
172
-
173
- Args:
174
- response (List[bytes]): Your generated images
175
- name (Optional[str]): Custom name for your images
176
- dir (Optional[Union[str, Path]]): Where to save the images (default: current directory)
177
- filenames_prefix (str): Prefix for your image files
178
-
179
- Returns:
180
- List[str]: Paths to your saved images
181
- """
182
- save_dir = dir if dir else os.getcwd()
183
- if not os.path.exists(save_dir):
184
- os.makedirs(save_dir)
185
-
186
- saved_paths = []
187
- timestamp = int(time.time())
188
-
189
- for i, image_bytes in enumerate(response):
190
- if name:
191
- filename = f"{filenames_prefix}{name}_{i}.{self.image_extension}"
192
- else:
193
- filename = f"{filenames_prefix}imgsys_{timestamp}_{i}.{self.image_extension}"
194
-
195
- filepath = os.path.join(save_dir, filename)
196
-
197
- async with aiohttp.AsyncFile(filepath, "wb") as f:
198
- await f.write(image_bytes)
199
-
200
- saved_paths.append(filepath)
201
-
202
- return saved_paths
@@ -1,195 +0,0 @@
1
- """ImgSys Synchronous Provider - Generate images from multiple providers! 🔥
2
-
3
- Examples:
4
- >>> from webscout import ImgSys
5
- >>> provider = ImgSys()
6
- >>>
7
- >>> # Generate images
8
- >>> images = provider.generate("A cool cyberpunk city at night")
9
- >>> provider.save(images, dir="my_images")
10
- """
11
-
12
- import requests
13
- import os
14
- import time
15
- from typing import List, Optional, Union
16
- from requests.exceptions import RequestException
17
- from pathlib import Path
18
-
19
- from webscout.AIbase import ImageProvider
20
- from webscout.litagent import LitAgent
21
-
22
- # Get a fresh user agent! 🔄
23
- agent = LitAgent()
24
-
25
- class ImgSys(ImageProvider):
26
- """Your homie for generating fire images using imgsys.org! 🎨
27
-
28
- This provider generates images from multiple providers, with built-in retry logic
29
- and error handling to make sure you get your images no cap! 💯
30
-
31
- Examples:
32
- >>> provider = ImgSys()
33
- >>> # Generate images
34
- >>> images = provider.generate("A futuristic city")
35
- >>> provider.save(images, "city.jpg")
36
- """
37
-
38
- def __init__(
39
- self,
40
- timeout: int = 60,
41
- proxies: Optional[dict] = None
42
- ):
43
- """Initialize your ImgSys provider with custom settings
44
-
45
- Examples:
46
- >>> provider = ImgSys(timeout=30)
47
- >>> provider = ImgSys(proxies={"http": "http://proxy:8080"})
48
-
49
- Args:
50
- timeout (int): HTTP request timeout in seconds (default: 60)
51
- proxies (dict, optional): Proxy configuration for requests
52
- """
53
- self.request_id_endpoint = "https://imgsys.org/api/initiate"
54
- self.image_response_endpoint = "https://imgsys.org/api/get"
55
- self.image_provider_endpoint = "https://imgsys.org/api/submit"
56
-
57
- self.headers = {
58
- "Accept": "application/json",
59
- "Content-Type": "application/json",
60
- "User-Agent": agent.random(),
61
- }
62
- self.session = requests.Session()
63
- self.session.headers.update(self.headers)
64
- if proxies:
65
- self.session.proxies.update(proxies)
66
-
67
- self.timeout = timeout
68
- self.prompt: str = "AI-generated image - webscout"
69
- self.image_extension: str = "jpeg"
70
-
71
- def generate(
72
- self,
73
- prompt: str,
74
- max_retries: int = 3,
75
- retry_delay: int = 5,
76
- ) -> List[bytes]:
77
- """Generate some fire images from your prompt! 🎨
78
-
79
- Args:
80
- prompt (str): Your image description
81
- max_retries (int): Max retry attempts if something fails (default: 3)
82
- retry_delay (int): Seconds to wait between retries (default: 5)
83
-
84
- Returns:
85
- List[bytes]: Your generated images as bytes
86
-
87
- Raises:
88
- ValueError: If the inputs ain't valid
89
- RequestException: If the API calls fail after retries
90
- """
91
- # Input validation
92
- if not prompt:
93
- raise ValueError("Yo fam, the prompt can't be empty! 🤔")
94
-
95
- self.prompt = prompt
96
- response = []
97
-
98
- # Get request ID
99
- data = {"prompt": prompt}
100
- resp = self.session.post(self.request_id_endpoint, json=data, timeout=self.timeout)
101
- resp.raise_for_status()
102
- request_id = resp.json()["requestId"]
103
-
104
- # Poll for results
105
- for attempt in range(max_retries):
106
- try:
107
- # Get image URLs
108
- resp = self.session.get(
109
- f"{self.image_response_endpoint}?requestId={request_id}",
110
- timeout=self.timeout
111
- )
112
- resp.raise_for_status()
113
- image_data = resp.json()
114
-
115
- if "results" in image_data and len(image_data["results"]) >= 2:
116
- # Get provider names
117
- provider_resp = self.session.post(
118
- self.image_provider_endpoint,
119
- json={"requestId": request_id, "preference": 0},
120
- timeout=self.timeout
121
- )
122
- provider_resp.raise_for_status()
123
- provider_data = provider_resp.json()
124
-
125
- # Download images
126
- for i, url in enumerate(image_data["results"][:2]):
127
- img_resp = self.session.get(url, timeout=self.timeout)
128
- img_resp.raise_for_status()
129
- response.append(img_resp.content)
130
-
131
- break
132
- else:
133
- if attempt == max_retries - 1:
134
- raise RequestException("Failed to get image results after max retries")
135
- time.sleep(retry_delay)
136
-
137
- except RequestException as e:
138
- if attempt == max_retries - 1:
139
- raise
140
- time.sleep(retry_delay)
141
-
142
- return response
143
-
144
- def save(
145
- self,
146
- response: List[bytes],
147
- name: Optional[str] = None,
148
- dir: Optional[Union[str, Path]] = None,
149
- filenames_prefix: str = "",
150
- ) -> List[str]:
151
- """Save your fire generated images! 💾
152
-
153
- Examples:
154
- >>> provider = ImgSys()
155
- >>> images = provider.generate("Cool art")
156
- >>> # Save with default settings
157
- >>> paths = provider.save(images)
158
- >>> # Save with custom name and directory
159
- >>> paths = provider.save(
160
- ... images,
161
- ... name="my_art",
162
- ... dir="my_images",
163
- ... filenames_prefix="test_"
164
- ... )
165
-
166
- Args:
167
- response (List[bytes]): Your generated images
168
- name (Optional[str]): Custom name for your images
169
- dir (Optional[Union[str, Path]]): Where to save the images (default: current directory)
170
- filenames_prefix (str): Prefix for your image files
171
-
172
- Returns:
173
- List[str]: Paths to your saved images
174
- """
175
- save_dir = dir if dir else os.getcwd()
176
- if not os.path.exists(save_dir):
177
- os.makedirs(save_dir)
178
-
179
- saved_paths = []
180
- timestamp = int(time.time())
181
-
182
- for i, image_bytes in enumerate(response):
183
- if name:
184
- filename = f"{filenames_prefix}{name}_{i}.{self.image_extension}"
185
- else:
186
- filename = f"{filenames_prefix}imgsys_{timestamp}_{i}.{self.image_extension}"
187
-
188
- filepath = os.path.join(save_dir, filename)
189
-
190
- with open(filepath, "wb") as f:
191
- f.write(image_bytes)
192
-
193
- saved_paths.append(filepath)
194
-
195
- return saved_paths
@@ -1,101 +0,0 @@
1
- # 🎨 MagicStudio Image Generation
2
-
3
- Generate amazing images with MagicStudio's AI art generator! 🚀
4
-
5
- ## 🌟 Features
6
-
7
- - Fast and reliable image generation
8
- - Both sync and async implementations
9
- - Smart retry mechanism
10
- - Proxy support
11
- - Custom timeouts
12
- - Easy-to-use interface
13
-
14
- ## 📦 Installation
15
-
16
- ```bash
17
- pip install webscout
18
- ```
19
-
20
- ## 🚀 Quick Start
21
-
22
- ### Sync Usage
23
-
24
- ```python
25
- from webscout import MagicStudioImager
26
-
27
- # Initialize the provider
28
- provider = MagicStudioImager()
29
-
30
- # Generate a single image
31
- images = provider.generate("A beautiful sunset over mountains")
32
- paths = provider.save(images)
33
-
34
- # Generate multiple images
35
- images = provider.generate(
36
- prompt="Epic dragon breathing fire",
37
- amount=3
38
- )
39
- paths = provider.save(images, dir="dragon_pics")
40
- ```
41
-
42
- ### Async Usage
43
-
44
- ```python
45
- from webscout import AsyncMagicStudioImager
46
- import asyncio
47
-
48
- async def generate_images():
49
- provider = AsyncMagicStudioImager()
50
-
51
- # Generate multiple images
52
- images = await provider.generate(
53
- "Epic dragon in cyberpunk city",
54
- amount=2
55
- )
56
- paths = await provider.save(images, dir="outputs")
57
-
58
- # Run the async function
59
- asyncio.run(generate_images())
60
- ```
61
-
62
- ## ⚙️ Configuration
63
-
64
- ```python
65
- # Custom settings
66
- provider = MagicStudioImager(
67
- timeout=120, # Longer timeout
68
- proxies={
69
- 'http': 'http://proxy:8080',
70
- 'https': 'http://proxy:8080'
71
- }
72
- )
73
-
74
- # Advanced usage
75
- images = provider.generate(
76
- prompt="A shiny red sports car",
77
- amount=3,
78
- max_retries=5,
79
- retry_delay=3
80
- )
81
- ```
82
-
83
- ## 🛡️ Error Handling
84
-
85
- ```python
86
- try:
87
- images = provider.generate("Cool art")
88
- paths = provider.save(images)
89
- except ValueError as e:
90
- print(f"Invalid input: {e}")
91
- except Exception as e:
92
- print(f"Generation failed: {e}")
93
- ```
94
-
95
- ## 💡 Tips
96
-
97
- 1. Use clear, descriptive prompts
98
- 2. Set longer timeouts for multiple images
99
- 3. Enable proxies for better reliability
100
- 4. Use retry mechanism for stability
101
- 5. Save images with meaningful names
@@ -1,2 +0,0 @@
1
- from .async_magicstudio import *
2
- from .sync_magicstudio import *
@@ -1,111 +0,0 @@
1
- import aiohttp
2
- import asyncio
3
- import os
4
- import uuid
5
- import time
6
- from typing import List, Optional, Union, AsyncGenerator
7
- from pathlib import Path
8
-
9
- from webscout.AIbase import AsyncImageProvider
10
- from webscout.litagent import LitAgent
11
-
12
- agent = LitAgent()
13
-
14
- class AsyncMagicStudioImager(AsyncImageProvider):
15
- """Your go-to async provider for generating fire images with MagicStudio! ⚡"""
16
-
17
- def __init__(self, timeout: int = 60, proxies: dict = None):
18
- """Initialize your async MagicStudio provider with custom settings! ⚙️"""
19
- self.api_endpoint = "https://ai-api.magicstudio.com/api/ai-art-generator"
20
- self.headers = {
21
- "Accept": "application/json, text/plain, */*",
22
- "User-Agent": agent.random(),
23
- "Origin": "https://magicstudio.com",
24
- "Referer": "https://magicstudio.com/ai-art-generator/",
25
- "DNT": "1",
26
- "Sec-GPC": "1"
27
- }
28
- self.timeout = timeout
29
- self.proxies = proxies
30
- self.prompt: str = "AI-generated image - webscout"
31
- self.image_extension: str = "jpg"
32
-
33
- async def generate(
34
- self,
35
- prompt: str,
36
- amount: int = 1,
37
- max_retries: int = 3,
38
- retry_delay: int = 5
39
- ) -> List[bytes]:
40
- """Generate some fire images from your prompt asynchronously! ⚡"""
41
- if not prompt:
42
- raise ValueError("Yo fam, prompt can't be empty! 🚫")
43
- if not isinstance(amount, int) or amount < 1:
44
- raise ValueError("Amount needs to be a positive number! 📈")
45
-
46
- self.prompt = prompt
47
- response = []
48
-
49
- async with aiohttp.ClientSession(headers=self.headers) as session:
50
- for _ in range(amount):
51
- form_data = {
52
- "prompt": prompt,
53
- "output_format": "bytes",
54
- "user_profile_id": "null",
55
- "anonymous_user_id": str(uuid.uuid4()),
56
- "request_timestamp": time.time(),
57
- "user_is_subscribed": "false",
58
- "client_id": uuid.uuid4().hex,
59
- }
60
-
61
- for attempt in range(max_retries):
62
- try:
63
- async with session.post(
64
- self.api_endpoint,
65
- data=form_data,
66
- timeout=self.timeout,
67
- proxy=self.proxies.get('http') if self.proxies else None
68
- ) as resp:
69
- resp.raise_for_status()
70
- response.append(await resp.read())
71
- break
72
- except aiohttp.ClientError as e:
73
- if attempt == max_retries - 1:
74
- raise
75
- await asyncio.sleep(retry_delay)
76
-
77
- return response
78
-
79
- async def save(
80
- self,
81
- response: Union[List[bytes], AsyncGenerator[bytes, None]],
82
- name: Optional[str] = None,
83
- dir: Optional[Union[str, Path]] = None,
84
- filenames_prefix: str = "",
85
- ) -> List[str]:
86
- """Save your fire generated images asynchronously! 💾"""
87
- save_dir = dir if dir else os.getcwd()
88
- if not os.path.exists(save_dir):
89
- os.makedirs(save_dir)
90
-
91
- name = self.prompt if name is None else name
92
- saved_paths = []
93
-
94
- async def save_single_image(image_bytes: bytes, index: int) -> str:
95
- filename = f"{filenames_prefix}{name}_{index}.{self.image_extension}"
96
- filepath = os.path.join(save_dir, filename)
97
-
98
- with open(filepath, "wb") as f:
99
- f.write(image_bytes)
100
-
101
- return os.path.basename(filepath)
102
-
103
- if isinstance(response, list):
104
- image_list = response
105
- else:
106
- image_list = [chunk async for chunk in response]
107
-
108
- tasks = [save_single_image(img, i) for i, img in enumerate(image_list)]
109
- saved_paths = await asyncio.gather(*tasks)
110
-
111
- return saved_paths