From fe0cb97a9dfcdbed836222b90d210d29dbae0fcf Mon Sep 17 00:00:00 2001 From: Ghost <62809003+Ghost6446@users.noreply.github.com> Date: Fri, 1 Mar 2024 16:15:51 +0100 Subject: [PATCH] fix auto domain --- Src/Api/page.py | 31 +++++++++++++++---------------- Src/Lib/FFmpeg/file_list.txt | 0 Src/Upload/update.py | 2 +- Src/Util/console.py | 12 ------------ Src/Util/os.py | 4 +--- data.json | 1 - 6 files changed, 17 insertions(+), 33 deletions(-) delete mode 100644 Src/Lib/FFmpeg/file_list.txt delete mode 100644 data.json diff --git a/Src/Api/page.py b/Src/Api/page.py index 07fe648..c060beb 100644 --- a/Src/Api/page.py +++ b/Src/Api/page.py @@ -11,28 +11,27 @@ from bs4 import BeautifulSoup def domain_version(): domain_req = requests.get("https://api.telegra.ph/getPage/Link-Aggiornato-StreamingCommunity-01-17") - domain = domain_req.json()['result']['description'] + domain = domain_req.json()['result']['description'].split(".")[1] console.print("[green]Get rules ...") - req_repo = None - while True: - console.print(f"[blue]Test domain [white]=> [red]{domain}") - site_url = domain - try: - site_request = requests.get(site_url, headers={'user-agent': get_headers()}) - soup = BeautifulSoup(site_request.text, "lxml") - version = json.loads(soup.find("div", {"id": "app"}).get("data-page"))['version'] - console.print(f"[blue]Rules [white]=> [red].{domain}") - return domain, version + console.print(f"[blue]Test domain [white]=> [red]{domain}") + site_url = f"https://streamingcommunity.{domain}" - except Exception as e: - console.log("[red]Cant get version, problem with domain. Try again.") - domain = None - continue + try: + site_request = requests.get(site_url, headers={'user-agent': get_headers()}) + soup = BeautifulSoup(site_request.text, "lxml") + version = json.loads(soup.find("div", {"id": "app"}).get("data-page"))['version'] + console.print(f"[blue]Rules [white]=> [red].{domain}") + + return domain, version + + except Exception as e: + console.log("[red]Cant get version, problem with domain. Try again.") + sys.exit(0) def search(title_search, domain): - req = requests.get(f"{domain}/api/search?q={title_search}", headers={'user-agent': get_headers()}) + req = requests.get(f"https://streamingcommunity.{domain}/api/search?q={title_search}", headers={'user-agent': get_headers()}) if req.ok: return [{'name': title['name'], 'type': title['type'], 'id': title['id'], 'slug': title['slug']} for title in diff --git a/Src/Lib/FFmpeg/file_list.txt b/Src/Lib/FFmpeg/file_list.txt deleted file mode 100644 index e69de29..0000000 diff --git a/Src/Upload/update.py b/Src/Upload/update.py index 4847a6f..d256b69 100644 --- a/Src/Upload/update.py +++ b/Src/Upload/update.py @@ -44,5 +44,5 @@ def main_update(): print("\n") console.print(f"[red]{repo_name} was downloaded [yellow]{down_count} [red]times, but only [yellow]{percentual_stars}% [red]of You(!!) have starred it. \n\ [cyan]Help the repository grow today, by leaving a [yellow]star [cyan]and [yellow]sharing [cyan]it to others online!") - time.sleep(2.5) + time.sleep(3) print("\n") \ No newline at end of file diff --git a/Src/Util/console.py b/Src/Util/console.py index 907713c..474364d 100644 --- a/Src/Util/console.py +++ b/Src/Util/console.py @@ -8,15 +8,3 @@ import logging # Variable msg = Prompt() console = Console() -SAVE_DEBUG = False - -class ConfigurazioneLogger: - def __init__(self, nome_file_log='debug.log'): - self.nome_file_log = nome_file_log - self.configura_logger() - - def configura_logger(self): - if SAVE_DEBUG: - logging.basicConfig(filename=self.nome_file_log, filemode='w', level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') - -config_logger = ConfigurazioneLogger() \ No newline at end of file diff --git a/Src/Util/os.py b/Src/Util/os.py index 11774eb..ddf87c3 100644 --- a/Src/Util/os.py +++ b/Src/Util/os.py @@ -20,6 +20,4 @@ def remove_file(file_path): except OSError as e: print(f"Error removing file '{file_path}': {e}") else: - print(f"File '{file_path}' does not exist.") - - time.sleep(1) \ No newline at end of file + print(f"File '{file_path}' does not exist.") \ No newline at end of file diff --git a/data.json b/data.json deleted file mode 100644 index 6938769..0000000 --- a/data.json +++ /dev/null @@ -1 +0,0 @@ -{"domain": "report"} \ No newline at end of file