|
9 | 9 | import threading |
10 | 10 | import asyncio |
11 | 11 | import subprocess |
12 | | -from urllib.parse import urlparse |
13 | 12 | from typing import Callable, Tuple |
14 | 13 |
|
15 | 14 |
|
|
23 | 22 | from StreamingCommunity.Api.Template.loader import load_search_functions |
24 | 23 | from StreamingCommunity.Util.message import start_message |
25 | 24 | from StreamingCommunity.Util.config_json import config_manager |
26 | | -from StreamingCommunity.Util.os import internet_manager, os_manager |
| 25 | +from StreamingCommunity.Util.os import os_manager |
27 | 26 | from StreamingCommunity.Util.logger import Logger |
28 | | -from StreamingCommunity.Lib.TMBD import tmdb |
29 | 27 | from StreamingCommunity.Upload.update import update as git_update |
30 | 28 | from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance, TelegramSession |
31 | 29 |
|
32 | 30 |
|
33 | 31 | # Config |
34 | | -SHOW_TRENDING = config_manager.get_bool('DEFAULT', 'show_trending') |
35 | 32 | TELEGRAM_BOT = config_manager.get_bool('DEFAULT', 'telegram_bot') |
36 | 33 | BYPASS_DNS = config_manager.get_bool('DEFAULT', 'bypass_dns') |
37 | 34 | COLOR_MAP = { |
@@ -70,12 +67,6 @@ def initialize(): |
70 | 67 | console.log("[red]Install python version > 3.7.16") |
71 | 68 | sys.exit(0) |
72 | 69 |
|
73 | | - # Show trending content |
74 | | - if SHOW_TRENDING: |
75 | | - print() |
76 | | - tmdb.display_trending_films() |
77 | | - tmdb.display_trending_tv_shows() |
78 | | - |
79 | 70 | # Attempt GitHub update |
80 | 71 | try: |
81 | 72 | git_update() |
@@ -279,57 +270,8 @@ def force_exit(): |
279 | 270 | os._exit(0) |
280 | 271 |
|
281 | 272 |
|
282 | | -def check_env_file(): |
283 | | - required_keys = ['TMDB_API_KEY'] |
284 | | - |
285 | | - env_path = os.path.join(os.getcwd(), '.env') |
286 | | - if not os.path.isfile(env_path): |
287 | | - console.print("\n[red]Please create a .env file in the current directory with the necessary configurations.") |
288 | | - |
289 | | - for key in required_keys: |
290 | | - console.print(f"\n[yellow]To get your {key}:[/yellow]") |
291 | | - console.print(f"[cyan]1. Go to: https://www.themoviedb.org/settings/api/request") |
292 | | - console.print(f"[cyan]2. Register or log in to your account") |
293 | | - console.print(f"[cyan]3. Create an API request and copy your API key\n[/cyan]") |
294 | | - |
295 | | - while True: |
296 | | - value = console.input(f"[cyan]Please enter the value for [bold]{key}[/bold]: [/cyan]").strip() |
297 | | - |
298 | | - if value: |
299 | | - with open(env_path, 'a') as f: |
300 | | - f.write(f"{key}={value}\n") |
301 | | - console.print(f"[green]{key} added to .env file.[/green]") |
302 | | - break |
303 | | - else: |
304 | | - console.print(f"[red]Error: {key} cannot be empty. Please try again.[/red]") |
305 | | - |
306 | | - console.print("\n[green].env file created successfully. Please restart the application.[/green]") |
307 | | - |
308 | | - |
309 | | -def check_dns(): |
310 | | - """Check DNS configuration and exit if required.""" |
311 | | - if BYPASS_DNS: |
312 | | - return |
313 | | - |
314 | | - hostname_list = [ |
315 | | - urlparse(site_info.get('full_url')).hostname |
316 | | - for site_info in config_manager.configSite.values() |
317 | | - if urlparse(site_info.get('full_url')).hostname |
318 | | - ] |
319 | | - |
320 | | - if not internet_manager.check_dns_resolve(hostname_list): |
321 | | - console.print("[red]\nERROR: DNS configuration is required!") |
322 | | - console.print("[red]The program cannot function correctly without proper DNS settings.") |
323 | | - console.print("\n[yellow]Please configure one of these DNS servers:") |
324 | | - console.print("[red]• Cloudflare (1.1.1.1) 'https://developers.cloudflare.com/1.1.1.1/setup/windows/'") |
325 | | - console.print("[red]• Quad9 (9.9.9.9) 'https://docs.quad9.net/Setup_Guides/Windows/Windows_10/'") |
326 | | - console.print("\n[yellow]-> The program will not work until you configure your DNS settings.") |
327 | | - sys.exit(0) |
328 | | - |
329 | | - |
330 | 273 | def setup_argument_parser(search_functions): |
331 | 274 | """Setup and return configured argument parser.""" |
332 | | - # Build help text |
333 | 275 | module_info = {} |
334 | 276 | for alias, (_func, _use_for) in search_functions.items(): |
335 | 277 | module_name = alias.split("_")[0].lower() |
@@ -499,12 +441,10 @@ def main(script_id=0): |
499 | 441 | get_bot_instance().send_message(f"Avviato script {script_id}", None) |
500 | 442 |
|
501 | 443 | Logger() |
502 | | - check_env_file() |
503 | 444 | execute_hooks('pre_run') |
504 | 445 | initialize() |
505 | 446 |
|
506 | 447 | try: |
507 | | - check_dns() |
508 | 448 | search_functions = load_search_functions() |
509 | 449 |
|
510 | 450 | parser = setup_argument_parser(search_functions) |
|
0 commit comments