From b8ca6bf7e8757fb1ca55a8da31b94465521182f8 Mon Sep 17 00:00:00 2001 From: RubyTemple <28711906+RubyTemple@users.noreply.github.com> Date: Sat, 15 Mar 2025 22:35:32 +0100 Subject: [PATCH 1/4] Risolto problema con il messaggio di selezione degli episodi per il bot Telegram (discusso su Discord) (#285) * Fixed issues related to TV series for the Telegram bot. * Fixed issues related to TV series for the Telegram bot. --- .../Api/Site/streamingcommunity/series.py | 6 +++++- StreamingCommunity/Util/table.py | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/StreamingCommunity/Api/Site/streamingcommunity/series.py b/StreamingCommunity/Api/Site/streamingcommunity/series.py index 1b38cd3..0f64b86 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/series.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/series.py @@ -185,7 +185,11 @@ def download_series(select_season: MediaItem) -> None: index_season_selected = bot.ask( "select_title_episode", - "Inserisci il numero della stagione (es. 1), * per scaricare tutte le stagioni, (es. 1-2) per un intervallo di stagioni, o (es. 3-*) per scaricare dalla stagione specificata fino alla fine", + "Menu di selezione delle stagioni\n\n" + "- Inserisci il numero della stagione (ad esempio, 1)\n" + "- Inserisci * per scaricare tutte le stagioni\n" + "- Inserisci un intervallo di stagioni (ad esempio, 1-2) per scaricare da una stagione all'altra\n" + "- Inserisci (ad esempio, 3-*) per scaricare dalla stagione specificata fino alla fine della serie", None ) diff --git a/StreamingCommunity/Util/table.py b/StreamingCommunity/Util/table.py index 477fbb5..965fca7 100644 --- a/StreamingCommunity/Util/table.py +++ b/StreamingCommunity/Util/table.py @@ -147,9 +147,14 @@ class TVShowManager: if not force_int_input: prompt_msg = ("\n[cyan]Insert media index [yellow](e.g., 1), [red]* [cyan]to download all media, " "[yellow](e.g., 1-2) [cyan]for a range of media, or [yellow](e.g., 3-*) [cyan]to download from a specific index to the end") + telegram_msg = "Menu di selezione degli episodi: \n\n" \ + "- Inserisci il numero dell'episodio (ad esempio, 1)\n" \ + "- Inserisci * per scaricare tutti gli episodi\n" \ + "- Inserisci un intervallo di episodi (ad esempio, 1-2) per scaricare da un episodio all'altro\n" \ + "- Inserisci (ad esempio, 3-*) per scaricare dall'episodio specificato fino alla fine della serie" if is_telegram: - key = bot.ask("select_title_episode", prompt_msg, None) + key = bot.ask("select_title_episode", telegram_msg, None) else: key = Prompt.ask(prompt_msg) else: @@ -183,9 +188,14 @@ class TVShowManager: if not force_int_input: prompt_msg = ("\n[cyan]Insert media index [yellow](e.g., 1), [red]* [cyan]to download all media, " "[yellow](e.g., 1-2) [cyan]for a range of media, or [yellow](e.g., 3-*) [cyan]to download from a specific index to the end") + telegram_msg = "Menu di selezione degli episodi: \n\n" \ + "- Inserisci il numero dell'episodio (ad esempio, 1)\n" \ + "- Inserisci * per scaricare tutti gli episodi\n" \ + "- Inserisci un intervallo di episodi (ad esempio, 1-2) per scaricare da un episodio all'altro\n" \ + "- Inserisci (ad esempio, 3-*) per scaricare dall'episodio specificato fino alla fine della serie" if is_telegram: - key = bot.ask("select_title_episode", prompt_msg, None) + key = bot.ask("select_title_episode", telegram_msg, None) else: key = Prompt.ask(prompt_msg) else: From 477637ee5c848c5860a85939fbf6393b6cc2d3dd Mon Sep 17 00:00:00 2001 From: Lovi <62809003+Lovi-0@users.noreply.github.com> Date: Sun, 16 Mar 2025 09:48:08 +0100 Subject: [PATCH 2/4] api: From cb01blog to cb01new --- .gitignore | 3 ++- README.md | 3 +++ StreamingCommunity/Api/Site/cb01new/site.py | 9 +++++---- StreamingCommunity/Util/config_json.py | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 4f12a50..0f9804a 100644 --- a/.gitignore +++ b/.gitignore @@ -51,4 +51,5 @@ note.txt cmd.txt bot_config.json scripts.json -active_requests.json \ No newline at end of file +active_requests.json +domains.json \ No newline at end of file diff --git a/README.md b/README.md index 49ffe63..b3749cb 100644 --- a/README.md +++ b/README.md @@ -634,6 +634,9 @@ The API-based domain updates are currently deprecated. To use it anyway, set `us Note: If `use_api` is set to `false` and no `domains.json` file is found, the script will raise an error. +#### 💡 Adding a New Site to the Legacy API +If you want to add a new site to the legacy API, just message me on the Discord server, and I'll add it! + # COMMAND - Download a specific season by entering its number. diff --git a/StreamingCommunity/Api/Site/cb01new/site.py b/StreamingCommunity/Api/Site/cb01new/site.py index ea0c328..52aca12 100644 --- a/StreamingCommunity/Api/Site/cb01new/site.py +++ b/StreamingCommunity/Api/Site/cb01new/site.py @@ -40,7 +40,7 @@ def title_search(word_to_search: str) -> int: media_search_manager.clear() table_show_manager.clear() - search_url = f"{site_constant.FULL_URL}/?story={word_to_search}&do=search&subaction=search" + search_url = f"{site_constant.FULL_URL}/?s={word_to_search}" console.print(f"[cyan]Search url: [yellow]{search_url}") try: @@ -54,10 +54,11 @@ def title_search(word_to_search: str) -> int: # Create soup and find table soup = BeautifulSoup(response.text, "html.parser") - for div in soup.find_all("div", class_ = "short-main"): + for card in soup.find_all("div", class_=["card", "mp-post", "horizontal"]): try: - url = div.find("a").get("href") - title = div.find("a").get_text(strip=True) + title_tag = card.find("h3", class_="card-title").find("a") + url = title_tag.get("href") + title = title_tag.get_text(strip=True) title_info = { 'name': title, diff --git a/StreamingCommunity/Util/config_json.py b/StreamingCommunity/Util/config_json.py index b2bc7f5..cde8cc9 100644 --- a/StreamingCommunity/Util/config_json.py +++ b/StreamingCommunity/Util/config_json.py @@ -196,6 +196,7 @@ class ConfigManager: except Exception as e: logging.error(f"Error reading configuration file: {e}") console.print(f"[bold red]Failed to read configuration:[/bold red] {str(e)}") + sys.exit(0) def download_requirements(self, url: str, filename: str) -> None: """ From ab094d0b1db21e74b8af4b5b995779dfd88ce3db Mon Sep 17 00:00:00 2001 From: Lovi <62809003+Lovi-0@users.noreply.github.com> Date: Sun, 16 Mar 2025 14:27:23 +0100 Subject: [PATCH 3/4] mp4: Fix error 'set_alpn_protocols' --- StreamingCommunity/Lib/Downloader/MP4/downloader.py | 13 +++++++------ StreamingCommunity/Util/config_json.py | 9 +-------- Test/Download/MP4.py | 2 ++ config.json | 3 +-- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/StreamingCommunity/Lib/Downloader/MP4/downloader.py b/StreamingCommunity/Lib/Downloader/MP4/downloader.py index 010fff7..f69c033 100644 --- a/StreamingCommunity/Lib/Downloader/MP4/downloader.py +++ b/StreamingCommunity/Lib/Downloader/MP4/downloader.py @@ -31,7 +31,6 @@ from ...FFmpeg import print_duration_table # Config REQUEST_VERIFY = config_manager.get_bool('REQUESTS', 'verify') -REQUEST_HTTP2 = config_manager.get_bool('REQUESTS', 'http2') GET_ONLY_LINK = config_manager.get_bool('M3U8_PARSER', 'get_only_link') REQUEST_TIMEOUT = config_manager.get_float('REQUESTS', 'timeout') TELEGRAM_BOT = config_manager.get_bool('DEFAULT', 'telegram_bot') @@ -111,11 +110,12 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No interrupt_handler = InterruptHandler() original_handler = signal.signal(signal.SIGINT, partial(signal_handler, interrupt_handler=interrupt_handler, original_handler=signal.getsignal(signal.SIGINT))) + # Ensure the output directory exists + os.makedirs(os.path.dirname(path), exist_ok=True) + try: - transport = httpx.HTTPTransport(verify=REQUEST_VERIFY, http2=REQUEST_HTTP2) - - with httpx.Client(transport=transport, timeout=httpx.Timeout(60)) as client: - with client.stream("GET", url, headers=headers, timeout=REQUEST_TIMEOUT) as response: + with httpx.Client() as client: + with client.stream("GET", url, headers=headers) as response: response.raise_for_status() total = int(response.headers.get('content-length', 0)) @@ -123,6 +123,7 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No console.print("[bold red]No video stream found.[/bold red]") return None, False + # Create a fancy progress bar progress_bar = tqdm( total=total, ascii='░▒█', @@ -135,7 +136,7 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No unit_scale=True, desc='Downloading', mininterval=0.05, - file=sys.stdout # Using file=sys.stdout to force in-place updates because sys.stderr may not support carriage returns in this environment. + file=sys.stdout # Using file=sys.stdout to force in-place updates because sys.stderr may not support carriage returns in this environment. ) downloaded = 0 diff --git a/StreamingCommunity/Util/config_json.py b/StreamingCommunity/Util/config_json.py index cde8cc9..e770fd5 100644 --- a/StreamingCommunity/Util/config_json.py +++ b/StreamingCommunity/Util/config_json.py @@ -256,14 +256,7 @@ class ConfigManager: sites_info = [] for site, info in examples: sites_info.append(f"[cyan]{site}[/cyan]: {info.get('full_url', 'N/A')}") - - console.print("[bold cyan]Sample sites:[/bold cyan]") - for info in sites_info: - console.print(f" {info}") - - if site_count > 3: - console.print(f" ... and {site_count - 3} more") - + else: console.print("[bold yellow]API returned empty data set[/bold yellow]") else: diff --git a/Test/Download/MP4.py b/Test/Download/MP4.py index a48e5ca..f2bc65c 100644 --- a/Test/Download/MP4.py +++ b/Test/Download/MP4.py @@ -10,6 +10,8 @@ sys.path.append(src_path) # Import from StreamingCommunity.Util.message import start_message +from StreamingCommunity.Util.os import os_summary +os_summary.get_system_summary() from StreamingCommunity.Util.logger import Logger from StreamingCommunity.Lib.Downloader import MP4_downloader diff --git a/config.json b/config.json index e361fa1..475d25b 100644 --- a/config.json +++ b/config.json @@ -25,8 +25,7 @@ "REQUESTS": { "verify": false, "timeout": 20, - "max_retry": 8, - "http2": true + "max_retry": 8 }, "M3U8_DOWNLOAD": { "tqdm_delay": 0.01, From 870714ca7e88d26be1fc5530cf5ba90c69f1c296 Mon Sep 17 00:00:00 2001 From: Lovi <62809003+Lovi-0@users.noreply.github.com> Date: Sun, 16 Mar 2025 15:42:50 +0100 Subject: [PATCH 4/4] api: Add warning altadefinizione --- StreamingCommunity/Api/Site/altadefinizione/film.py | 1 + 1 file changed, 1 insertion(+) diff --git a/StreamingCommunity/Api/Site/altadefinizione/film.py b/StreamingCommunity/Api/Site/altadefinizione/film.py index 42a2e5a..296c0d1 100644 --- a/StreamingCommunity/Api/Site/altadefinizione/film.py +++ b/StreamingCommunity/Api/Site/altadefinizione/film.py @@ -67,6 +67,7 @@ def download_film(select_title: MediaItem) -> str: except Exception as e: console.print(f"[red]Error fetching mostraguarda link: {e}") + console.print("[yellow]Missing access credentials. This part of the code is still under development.") return None # Create supervio URL