webscout 6.3__py3-none-any.whl → 6.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.

Potentially problematic release.


This version of webscout might be problematic. Click here for more details.

Files changed (85) hide show
  1. webscout/AIauto.py +191 -176
  2. webscout/AIbase.py +0 -197
  3. webscout/AIutel.py +488 -1130
  4. webscout/Bing_search.py +250 -153
  5. webscout/DWEBS.py +151 -19
  6. webscout/Extra/__init__.py +2 -1
  7. webscout/Extra/autocoder/__init__.py +9 -0
  8. webscout/Extra/autocoder/autocoder_utiles.py +121 -0
  9. webscout/Extra/autocoder/rawdog.py +681 -0
  10. webscout/Extra/autollama.py +246 -195
  11. webscout/Extra/gguf.py +441 -416
  12. webscout/LLM.py +206 -43
  13. webscout/Litlogger/__init__.py +681 -0
  14. webscout/Provider/DARKAI.py +1 -1
  15. webscout/Provider/EDITEE.py +1 -1
  16. webscout/Provider/NinjaChat.py +1 -1
  17. webscout/Provider/PI.py +221 -207
  18. webscout/Provider/Perplexity.py +598 -598
  19. webscout/Provider/RoboCoders.py +206 -0
  20. webscout/Provider/TTI/AiForce/__init__.py +22 -0
  21. webscout/Provider/TTI/AiForce/async_aiforce.py +257 -0
  22. webscout/Provider/TTI/AiForce/sync_aiforce.py +242 -0
  23. webscout/Provider/TTI/Nexra/__init__.py +22 -0
  24. webscout/Provider/TTI/Nexra/async_nexra.py +286 -0
  25. webscout/Provider/TTI/Nexra/sync_nexra.py +258 -0
  26. webscout/Provider/TTI/PollinationsAI/__init__.py +23 -0
  27. webscout/Provider/TTI/PollinationsAI/async_pollinations.py +330 -0
  28. webscout/Provider/TTI/PollinationsAI/sync_pollinations.py +285 -0
  29. webscout/Provider/TTI/__init__.py +2 -4
  30. webscout/Provider/TTI/artbit/__init__.py +22 -0
  31. webscout/Provider/TTI/artbit/async_artbit.py +184 -0
  32. webscout/Provider/TTI/artbit/sync_artbit.py +176 -0
  33. webscout/Provider/TTI/blackbox/__init__.py +4 -0
  34. webscout/Provider/TTI/blackbox/async_blackbox.py +212 -0
  35. webscout/Provider/TTI/{blackboximage.py → blackbox/sync_blackbox.py} +199 -153
  36. webscout/Provider/TTI/deepinfra/__init__.py +4 -0
  37. webscout/Provider/TTI/deepinfra/async_deepinfra.py +227 -0
  38. webscout/Provider/TTI/deepinfra/sync_deepinfra.py +199 -0
  39. webscout/Provider/TTI/huggingface/__init__.py +22 -0
  40. webscout/Provider/TTI/huggingface/async_huggingface.py +199 -0
  41. webscout/Provider/TTI/huggingface/sync_huggingface.py +195 -0
  42. webscout/Provider/TTI/imgninza/__init__.py +4 -0
  43. webscout/Provider/TTI/imgninza/async_ninza.py +214 -0
  44. webscout/Provider/TTI/{imgninza.py → imgninza/sync_ninza.py} +209 -136
  45. webscout/Provider/TTI/talkai/__init__.py +4 -0
  46. webscout/Provider/TTI/talkai/async_talkai.py +229 -0
  47. webscout/Provider/TTI/talkai/sync_talkai.py +207 -0
  48. webscout/Provider/__init__.py +146 -139
  49. webscout/Provider/askmyai.py +2 -2
  50. webscout/Provider/cerebras.py +227 -219
  51. webscout/Provider/llama3mitril.py +0 -1
  52. webscout/Provider/mhystical.py +176 -0
  53. webscout/Provider/perplexitylabs.py +265 -0
  54. webscout/Provider/twitterclone.py +251 -245
  55. webscout/Provider/typegpt.py +359 -0
  56. webscout/__init__.py +28 -23
  57. webscout/__main__.py +5 -5
  58. webscout/cli.py +252 -280
  59. webscout/conversation.py +227 -0
  60. webscout/exceptions.py +161 -29
  61. webscout/litagent/__init__.py +172 -0
  62. webscout/litprinter/__init__.py +831 -0
  63. webscout/optimizers.py +270 -0
  64. webscout/prompt_manager.py +279 -0
  65. webscout/swiftcli/__init__.py +810 -0
  66. webscout/transcriber.py +479 -551
  67. webscout/update_checker.py +125 -0
  68. webscout/version.py +1 -1
  69. {webscout-6.3.dist-info → webscout-6.4.dist-info}/METADATA +26 -45
  70. {webscout-6.3.dist-info → webscout-6.4.dist-info}/RECORD +75 -45
  71. webscout/Provider/TTI/AIuncensoredimage.py +0 -103
  72. webscout/Provider/TTI/Nexra.py +0 -120
  73. webscout/Provider/TTI/PollinationsAI.py +0 -138
  74. webscout/Provider/TTI/WebSimAI.py +0 -142
  75. webscout/Provider/TTI/aiforce.py +0 -160
  76. webscout/Provider/TTI/artbit.py +0 -141
  77. webscout/Provider/TTI/deepinfra.py +0 -148
  78. webscout/Provider/TTI/huggingface.py +0 -155
  79. webscout/Provider/TTI/talkai.py +0 -116
  80. webscout/models.py +0 -23
  81. /webscout/{g4f.py → gpt4free.py} +0 -0
  82. {webscout-6.3.dist-info → webscout-6.4.dist-info}/LICENSE.md +0 -0
  83. {webscout-6.3.dist-info → webscout-6.4.dist-info}/WHEEL +0 -0
  84. {webscout-6.3.dist-info → webscout-6.4.dist-info}/entry_points.txt +0 -0
  85. {webscout-6.3.dist-info → webscout-6.4.dist-info}/top_level.txt +0 -0
webscout/cli.py CHANGED
@@ -1,22 +1,19 @@
1
- import csv
2
- import logging
3
1
  import os
2
+ import sys
4
3
  from concurrent.futures import ThreadPoolExecutor, as_completed
5
4
  from datetime import datetime
6
5
  from urllib.parse import unquote
7
6
  from pathlib import Path
8
- import click
7
+ from .swiftcli import CLI, option, argument, group
9
8
  from curl_cffi import requests
10
9
  import pyreqwest_impersonate as pri
11
10
  from .webscout_search import WEBS
12
11
  from .utils import json_dumps, json_loads
13
12
  from .version import __version__
14
- from .interactive import interactive_session
15
-
16
- # Import rich for panel interface
13
+ from .Litlogger import LitLogger, LogFormat, ColorScheme
14
+ from rich.console import Console
17
15
  from rich.panel import Panel
18
16
  from rich.markdown import Markdown
19
- from rich.console import Console
20
17
  from rich.table import Table
21
18
  from rich.style import Style
22
19
  from rich.text import Text
@@ -26,7 +23,12 @@ from rich.prompt import Prompt, Confirm
26
23
  from rich.columns import Columns
27
24
  from pyfiglet import figlet_format
28
25
 
29
- logger = logging.getLogger(__name__)
26
+ logger = LitLogger(
27
+ name="webscout",
28
+ format=LogFormat.MODERN_EMOJI,
29
+ color_scheme=ColorScheme.CYBERPUNK,
30
+ console_output=True
31
+ )
30
32
 
31
33
  COLORS = {
32
34
  0: "black",
@@ -60,296 +62,266 @@ def _print_data(data):
60
62
  if v:
61
63
  width = 300 if k in ("content", "href", "image", "source", "thumbnail", "url") else 78
62
64
  k = "language" if k == "detected_language" else k
63
- text = click.wrap_text(
64
- f"{v}", width=width, initial_indent="", subsequent_indent=" " * 18, preserve_paragraphs=True
65
- ).replace("\n", "\n\n")
65
+ text = Text(f"{v}", style="white")
66
+ text = text.wrap(width=width, initial_indent="", subsequent_indent=" " * 18, preserve_paragraphs=True)
66
67
  else:
67
- text = v
68
+ text = Text(v, style="white")
68
69
  table.add_row(k, text)
69
70
 
70
71
  # Only the Panel has the title now
71
72
  console.print(Panel(table, title=f"Result {i}", expand=False, style="green on black"))
72
73
  console.print("\n")
73
-
74
-
75
- def _sanitize_keywords(keywords):
76
- """Sanitizes keywords for file names and paths. Removes invalid characters like ':'. """
77
- keywords = (
78
- keywords.replace("filetype", "")
79
- .replace(":", "")
80
- .replace('"', "'")
81
- .replace("site", "")
82
- .replace(" ", "_")
83
- .replace("/", "_")
84
- .replace("\\", "_")
85
- .replace(" ", "")
86
- )
87
- return keywords
88
-
89
- @click.group(chain=True)
90
- def cli():
91
- """webscout CLI tool - Search the web with a rich UI."""
92
- console = Console()
93
- console.print(f"[bold blue]{figlet_format('Webscout')}[/]\n", justify="center")
94
-
95
- def safe_entry_point():
96
- try:
97
- cli()
98
- except Exception as ex:
99
- click.echo(f"{type(ex).__name__}: {ex}")
100
74
 
75
+ # Initialize CLI app
76
+ app = CLI(name="webscout", help="Search the web with a rich UI", version=__version__)
101
77
 
102
- @cli.command()
78
+ @app.command()
103
79
  def version():
104
- """Shows the current version of webscout."""
80
+ """Show the version of webscout."""
105
81
  console = Console()
106
- console.print(Panel(Text(f"webscout v{__version__}", style="cyan"), title="Version", expand=False))
82
+ console.print(f"[bold green]webscout[/bold green] version: {__version__}")
107
83
 
108
-
109
- @cli.command()
110
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
111
- def chat(proxy):
84
+ @app.command()
85
+ @option("--proxy", help="Proxy URL to use for requests")
86
+ @option("--model", "-m", help="AI model to use", default="gpt-4o-mini", type=str)
87
+ def chat(proxy: str = None, model: str = "gpt-4o-mini"):
112
88
  """Interactive AI chat using DuckDuckGo's AI."""
113
- models = ["gpt-3.5", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b"]
114
- client = WEBS(proxy=proxy)
115
-
89
+ webs = WEBS(proxy=proxy)
116
90
  console = Console()
117
- console.print(Panel(Text("Available AI Models:", style="cyan"), title="DuckDuckGo AI Chat", expand=False))
118
- console.print(Columns([Panel(Text(model, justify="center"), expand=True) for model in models]))
119
- chosen_model_idx = Prompt.ask("[bold cyan]Choose a model by entering its number[/] [1]", choices=[str(i) for i in range(1, len(models) + 1)], default="1")
120
- chosen_model_idx = int(chosen_model_idx) - 1
121
- model = models[chosen_model_idx]
122
- console.print(f"[bold green]Using model:[/] {model}")
123
-
124
- while True:
125
- user_input = Prompt.ask(f"{'-'*78}\n[bold blue]You:[/]")
126
- if not user_input.strip():
127
- break
128
-
129
- resp_answer = client.chat(keywords=user_input, model=model)
130
- text = click.wrap_text(resp_answer, width=78, preserve_paragraphs=True)
131
- console.print(Panel(Text(f"AI: {text}", style="green"), title="AI Response"))
132
-
133
- if "exit" in user_input.lower() or "quit" in user_input.lower():
134
- console.print(Panel(Text("Exiting chat session.", style="cyan"), title="Goodbye", expand=False))
135
- break
136
-
137
-
138
- @cli.command()
139
- @click.option("-k", "--keywords", required=True, help="Keywords for text search.")
140
- @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
141
- @click.option("-s", "--safesearch", default="moderate", type=click.Choice(["on", "moderate", "off"]), help="Safe search level.")
142
- @click.option("-t", "--timelimit", default=None, type=click.Choice(["d", "w", "m", "y"]), help="Time limit (d: day, w: week, m: month, y: year).")
143
- @click.option("-m", "--max_results", default=20, help="Maximum number of results to retrieve (default: 20).")
144
- @click.option("-b", "--backend", default="api", type=click.Choice(["api", "html", "lite"]), help="Backend to use (api, html, lite).")
145
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
146
- def text(keywords, region, safesearch, timelimit, backend, max_results, proxy):
147
- """Performs a text search using DuckDuckGo API with a rich UI."""
148
- data = WEBS(proxy=proxy).text(
149
- keywords=keywords,
150
- region=region,
151
- safesearch=safesearch,
152
- timelimit=timelimit,
153
- backend=backend,
154
- max_results=max_results,
155
- )
156
- _print_data(data)
157
-
158
- @cli.command()
159
- @click.option("-k", "--keywords", required=True, help="Keywords for answers search.")
160
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
161
- def answers(keywords, proxy):
162
- """Performs an answers search using DuckDuckGo API with a rich UI."""
163
- data = WEBS(proxy=proxy).answers(keywords=keywords)
164
- _print_data(data)
165
-
166
-
167
- @cli.command()
168
- @click.option("-k", "--keywords", required=True, help="Keywords for images search.")
169
- @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
170
- @click.option("-s", "--safesearch", default="moderate", type=click.Choice(["on", "moderate", "off"]), help="Safe search level.")
171
- @click.option("-t", "--timelimit", default=None, type=click.Choice(["Day", "Week", "Month", "Year"]), help="Time limit (Day, Week, Month, Year).")
172
- @click.option("-size", "--size", default=None, type=click.Choice(["Small", "Medium", "Large", "Wallpaper"]), help="Image size (Small, Medium, Large, Wallpaper).")
173
- @click.option(
174
- "-c",
175
- "--color",
176
- default=None,
177
- type=click.Choice(
178
- [
179
- "color",
180
- "Monochrome",
181
- "Red",
182
- "Orange",
183
- "Yellow",
184
- "Green",
185
- "Blue",
186
- "Purple",
187
- "Pink",
188
- "Brown",
189
- "Black",
190
- "Gray",
191
- "Teal",
192
- "White",
193
- ]
194
- ),
195
- help="Image color (color, Monochrome, Red, Orange, Yellow, Green, Blue, Purple, Pink, Brown, Black, Gray, Teal, White).",
196
- )
197
- @click.option(
198
- "-type", "--type_image", default=None, type=click.Choice(["photo", "clipart", "gif", "transparent", "line"]), help="Image type (photo, clipart, gif, transparent, line)."
199
- )
200
- @click.option("-l", "--layout", default=None, type=click.Choice(["Square", "Tall", "Wide"]), help="Image layout (Square, Tall, Wide).")
201
- @click.option(
202
- "-lic",
203
- "--license_image",
204
- default=None,
205
- type=click.Choice(["any", "Public", "Share", "Modify", "ModifyCommercially"]),
206
- help="Image license (any, Public, Share, Modify, ModifyCommercially).",
207
- )
208
- @click.option("-m", "--max_results", default=90, help="Maximum number of results to retrieve (default: 90).")
209
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
91
+
92
+ # Display header
93
+ console.print(f"[bold blue]{figlet_format('Webscout Chat')}[/]\n", justify="center")
94
+ console.print(f"[bold green]Using model:[/] {model}\n")
95
+ console.print("[cyan]Type your message and press Enter. Press Ctrl+C or type 'exit' to quit.[/]\n")
96
+
97
+ # Start chat loop
98
+ try:
99
+ while True:
100
+ try:
101
+ user_input = input("You: ").strip()
102
+ if not user_input or user_input.lower() in ['exit', 'quit']:
103
+ break
104
+
105
+ logger.info(f"Sending message to {model}")
106
+ response = webs.chat(keywords=user_input, model=model)
107
+ console.print(f"\nAI: {response}\n")
108
+ logger.success("Received response from AI")
109
+
110
+ except Exception as e:
111
+ logger.error(f"Error in chat: {str(e)}")
112
+ console.print(f"[bold red]Error:[/] {str(e)}\n")
113
+
114
+ except KeyboardInterrupt:
115
+ logger.info("Chat session terminated by user")
116
+
117
+ console.print("\n[cyan]Chat session ended. Goodbye![/]")
118
+
119
+ @app.command()
120
+ @option("--keywords", "-k", help="Search keywords")
121
+ @option("--region", "-r", help="Region for search results", default="wt-wt")
122
+ @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
123
+ @option("--timelimit", "-t", help="Time limit for results", default=None)
124
+ @option("--backend", "-b", help="Search backend to use", default="api")
125
+ @option("--max-results", "-m", help="Maximum number of results", type=int, default=25)
126
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
127
+ def text(keywords: str, region: str, safesearch: str, timelimit: str, backend: str, max_results: int, proxy: str = None):
128
+ """Perform a text search using DuckDuckGo API."""
129
+ webs = WEBS(proxy=proxy)
130
+ try:
131
+ webs.text(keywords, region, safesearch, timelimit, backend, max_results)
132
+ except Exception as e:
133
+ logger.error(f"Error in text search: {e}")
134
+ raise e
135
+
136
+ @app.command()
137
+ @option("--keywords", "-k", help="Search keywords")
138
+ @option("--region", "-r", help="Region for search results", default="wt-wt")
139
+ @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
140
+ @option("--timelimit", "-t", help="Time limit for results", default=None)
141
+ @option("--max-results", "-m", help="Maximum number of results", type=int, default=25)
142
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
143
+ def answers(keywords: str, region: str, safesearch: str, timelimit: str, max_results: int, proxy: str = None):
144
+ """Perform an answers search using DuckDuckGo API."""
145
+ webs = WEBS(proxy=proxy)
146
+ try:
147
+ webs.answers(keywords, region, safesearch, timelimit, max_results)
148
+ except Exception as e:
149
+ logger.error(f"Error in answers search: {e}")
150
+ raise e
151
+
152
+ @app.command()
153
+ @option("--keywords", "-k", help="Search keywords")
154
+ @option("--region", "-r", help="Region for search results", default="wt-wt")
155
+ @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
156
+ @option("--timelimit", "-t", help="Time limit for results", default=None)
157
+ @option("--size", "-size", help="Image size", default=None)
158
+ @option("--color", "-c", help="Image color", default=None)
159
+ @option("--type", "-type", help="Image type", default=None)
160
+ @option("--layout", "-l", help="Image layout", default=None)
161
+ @option("--license", "-lic", help="Image license", default=None)
162
+ @option("--max-results", "-m", help="Maximum number of results", type=int, default=90)
163
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
210
164
  def images(
211
- keywords,
212
- region,
213
- safesearch,
214
- timelimit,
215
- size,
216
- color,
217
- type_image,
218
- layout,
219
- license_image,
220
- max_results,
221
- proxy,
165
+ keywords: str,
166
+ region: str,
167
+ safesearch: str,
168
+ timelimit: str,
169
+ size: str,
170
+ color: str,
171
+ type: str,
172
+ layout: str,
173
+ license: str,
174
+ max_results: int,
175
+ proxy: str = None,
222
176
  ):
223
- """Performs an images search using DuckDuckGo API with a rich UI."""
224
- data = WEBS(proxy=proxy).images(
225
- keywords=keywords,
226
- region=region,
227
- safesearch=safesearch,
228
- timelimit=timelimit,
229
- size=size,
230
- color=color,
231
- type_image=type_image,
232
- layout=layout,
233
- license_image=license_image,
234
- max_results=max_results,
235
- )
236
- _print_data(data)
237
-
238
-
239
- @cli.command()
240
- @click.option("-k", "--keywords", required=True, help="Keywords for videos search.")
241
- @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
242
- @click.option("-s", "--safesearch", default="moderate", type=click.Choice(["on", "moderate", "off"]), help="Safe search level.")
243
- @click.option("-t", "--timelimit", default=None, type=click.Choice(["d", "w", "m"]), help="Time limit (d: day, w: week, m: month).")
244
- @click.option("-res", "--resolution", default=None, type=click.Choice(["high", "standart"]), help="Video resolution (high, standart).")
245
- @click.option("-d", "--duration", default=None, type=click.Choice(["short", "medium", "long"]), help="Video duration (short, medium, long).")
246
- @click.option("-lic", "--license_videos", default=None, type=click.Choice(["creativeCommon", "youtube"]), help="Video license (creativeCommon, youtube).")
247
- @click.option("-m", "--max_results", default=50, help="Maximum number of results to retrieve (default: 50).")
248
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
249
- def videos(keywords, region, safesearch, timelimit, resolution, duration, license_videos, max_results, proxy):
250
- """Performs a videos search using DuckDuckGo API with a rich UI."""
251
- data = WEBS(proxy=proxy).videos(
252
- keywords=keywords,
253
- region=region,
254
- safesearch=safesearch,
255
- timelimit=timelimit,
256
- resolution=resolution,
257
- duration=duration,
258
- license_videos=license_videos,
259
- max_results=max_results,
260
- )
261
- _print_data(data)
262
-
263
-
264
- @cli.command()
265
- @click.option("-k", "--keywords", required=True, help="Keywords for news search.")
266
- @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
267
- @click.option("-s", "--safesearch", default="moderate", type=click.Choice(["on", "moderate", "off"]), help="Safe search level.")
268
- @click.option("-t", "--timelimit", default=None, type=click.Choice(["d", "w", "m", "y"]), help="Time limit (d: day, w: week, m: month, y: year).")
269
- @click.option("-m", "--max_results", default=25, help="Maximum number of results to retrieve (default: 25).")
270
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
271
- def news(keywords, region, safesearch, timelimit, max_results, proxy):
272
- """Performs a news search using DuckDuckGo API with a rich UI."""
273
- data = WEBS(proxy=proxy).news(
274
- keywords=keywords, region=region, safesearch=safesearch, timelimit=timelimit, max_results=max_results
275
- )
276
- _print_data(data)
277
-
278
-
279
- @cli.command()
280
- @click.option("-k", "--keywords", required=True, help="Keywords for maps search.")
281
- @click.option("-p", "--place", default=None, help="Simplified search - if set, the other parameters are not used.")
282
- @click.option("-s", "--street", default=None, help="House number/street.")
283
- @click.option("-c", "--city", default=None, help="City of search.")
284
- @click.option("-county", "--county", default=None, help="County of search.")
285
- @click.option("-state", "--state", default=None, help="State of search.")
286
- @click.option("-country", "--country", default=None, help="Country of search.")
287
- @click.option("-post", "--postalcode", default=None, help="Postal code of search.")
288
- @click.option("-lat", "--latitude", default=None, help="Geographic coordinate (north-south position).")
289
- @click.option("-lon", "--longitude", default=None, help="Geographic coordinate (east-west position); if latitude and longitude are set, the other parameters are not used.")
290
- @click.option("-r", "--radius", default=0, help="Expand the search square by the distance in kilometers.")
291
- @click.option("-m", "--max_results", default=50, help="Number of results (default: 50).")
292
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
177
+ """Perform an images search using DuckDuckGo API."""
178
+ webs = WEBS(proxy=proxy)
179
+ try:
180
+ webs.images(keywords, region, safesearch, timelimit, size, color, type, layout, license, max_results)
181
+ except Exception as e:
182
+ logger.error(f"Error in images search: {e}")
183
+ raise e
184
+
185
+ @app.command()
186
+ @option("--keywords", "-k", help="Search keywords")
187
+ @option("--region", "-r", help="Region for search results", default="wt-wt")
188
+ @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
189
+ @option("--timelimit", "-t", help="Time limit for results", default=None)
190
+ @option("--resolution", "-res", help="Video resolution", default=None)
191
+ @option("--duration", "-d", help="Video duration", default=None)
192
+ @option("--license", "-lic", help="Video license", default=None)
193
+ @option("--max-results", "-m", help="Maximum number of results", type=int, default=50)
194
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
195
+ def videos(
196
+ keywords: str,
197
+ region: str,
198
+ safesearch: str,
199
+ timelimit: str,
200
+ resolution: str,
201
+ duration: str,
202
+ license: str,
203
+ max_results: int,
204
+ proxy: str = None,
205
+ ):
206
+ """Perform a videos search using DuckDuckGo API."""
207
+ webs = WEBS(proxy=proxy)
208
+ try:
209
+ webs.videos(keywords, region, safesearch, timelimit, resolution, duration, license, max_results)
210
+ except Exception as e:
211
+ logger.error(f"Error in videos search: {e}")
212
+ raise e
213
+
214
+ @app.command()
215
+ @option("--keywords", "-k", help="Search keywords")
216
+ @option("--region", "-r", help="Region for search results", default="wt-wt")
217
+ @option("--safesearch", "-s", help="SafeSearch setting", default="moderate")
218
+ @option("--timelimit", "-t", help="Time limit for results", default=None)
219
+ @option("--max-results", "-m", help="Maximum number of results", type=int, default=25)
220
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
221
+ def news(keywords: str, region: str, safesearch: str, timelimit: str, max_results: int, proxy: str = None):
222
+ """Perform a news search using DuckDuckGo API."""
223
+ webs = WEBS(proxy=proxy)
224
+ try:
225
+ webs.news(keywords, region, safesearch, timelimit, max_results)
226
+ except Exception as e:
227
+ logger.error(f"Error in news search: {e}")
228
+ raise e
229
+
230
+ @app.command()
231
+ @option("--keywords", "-k", help="Search keywords")
232
+ @option("--place", "-p", help="Simplified search - if set, the other parameters are not used")
233
+ @option("--street", "-s", help="House number/street")
234
+ @option("--city", "-c", help="City of search")
235
+ @option("--county", "-county", help="County of search")
236
+ @option("--state", "-state", help="State of search")
237
+ @option("--country", "-country", help="Country of search")
238
+ @option("--postalcode", "-post", help="Postal code of search")
239
+ @option("--latitude", "-lat", help="Geographic coordinate (north-south position)")
240
+ @option("--longitude", "-lon", help="Geographic coordinate (east-west position); if latitude and longitude are set, the other parameters are not used")
241
+ @option("--radius", "-r", help="Expand the search square by the distance in kilometers", type=int, default=0)
242
+ @option("--max-results", "-m", help="Number of results", type=int, default=50)
243
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
293
244
  def maps(
294
- keywords,
295
- place,
296
- street,
297
- city,
298
- county,
299
- state,
300
- country,
301
- postalcode,
302
- latitude,
303
- longitude,
304
- radius,
305
- max_results,
306
- proxy,
245
+ keywords: str,
246
+ place: str,
247
+ street: str,
248
+ city: str,
249
+ county: str,
250
+ state: str,
251
+ country: str,
252
+ postalcode: str,
253
+ latitude: str,
254
+ longitude: str,
255
+ radius: int,
256
+ max_results: int,
257
+ proxy: str = None,
307
258
  ):
308
- """Performs a maps search using DuckDuckGo API with a rich UI."""
309
- data = WEBS(proxy=proxy).maps(
310
- keywords=keywords,
311
- place=place,
312
- street=street,
313
- city=city,
314
- county=county,
315
- state=state,
316
- country=country,
317
- postalcode=postalcode,
318
- latitude=latitude,
319
- longitude=longitude,
320
- radius=radius,
321
- max_results=max_results,
322
- )
323
- _print_data(data)
324
-
325
-
326
- @cli.command()
327
- @click.option("-k", "--keywords", required=True, help="Text for translation.")
328
- @click.option("-f", "--from_", help="Language to translate from (defaults automatically).")
329
- @click.option("-t", "--to", default="en", help="Language to translate to (default: 'en').")
330
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
331
- def translate(keywords, from_, to, proxy):
332
- """Performs translation using DuckDuckGo API with a rich UI."""
333
- data = WEBS(proxy=proxy).translate(keywords=keywords, from_=from_, to=to)
334
- _print_data(data)
335
-
336
-
337
- @cli.command()
338
- @click.option("-k", "--keywords", required=True, help="Keywords for query.")
339
- @click.option("-r", "--region", default="wt-wt", help="Region (e.g., wt-wt, us-en, ru-ru) - See https://duckduckgo.com/params for more options.")
340
- @click.option("-p", "--proxy", default=None, help="Proxy to send requests (e.g., socks5://localhost:9150)")
341
- def suggestions(keywords, region, proxy):
342
- """Performs a suggestions search using DuckDuckGo API with a rich UI."""
343
- data = WEBS(proxy=proxy).suggestions(keywords=keywords, region=region)
344
- _print_data(data)
345
-
346
-
347
- @cli.command()
348
- @click.option("--proxy", help="Proxy to use for requests", default=None)
349
- def interactive(proxy):
259
+ """Perform a maps search using DuckDuckGo API."""
260
+ webs = WEBS(proxy=proxy)
261
+ try:
262
+ webs.maps(
263
+ keywords,
264
+ place,
265
+ street,
266
+ city,
267
+ county,
268
+ state,
269
+ country,
270
+ postalcode,
271
+ latitude,
272
+ longitude,
273
+ radius,
274
+ max_results,
275
+ )
276
+ except Exception as e:
277
+ logger.error(f"Error in maps search: {e}")
278
+ raise e
279
+
280
+ @app.command()
281
+ @option("--keywords", "-k", help="Text for translation")
282
+ @option("--from", "-f", help="Language to translate from (defaults automatically)")
283
+ @option("--to", "-t", help="Language to translate to (default: 'en')", default="en")
284
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
285
+ def translate(keywords: str, from_: str, to: str, proxy: str = None):
286
+ """Perform translation using DuckDuckGo API."""
287
+ webs = WEBS(proxy=proxy)
288
+ try:
289
+ webs.translate(keywords, from_, to)
290
+ except Exception as e:
291
+ logger.error(f"Error in translation: {e}")
292
+ raise e
293
+
294
+ @app.command()
295
+ @option("--keywords", "-k", help="Search keywords")
296
+ @option("--region", "-r", help="Region for search results", default="wt-wt")
297
+ @option("--proxy", "-p", help="Proxy URL to use for requests")
298
+ def suggestions(keywords: str, region: str, proxy: str = None):
299
+ """Perform a suggestions search using DuckDuckGo API."""
300
+ webs = WEBS(proxy=proxy)
301
+ try:
302
+ webs.suggestions(keywords, region)
303
+ except Exception as e:
304
+ logger.error(f"Error in suggestions search: {e}")
305
+ raise e
306
+
307
+ @app.command()
308
+ @option("--proxy", help="Proxy URL to use for requests")
309
+ def interactive(proxy: str = None):
350
310
  """Start an interactive search session with AI-powered responses."""
351
- interactive_session()
311
+ webs = WEBS(proxy=proxy)
312
+ try:
313
+ webs.interactive()
314
+ except Exception as e:
315
+ logger.error(f"Error in interactive mode: {e}")
316
+ raise e
352
317
 
318
+ def main():
319
+ """Main entry point for the CLI."""
320
+ try:
321
+ app.run()
322
+ except Exception as e:
323
+ logger.error(f"Error: {e}")
324
+ sys.exit(1)
353
325
 
354
326
  if __name__ == "__main__":
355
- cli(prog_name="WEBS")
327
+ main()