From 45f39b36c37fa8c17108c6399c9c5f9a167e4b92 Mon Sep 17 00:00:00 2001 From: Dark1291 Date: Wed, 26 Feb 2025 12:20:53 +0100 Subject: [PATCH] Remove "console.py" (#277) * [CORE] Remove some key from json * [UTIL] Remove "console.py" * [UTIL] Remove set_slice_end * [CORE] Ffmpeg remove static variable * [CORE] Rename _jsonConfig to config_json * [UTIL] Remove "call_stack.py" * [UTIL] Remove variable "USE_LARGE_BAR" --- StreamingCommunity/Api/Player/ddl.py | 2 +- StreamingCommunity/Api/Player/maxstream.py | 2 +- StreamingCommunity/Api/Player/supervideo.py | 2 +- StreamingCommunity/Api/Player/vixcloud.py | 5 +- .../Api/Site/1337xx/__init__.py | 9 +++- StreamingCommunity/Api/Site/1337xx/site.py | 5 +- StreamingCommunity/Api/Site/1337xx/title.py | 5 +- .../Api/Site/animeunity/__init__.py | 9 +++- .../Api/Site/animeunity/film_serie.py | 8 ++- .../Api/Site/animeunity/site.py | 5 +- .../Api/Site/animeunity/util/ScrapeSerie.py | 2 +- .../Api/Site/cb01new/__init__.py | 9 +++- StreamingCommunity/Api/Site/cb01new/film.py | 8 ++- StreamingCommunity/Api/Site/cb01new/site.py | 6 ++- .../Api/Site/ddlstreamitaly/__init__.py | 11 ++++- .../Api/Site/ddlstreamitaly/series.py | 8 ++- .../Api/Site/ddlstreamitaly/site.py | 5 +- .../Site/ddlstreamitaly/util/ScrapeSerie.py | 2 +- .../Api/Site/guardaserie/__init__.py | 11 ++++- .../Api/Site/guardaserie/series.py | 10 +++- .../Api/Site/guardaserie/site.py | 8 +-- .../Api/Site/guardaserie/util/ScrapeSerie.py | 2 +- .../Api/Site/mostraguarda/__init__.py | 8 ++- .../Api/Site/mostraguarda/film.py | 10 ++-- .../Api/Site/streamingcommunity/__init__.py | 9 +++- .../Api/Site/streamingcommunity/film.py | 9 +++- .../Api/Site/streamingcommunity/series.py | 11 ++++- .../Api/Site/streamingcommunity/site.py | 6 +-- .../streamingcommunity/util/ScrapeSerie.py | 2 +- .../Api/Template/Util/get_domain.py | 5 +- .../Api/Template/Util/manage_ep.py | 13 +++-- .../Api/Template/config_loader.py | 2 +- StreamingCommunity/Api/Template/site.py | 9 ++-- .../Lib/Downloader/HLS/downloader.py | 20 ++++---- .../Lib/Downloader/HLS/segments.py | 11 +++-- .../Lib/Downloader/MP4/downloader.py | 10 +++- .../Lib/Downloader/TOR/downloader.py | 16 +++--- StreamingCommunity/Lib/FFmpeg/capture.py | 8 ++- StreamingCommunity/Lib/FFmpeg/command.py | 29 +++++------ StreamingCommunity/Lib/FFmpeg/util.py | 16 +++--- StreamingCommunity/Lib/M3U8/decryptor.py | 5 +- StreamingCommunity/Lib/M3U8/estimator.py | 17 +++---- StreamingCommunity/Lib/TMBD/tmdb.py | 13 ++--- StreamingCommunity/Upload/update.py | 5 +- StreamingCommunity/Util/call_stack.py | 42 ---------------- .../Util/{_jsonConfig.py => config_json.py} | 15 +++++- StreamingCommunity/Util/console.py | 12 ----- StreamingCommunity/Util/logger.py | 2 +- StreamingCommunity/Util/message.py | 9 +++- StreamingCommunity/Util/os.py | 49 ++++++++++++++----- StreamingCommunity/Util/table.py | 20 ++------ StreamingCommunity/run.py | 15 ++++-- test_run.py | 2 +- update.py | 2 +- 54 files changed, 317 insertions(+), 219 deletions(-) delete mode 100644 StreamingCommunity/Util/call_stack.py rename StreamingCommunity/Util/{_jsonConfig.py => config_json.py} (98%) delete mode 100644 StreamingCommunity/Util/console.py diff --git a/StreamingCommunity/Api/Player/ddl.py b/StreamingCommunity/Api/Player/ddl.py index 2ee4aa8..62d4efa 100644 --- a/StreamingCommunity/Api/Player/ddl.py +++ b/StreamingCommunity/Api/Player/ddl.py @@ -9,7 +9,7 @@ from bs4 import BeautifulSoup # Internal utilities -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.headers import get_userAgent diff --git a/StreamingCommunity/Api/Player/maxstream.py b/StreamingCommunity/Api/Player/maxstream.py index 6f916f0..c8785b1 100644 --- a/StreamingCommunity/Api/Player/maxstream.py +++ b/StreamingCommunity/Api/Player/maxstream.py @@ -11,7 +11,7 @@ from bs4 import BeautifulSoup # Internal utilities -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.headers import get_userAgent diff --git a/StreamingCommunity/Api/Player/supervideo.py b/StreamingCommunity/Api/Player/supervideo.py index 2661aff..942fe2e 100644 --- a/StreamingCommunity/Api/Player/supervideo.py +++ b/StreamingCommunity/Api/Player/supervideo.py @@ -11,7 +11,7 @@ from bs4 import BeautifulSoup # Internal utilities -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.headers import get_userAgent diff --git a/StreamingCommunity/Api/Player/vixcloud.py b/StreamingCommunity/Api/Player/vixcloud.py index 91c915f..7f614fc 100644 --- a/StreamingCommunity/Api/Player/vixcloud.py +++ b/StreamingCommunity/Api/Player/vixcloud.py @@ -8,18 +8,19 @@ from urllib.parse import urlparse, parse_qs, urlencode, urlunparse # External libraries import httpx from bs4 import BeautifulSoup +from rich.console import Console # Internal utilities from StreamingCommunity.Util.headers import get_userAgent -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from .Helper.Vixcloud.util import WindowVideo, WindowParameter, StreamsCollection from .Helper.Vixcloud.js_parser import JavaScriptParser # Variable MAX_TIMEOUT = config_manager.get_int("REQUESTS", "timeout") +console = Console() class VideoSource: diff --git a/StreamingCommunity/Api/Site/1337xx/__init__.py b/StreamingCommunity/Api/Site/1337xx/__init__.py index e16f109..fef9569 100644 --- a/StreamingCommunity/Api/Site/1337xx/__init__.py +++ b/StreamingCommunity/Api/Site/1337xx/__init__.py @@ -3,8 +3,12 @@ from urllib.parse import quote_plus +# External library +from rich.console import Console +from rich.prompt import Prompt + + # Internal utilities -from StreamingCommunity.Util.console import console, msg from StreamingCommunity.Api.Template import get_select_title @@ -21,6 +25,9 @@ _deprecate = False _priority = 2 _engineDownload = "tor" +console = Console() +msg = Prompt() + def search(string_to_search: str = None, get_onylDatabase: bool = False): """ diff --git a/StreamingCommunity/Api/Site/1337xx/site.py b/StreamingCommunity/Api/Site/1337xx/site.py index fae2d33..06c8d22 100644 --- a/StreamingCommunity/Api/Site/1337xx/site.py +++ b/StreamingCommunity/Api/Site/1337xx/site.py @@ -5,11 +5,11 @@ import sys # External libraries import httpx from bs4 import BeautifulSoup +from rich.console import Console # Internal utilities -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.headers import get_userAgent from StreamingCommunity.Util.table import TVShowManager @@ -21,6 +21,7 @@ from StreamingCommunity.Api.Template.Class.SearchType import MediaManager # Variable +console = Console() media_search_manager = MediaManager() table_show_manager = TVShowManager() max_timeout = config_manager.get_int("REQUESTS", "timeout") diff --git a/StreamingCommunity/Api/Site/1337xx/title.py b/StreamingCommunity/Api/Site/1337xx/title.py index 1679622..ffd72f7 100644 --- a/StreamingCommunity/Api/Site/1337xx/title.py +++ b/StreamingCommunity/Api/Site/1337xx/title.py @@ -6,10 +6,10 @@ import os # External libraries import httpx from bs4 import BeautifulSoup +from rich.console import Console # Internal utilities -from StreamingCommunity.Util.console import console from StreamingCommunity.Util.os import os_manager from StreamingCommunity.Util.message import start_message from StreamingCommunity.Util.headers import get_userAgent @@ -21,6 +21,9 @@ from StreamingCommunity.Api.Template.config_loader import site_constant from StreamingCommunity.Api.Template.Class.SearchType import MediaItem +# Variable +console = Console() + def download_title(select_title: MediaItem): """ diff --git a/StreamingCommunity/Api/Site/animeunity/__init__.py b/StreamingCommunity/Api/Site/animeunity/__init__.py index bc2113b..172bf2b 100644 --- a/StreamingCommunity/Api/Site/animeunity/__init__.py +++ b/StreamingCommunity/Api/Site/animeunity/__init__.py @@ -4,8 +4,12 @@ import sys import subprocess +# External library +from rich.console import Console +from rich.prompt import Prompt + + # Internal utilities -from StreamingCommunity.Util.console import console, msg from StreamingCommunity.Api.Template import get_select_title from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance @@ -23,6 +27,9 @@ _deprecate = False _priority = 2 _engineDownload = "mp4" +msg = Prompt() +console = Console() + def search(string_to_search: str = None, get_onylDatabase: bool = False): diff --git a/StreamingCommunity/Api/Site/animeunity/film_serie.py b/StreamingCommunity/Api/Site/animeunity/film_serie.py index 3ebfeb0..a85dbec 100644 --- a/StreamingCommunity/Api/Site/animeunity/film_serie.py +++ b/StreamingCommunity/Api/Site/animeunity/film_serie.py @@ -5,8 +5,12 @@ import logging from typing import Tuple +# External library +from rich.console import Console +from rich.prompt import Prompt + + # Internal utilities -from StreamingCommunity.Util.console import console, msg from StreamingCommunity.Util.os import os_manager from StreamingCommunity.Util.message import start_message from StreamingCommunity.Lib.Downloader import MP4_downloader @@ -25,6 +29,8 @@ from StreamingCommunity.Api.Player.vixcloud import VideoSourceAnime # Variable +console = Console() +msg = Prompt() KILL_HANDLER = bool(False) diff --git a/StreamingCommunity/Api/Site/animeunity/site.py b/StreamingCommunity/Api/Site/animeunity/site.py index 9e071c9..564e7b8 100644 --- a/StreamingCommunity/Api/Site/animeunity/site.py +++ b/StreamingCommunity/Api/Site/animeunity/site.py @@ -7,11 +7,11 @@ import logging # External libraries import httpx from bs4 import BeautifulSoup +from rich.console import Console # Internal utilities -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.table import TVShowManager from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance @@ -23,6 +23,7 @@ from StreamingCommunity.Api.Template.Class.SearchType import MediaManager # Variable +console = Console() media_search_manager = MediaManager() table_show_manager = TVShowManager() max_timeout = config_manager.get_int("REQUESTS", "timeout") diff --git a/StreamingCommunity/Api/Site/animeunity/util/ScrapeSerie.py b/StreamingCommunity/Api/Site/animeunity/util/ScrapeSerie.py index bf2221e..26187a5 100644 --- a/StreamingCommunity/Api/Site/animeunity/util/ScrapeSerie.py +++ b/StreamingCommunity/Api/Site/animeunity/util/ScrapeSerie.py @@ -9,7 +9,7 @@ import httpx # Internal utilities from StreamingCommunity.Util.headers import get_userAgent -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Api.Player.Helper.Vixcloud.util import EpisodeManager, Episode diff --git a/StreamingCommunity/Api/Site/cb01new/__init__.py b/StreamingCommunity/Api/Site/cb01new/__init__.py index fdbe5ed..a8e2fb9 100644 --- a/StreamingCommunity/Api/Site/cb01new/__init__.py +++ b/StreamingCommunity/Api/Site/cb01new/__init__.py @@ -3,8 +3,12 @@ from urllib.parse import quote_plus +# External library +from rich.console import Console +from rich.prompt import Prompt + + # Internal utilities -from StreamingCommunity.Util.console import console, msg from StreamingCommunity.Api.Template import get_select_title @@ -21,6 +25,9 @@ _deprecate = False _priority = 2 _engineDownload = "mp4" +msg = Prompt() +console = Console() + def search(string_to_search: str = None, get_onylDatabase: bool = False): """ diff --git a/StreamingCommunity/Api/Site/cb01new/film.py b/StreamingCommunity/Api/Site/cb01new/film.py index 949c3bb..a197529 100644 --- a/StreamingCommunity/Api/Site/cb01new/film.py +++ b/StreamingCommunity/Api/Site/cb01new/film.py @@ -3,8 +3,11 @@ import os +# External library +from rich.console import Console + + # Internal utilities -from StreamingCommunity.Util.console import console from StreamingCommunity.Util.os import os_manager from StreamingCommunity.Util.message import start_message from StreamingCommunity.Lib.Downloader import HLS_Downloader @@ -19,6 +22,9 @@ from StreamingCommunity.Api.Template.Class.SearchType import MediaItem from StreamingCommunity.Api.Player.maxstream import VideoSource +# Variable +console = Console() + def download_film(select_title: MediaItem) -> str: """ diff --git a/StreamingCommunity/Api/Site/cb01new/site.py b/StreamingCommunity/Api/Site/cb01new/site.py index cc16ac6..fa5226e 100644 --- a/StreamingCommunity/Api/Site/cb01new/site.py +++ b/StreamingCommunity/Api/Site/cb01new/site.py @@ -2,14 +2,15 @@ import sys + # External libraries import httpx from bs4 import BeautifulSoup +from rich.console import Console # Internal utilities -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.headers import get_userAgent from StreamingCommunity.Util.table import TVShowManager @@ -21,6 +22,7 @@ from StreamingCommunity.Api.Template.Class.SearchType import MediaManager # Variable +console = Console() media_search_manager = MediaManager() table_show_manager = TVShowManager() max_timeout = config_manager.get_int("REQUESTS", "timeout") diff --git a/StreamingCommunity/Api/Site/ddlstreamitaly/__init__.py b/StreamingCommunity/Api/Site/ddlstreamitaly/__init__.py index 69bb417..3bb93de 100644 --- a/StreamingCommunity/Api/Site/ddlstreamitaly/__init__.py +++ b/StreamingCommunity/Api/Site/ddlstreamitaly/__init__.py @@ -4,13 +4,17 @@ import logging from urllib.parse import quote_plus +# External library +from rich.console import Console +from rich.prompt import Prompt + + # Internal utilities -from StreamingCommunity.Util.console import console, msg from StreamingCommunity.Api.Template import get_select_title +from StreamingCommunity.Api.Template.config_loader import site_constant # Logic class -from StreamingCommunity.Api.Template.config_loader import site_constant from .site import title_search, media_search_manager, table_show_manager from .series import download_thread @@ -22,6 +26,9 @@ _deprecate = False _priority = 2 _engineDownload = "mp4" +msg = Prompt() +console = Console() + def search(string_to_search: str = None, get_onylDatabase: bool = False): """ diff --git a/StreamingCommunity/Api/Site/ddlstreamitaly/series.py b/StreamingCommunity/Api/Site/ddlstreamitaly/series.py index daf3363..e56a416 100644 --- a/StreamingCommunity/Api/Site/ddlstreamitaly/series.py +++ b/StreamingCommunity/Api/Site/ddlstreamitaly/series.py @@ -5,8 +5,11 @@ from urllib.parse import urlparse from typing import Tuple +# External library +from rich.console import Console + + # Internal utilities -from StreamingCommunity.Util.console import console from StreamingCommunity.Util.message import start_message from StreamingCommunity.Util.os import os_manager from StreamingCommunity.Lib.Downloader import MP4_downloader @@ -28,6 +31,9 @@ from .util.ScrapeSerie import GetSerieInfo from StreamingCommunity.Api.Player.ddl import VideoSource +# Variable +console = Console() + def download_video(index_episode_selected: int, scape_info_serie: GetSerieInfo, video_source: VideoSource) -> Tuple[str,bool]: """ diff --git a/StreamingCommunity/Api/Site/ddlstreamitaly/site.py b/StreamingCommunity/Api/Site/ddlstreamitaly/site.py index d3a321a..ee46a19 100644 --- a/StreamingCommunity/Api/Site/ddlstreamitaly/site.py +++ b/StreamingCommunity/Api/Site/ddlstreamitaly/site.py @@ -7,11 +7,11 @@ import logging # External libraries import httpx from bs4 import BeautifulSoup +from rich.console import Console # Internal utilities -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.headers import get_userAgent from StreamingCommunity.Util.table import TVShowManager @@ -23,6 +23,7 @@ from StreamingCommunity.Api.Template.Class.SearchType import MediaManager # Variable +console = Console() media_search_manager = MediaManager() table_show_manager = TVShowManager() max_timeout = config_manager.get_int("REQUESTS", "timeout") diff --git a/StreamingCommunity/Api/Site/ddlstreamitaly/util/ScrapeSerie.py b/StreamingCommunity/Api/Site/ddlstreamitaly/util/ScrapeSerie.py index 26af8f2..ed02262 100644 --- a/StreamingCommunity/Api/Site/ddlstreamitaly/util/ScrapeSerie.py +++ b/StreamingCommunity/Api/Site/ddlstreamitaly/util/ScrapeSerie.py @@ -11,7 +11,7 @@ from bs4 import BeautifulSoup # Internal utilities -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.headers import get_userAgent diff --git a/StreamingCommunity/Api/Site/guardaserie/__init__.py b/StreamingCommunity/Api/Site/guardaserie/__init__.py index 4bc4520..89d3400 100644 --- a/StreamingCommunity/Api/Site/guardaserie/__init__.py +++ b/StreamingCommunity/Api/Site/guardaserie/__init__.py @@ -3,13 +3,17 @@ from urllib.parse import quote_plus +# External library +from rich.console import Console +from rich.prompt import Prompt + + # Internal utilities -from StreamingCommunity.Util.console import console, msg from StreamingCommunity.Api.Template import get_select_title +from StreamingCommunity.Api.Template.config_loader import site_constant # Logic class -from StreamingCommunity.Api.Template.config_loader import site_constant from .site import title_search, media_search_manager, table_show_manager from .series import download_series @@ -21,6 +25,9 @@ _deprecate = False _priority = 2 _engineDownload = "hls" +msg = Prompt() +console = Console() + def search(string_to_search: str = None, get_onylDatabase: bool = False): """ diff --git a/StreamingCommunity/Api/Site/guardaserie/series.py b/StreamingCommunity/Api/Site/guardaserie/series.py index 9a63d8f..aaf38e9 100644 --- a/StreamingCommunity/Api/Site/guardaserie/series.py +++ b/StreamingCommunity/Api/Site/guardaserie/series.py @@ -4,8 +4,12 @@ import os from typing import Tuple +# External library +from rich.console import Console +from rich.prompt import Prompt + + # Internal utilities -from StreamingCommunity.Util.console import console, msg from StreamingCommunity.Util.message import start_message from StreamingCommunity.Lib.Downloader import HLS_Downloader @@ -28,6 +32,10 @@ from .util.ScrapeSerie import GetSerieInfo from StreamingCommunity.Api.Player.supervideo import VideoSource +# Variable +msg = Prompt() +console = Console() + def download_video(index_season_selected: int, index_episode_selected: int, scape_info_serie: GetSerieInfo) -> Tuple[str,bool]: """ diff --git a/StreamingCommunity/Api/Site/guardaserie/site.py b/StreamingCommunity/Api/Site/guardaserie/site.py index 7732f0f..47d68b9 100644 --- a/StreamingCommunity/Api/Site/guardaserie/site.py +++ b/StreamingCommunity/Api/Site/guardaserie/site.py @@ -2,14 +2,14 @@ import sys + # External libraries import httpx from bs4 import BeautifulSoup - +from rich.console import Console # Internal utilities -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.headers import get_userAgent from StreamingCommunity.Util.table import TVShowManager @@ -21,11 +21,13 @@ from StreamingCommunity.Api.Template.Class.SearchType import MediaManager # Variable +console = Console() media_search_manager = MediaManager() table_show_manager = TVShowManager() max_timeout = config_manager.get_int("REQUESTS", "timeout") + def title_search(word_to_search: str) -> int: """ Search for titles based on a search query. diff --git a/StreamingCommunity/Api/Site/guardaserie/util/ScrapeSerie.py b/StreamingCommunity/Api/Site/guardaserie/util/ScrapeSerie.py index 9d05d7e..c552a2c 100644 --- a/StreamingCommunity/Api/Site/guardaserie/util/ScrapeSerie.py +++ b/StreamingCommunity/Api/Site/guardaserie/util/ScrapeSerie.py @@ -11,7 +11,7 @@ from bs4 import BeautifulSoup # Internal utilities from StreamingCommunity.Util.headers import get_userAgent -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager # Logic class diff --git a/StreamingCommunity/Api/Site/mostraguarda/__init__.py b/StreamingCommunity/Api/Site/mostraguarda/__init__.py index a9cf4e4..e927ce0 100644 --- a/StreamingCommunity/Api/Site/mostraguarda/__init__.py +++ b/StreamingCommunity/Api/Site/mostraguarda/__init__.py @@ -3,8 +3,9 @@ from urllib.parse import quote_plus -# Internal utilities -from StreamingCommunity.Util.console import console, msg +# External library +from rich.console import Console +from rich.prompt import Prompt, Confirm # Logic class @@ -20,6 +21,9 @@ _deprecate = False _priority = 2 _engineDownload = "hls" +msg = Prompt() +console = Console() + def search(string_to_search: str = None, get_onylDatabase: bool = False): """ diff --git a/StreamingCommunity/Api/Site/mostraguarda/film.py b/StreamingCommunity/Api/Site/mostraguarda/film.py index a27d278..d317837 100644 --- a/StreamingCommunity/Api/Site/mostraguarda/film.py +++ b/StreamingCommunity/Api/Site/mostraguarda/film.py @@ -7,14 +7,14 @@ import logging # External libraries import httpx from bs4 import BeautifulSoup +from rich.console import Console # Internal utilities -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util.os import os_manager +from StreamingCommunity.Util.os import os_manager, get_call_stack from StreamingCommunity.Util.message import start_message from StreamingCommunity.Util.headers import get_userAgent -from StreamingCommunity.Util.table import TVShowManager, get_call_stack +from StreamingCommunity.Util.table import TVShowManager from StreamingCommunity.Lib.Downloader import HLS_Downloader @@ -27,6 +27,10 @@ from StreamingCommunity.Api.Template.config_loader import site_constant from StreamingCommunity.Lib.TMBD import Json_film +# Variable +console = Console() + + def download_film(movie_details: Json_film) -> str: """ Downloads a film using the provided tmbd id. diff --git a/StreamingCommunity/Api/Site/streamingcommunity/__init__.py b/StreamingCommunity/Api/Site/streamingcommunity/__init__.py index 4492c2f..6fbc067 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/__init__.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/__init__.py @@ -5,8 +5,12 @@ import subprocess from urllib.parse import quote_plus +# External library +from rich.console import Console +from rich.prompt import Prompt + + # Internal utilities -from StreamingCommunity.Util.console import console, msg from StreamingCommunity.Api.Template import get_select_title from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance @@ -25,6 +29,9 @@ _deprecate = False _priority = 1 _engineDownload = "hls" +msg = Prompt() +console = Console() + def search(string_to_search: str = None, get_onylDatabase: bool = False): """ diff --git a/StreamingCommunity/Api/Site/streamingcommunity/film.py b/StreamingCommunity/Api/Site/streamingcommunity/film.py index c4a76a0..ec6d1d1 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/film.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/film.py @@ -3,8 +3,11 @@ import os +# External library +from rich.console import Console + + # Internal utilities -from StreamingCommunity.Util.console import console from StreamingCommunity.Util.os import os_manager from StreamingCommunity.Util.message import start_message from StreamingCommunity.Lib.Downloader import HLS_Downloader @@ -20,6 +23,10 @@ from StreamingCommunity.Api.Template.Class.SearchType import MediaItem from StreamingCommunity.Api.Player.vixcloud import VideoSource +# Variable +console = Console() + + def download_film(select_title: MediaItem) -> str: """ Downloads a film using the provided film ID, title name, and domain. diff --git a/StreamingCommunity/Api/Site/streamingcommunity/series.py b/StreamingCommunity/Api/Site/streamingcommunity/series.py index 53aa659..ec60d7d 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/series.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/series.py @@ -4,8 +4,12 @@ import os from typing import Tuple +# External library +from rich.console import Console +from rich.prompt import Prompt, Confirm + + # Internal utilities -from StreamingCommunity.Util.console import console, msg from StreamingCommunity.Util.message import start_message from StreamingCommunity.Lib.Downloader import HLS_Downloader from StreamingCommunity.TelegramHelp.telegram_bot import TelegramSession, get_bot_instance @@ -28,6 +32,11 @@ from StreamingCommunity.Api.Template.Class.SearchType import MediaItem from StreamingCommunity.Api.Player.vixcloud import VideoSource +# Variable +msg = Prompt() +console = Console() + + def download_video(index_season_selected: int, index_episode_selected: int, scrape_serie: ScrapeSerie, video_source: VideoSource) -> Tuple[str,bool]: """ Download a single episode video. diff --git a/StreamingCommunity/Api/Site/streamingcommunity/site.py b/StreamingCommunity/Api/Site/streamingcommunity/site.py index 0915a6b..dbdea32 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/site.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/site.py @@ -5,11 +5,11 @@ import sys # External libraries import httpx +from rich.console import Console # Internal utilities -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.headers import get_userAgent from StreamingCommunity.Util.table import TVShowManager from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance @@ -21,8 +21,8 @@ from StreamingCommunity.Api.Template.Util import search_domain from StreamingCommunity.Api.Template.Class.SearchType import MediaManager - # Variable +console = Console() media_search_manager = MediaManager() table_show_manager = TVShowManager() max_timeout = config_manager.get_int("REQUESTS", "timeout") diff --git a/StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py b/StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py index 5146dd3..21dda57 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py @@ -11,7 +11,7 @@ from bs4 import BeautifulSoup # Internal utilities from StreamingCommunity.Util.headers import get_userAgent -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Api.Player.Helper.Vixcloud.util import Season, EpisodeManager diff --git a/StreamingCommunity/Api/Template/Util/get_domain.py b/StreamingCommunity/Api/Template/Util/get_domain.py index 45e8dd5..63163fd 100644 --- a/StreamingCommunity/Api/Template/Util/get_domain.py +++ b/StreamingCommunity/Api/Template/Util/get_domain.py @@ -7,15 +7,16 @@ from urllib.parse import urlparse, unquote # External libraries import httpx +from rich.console import Console # Internal utilities from StreamingCommunity.Util.headers import get_headers -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager # Variable +console = Console() VERIFY = config_manager.get("REQUESTS", "verify") diff --git a/StreamingCommunity/Api/Template/Util/manage_ep.py b/StreamingCommunity/Api/Template/Util/manage_ep.py index 38505a8..9be9a81 100644 --- a/StreamingCommunity/Api/Template/Util/manage_ep.py +++ b/StreamingCommunity/Api/Template/Util/manage_ep.py @@ -5,14 +5,20 @@ import logging from typing import List +# External library +from rich.console import Console +from rich.prompt import Prompt + + # Internal utilities -from StreamingCommunity.Util.console import console, msg from StreamingCommunity.Util.os import os_manager -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.table import TVShowManager -# Config +# Variable +msg = Prompt() +console = Console() MAP_EPISODE = config_manager.get('OUT_FOLDER', 'map_episode_name') @@ -195,7 +201,6 @@ def display_episodes_list(episodes_manager) -> str: """ # Set up table for displaying episodes table_show_manager = TVShowManager() - table_show_manager.set_slice_end(10) # Add columns to the table column_info = { diff --git a/StreamingCommunity/Api/Template/config_loader.py b/StreamingCommunity/Api/Template/config_loader.py index 3765548..d9da377 100644 --- a/StreamingCommunity/Api/Template/config_loader.py +++ b/StreamingCommunity/Api/Template/config_loader.py @@ -5,7 +5,7 @@ import inspect # Internal utilities -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager def get_site_name_from_stack(): diff --git a/StreamingCommunity/Api/Template/site.py b/StreamingCommunity/Api/Template/site.py index 30aa5d9..31fb880 100644 --- a/StreamingCommunity/Api/Template/site.py +++ b/StreamingCommunity/Api/Template/site.py @@ -3,11 +3,12 @@ import sys -# Internal utilities -from StreamingCommunity.Util.console import console +# External library +from rich.console import Console # Variable +console = Console() available_colors = ['red', 'magenta', 'yellow', 'cyan', 'green', 'blue', 'white'] column_to_hide = ['Slug', 'Sub_ita', 'Last_air_date', 'Seasons_count', 'Url'] @@ -19,10 +20,6 @@ def get_select_title(table_show_manager, media_search_manager): Returns: MediaItem: The selected media item. """ - - # Set up table for displaying titles - table_show_manager.set_slice_end(10) - # Determine column_info dynamically for (search site) if not media_search_manager.media_list: console.print("\n[red]No media items available.") diff --git a/StreamingCommunity/Lib/Downloader/HLS/downloader.py b/StreamingCommunity/Lib/Downloader/HLS/downloader.py index 782be05..c864851 100644 --- a/StreamingCommunity/Lib/Downloader/HLS/downloader.py +++ b/StreamingCommunity/Lib/Downloader/HLS/downloader.py @@ -10,17 +10,14 @@ from typing import Any, Dict, List, Optional # External libraries import httpx +from rich.console import Console +from rich.panel import Panel # Internal utilities -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.headers import get_userAgent -from StreamingCommunity.Util.console import console, Panel -from StreamingCommunity.Util.os import ( - compute_sha1_hash, - os_manager, - internet_manager -) +from StreamingCommunity.Util.os import compute_sha1_hash, os_manager, internet_manager from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance @@ -49,6 +46,7 @@ RETRY_LIMIT = config_manager.get_int('REQUESTS', 'max_retry') MAX_TIMEOUT = config_manager.get_int("REQUESTS", "timeout") TELEGRAM_BOT = config_manager.get_bool('DEFAULT', 'telegram_bot') +console = Console() class HLSClient: @@ -192,7 +190,7 @@ class M3U8Manager: list_available_resolution = [f"{r[0]}x{r[1]}" for r in tuple_available_resolution] console.print( - f"[cyan bold]Video →[/cyan bold] [green]Available:[/green] [purple]{', '.join(list_available_resolution)}[/purple] | " + f"[cyan bold]Video [/cyan bold] [green]Available:[/green] [purple]{', '.join(list_available_resolution)}[/purple] | " f"[red]Set:[/red] [purple]{FILTER_CUSTOM_REOLUTION}[/purple] | " f"[yellow]Downloadable:[/yellow] [purple]{self.video_res[0]}x{self.video_res[1]}[/purple]" ) @@ -207,7 +205,7 @@ class M3U8Manager: set_codec_info = available_codec_info if config_manager.get_bool("M3U8_CONVERSION", "use_codec") else "[purple]copy[/purple]" console.print( - f"[bold cyan]Codec →[/bold cyan] [green]Available:[/green] {available_codec_info} | " + f"[bold cyan]Codec [/bold cyan] [green]Available:[/green] {available_codec_info} | " f"[red]Set:[/red] {set_codec_info}" ) @@ -216,7 +214,7 @@ class M3U8Manager: downloadable_sub_languages = list(set(available_sub_languages) & set(DOWNLOAD_SPECIFIC_SUBTITLE)) if available_sub_languages: console.print( - f"[cyan bold]Subtitle →[/cyan bold] [green]Available:[/green] [purple]{', '.join(available_sub_languages)}[/purple] | " + f"[cyan bold]Subtitle [/cyan bold] [green]Available:[/green] [purple]{', '.join(available_sub_languages)}[/purple] | " f"[red]Set:[/red] [purple]{', '.join(DOWNLOAD_SPECIFIC_SUBTITLE)}[/purple] | " f"[yellow]Downloadable:[/yellow] [purple]{', '.join(downloadable_sub_languages)}[/purple]" ) @@ -226,7 +224,7 @@ class M3U8Manager: downloadable_audio_languages = list(set(available_audio_languages) & set(DOWNLOAD_SPECIFIC_AUDIO)) if available_audio_languages: console.print( - f"[cyan bold]Audio →[/cyan bold] [green]Available:[/green] [purple]{', '.join(available_audio_languages)}[/purple] | " + f"[cyan bold]Audio [/cyan bold] [green]Available:[/green] [purple]{', '.join(available_audio_languages)}[/purple] | " f"[red]Set:[/red] [purple]{', '.join(DOWNLOAD_SPECIFIC_AUDIO)}[/purple] | " f"[yellow]Downloadable:[/yellow] [purple]{', '.join(downloadable_audio_languages)}[/purple]" ) diff --git a/StreamingCommunity/Lib/Downloader/HLS/segments.py b/StreamingCommunity/Lib/Downloader/HLS/segments.py index c982754..9933312 100644 --- a/StreamingCommunity/Lib/Downloader/HLS/segments.py +++ b/StreamingCommunity/Lib/Downloader/HLS/segments.py @@ -17,14 +17,13 @@ from typing import Dict # External libraries import httpx from tqdm import tqdm +from rich.console import Console # Internal utilities from StreamingCommunity.Util.color import Colors -from StreamingCommunity.Util.console import console from StreamingCommunity.Util.headers import get_userAgent -from StreamingCommunity.Util._jsonConfig import config_manager -from StreamingCommunity.Util.os import os_manager +from StreamingCommunity.Util.config_json import config_manager, get_use_large_bar # Logic class @@ -37,7 +36,6 @@ from ...M3U8 import ( # Config TQDM_DELAY_WORKER = config_manager.get_float('M3U8_DOWNLOAD', 'tqdm_delay') -USE_LARGE_BAR = not ("android" in sys.platform or "ios" in sys.platform) REQUEST_MAX_RETRY = config_manager.get_int('REQUESTS', 'max_retry') REQUEST_VERIFY = config_manager.get_int('REQUESTS', 'verify') DEFAULT_VIDEO_WORKERS = config_manager.get_int('M3U8_DOWNLOAD', 'default_video_workser') @@ -48,6 +46,9 @@ SEGMENT_MAX_TIMEOUT = config_manager.get_int("M3U8_DOWNLOAD", "segment_timeout") TELEGRAM_BOT = config_manager.get_bool('DEFAULT', 'telegram_bot') +# Variable +console = Console() + class M3U8_Segments: def __init__(self, url: str, tmp_folder: str, is_index_url: bool = True): @@ -386,7 +387,7 @@ class M3U8_Segments: """ Generate platform-appropriate progress bar format. """ - if not USE_LARGE_BAR: + if not get_use_large_bar(): return ( f"{Colors.YELLOW}Proc{Colors.WHITE}: " f"{Colors.RED}{{percentage:.2f}}% " diff --git a/StreamingCommunity/Lib/Downloader/MP4/downloader.py b/StreamingCommunity/Lib/Downloader/MP4/downloader.py index 0955b4c..619d05d 100644 --- a/StreamingCommunity/Lib/Downloader/MP4/downloader.py +++ b/StreamingCommunity/Lib/Downloader/MP4/downloader.py @@ -12,13 +12,15 @@ from functools import partial # External libraries import httpx from tqdm import tqdm +from rich.console import Console +from rich.prompt import Prompt +from rich.panel import Panel # Internal utilities from StreamingCommunity.Util.headers import get_userAgent from StreamingCommunity.Util.color import Colors -from StreamingCommunity.Util.console import console, Panel -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.os import internet_manager from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance @@ -34,6 +36,10 @@ REQUEST_TIMEOUT = config_manager.get_float('REQUESTS', 'timeout') TELEGRAM_BOT = config_manager.get_bool('DEFAULT', 'telegram_bot') +# Variable +msg = Prompt() +console = Console() + class InterruptHandler: def __init__(self): diff --git a/StreamingCommunity/Lib/Downloader/TOR/downloader.py b/StreamingCommunity/Lib/Downloader/TOR/downloader.py index 1d7e290..5004cf9 100644 --- a/StreamingCommunity/Lib/Downloader/TOR/downloader.py +++ b/StreamingCommunity/Lib/Downloader/TOR/downloader.py @@ -9,11 +9,14 @@ import psutil import logging +# External library +from rich.console import Console + + # Internal utilities from StreamingCommunity.Util.color import Colors from StreamingCommunity.Util.os import internet_manager -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager, get_use_large_bar # External libraries @@ -28,10 +31,9 @@ USERNAME = config_manager.get_dict('QBIT_CONFIG', 'user') PASSWORD = config_manager.get_dict('QBIT_CONFIG', 'pass') -# Config -USE_LARGE_BAR = not ("android" in sys.platform or "ios" in sys.platform) +# Variable REQUEST_TIMEOUT = config_manager.get_float('REQUESTS', 'timeout') - +console = Console() class TOR_downloader: @@ -160,7 +162,7 @@ class TOR_downloader: try: # Custom progress bar for mobile and PC - if USE_LARGE_BAR: + if get_use_large_bar(): bar_format = ( f"{Colors.YELLOW}[TOR] {Colors.WHITE}({Colors.CYAN}video{Colors.WHITE}): " f"{Colors.RED}{{percentage:.2f}}% {Colors.MAGENTA}{{bar}} {Colors.WHITE}[ " @@ -221,7 +223,7 @@ class TOR_downloader: average_internet = average_internet_str average_internet_unit = "" - if USE_LARGE_BAR: + if get_use_large_bar(): pbar.set_postfix_str( f"{Colors.WHITE}[ {Colors.GREEN}{downloaded_size} {Colors.WHITE}< {Colors.GREEN}{total_size} {Colors.RED}{total_size_unit} " f"{Colors.WHITE}| {Colors.CYAN}{average_internet} {Colors.RED}{average_internet_unit}" diff --git a/StreamingCommunity/Lib/FFmpeg/capture.py b/StreamingCommunity/Lib/FFmpeg/capture.py index c1fd2cf..4062d27 100644 --- a/StreamingCommunity/Lib/FFmpeg/capture.py +++ b/StreamingCommunity/Lib/FFmpeg/capture.py @@ -6,12 +6,16 @@ import threading import subprocess +# External library +from rich.console import Console + + # Internal utilities -from StreamingCommunity.Util.console import console from StreamingCommunity.Util.os import internet_manager # Variable +console = Console() terminate_flag = threading.Event() @@ -57,7 +61,7 @@ def capture_output(process: subprocess.Popen, description: str) -> None: # Construct the progress string with formatted output information - progress_string = (f"→ {description}[white]: " + progress_string = (f" {description}[white]: " f"([green]'speed': [yellow]{data.get('speed', 'N/A')}[white], " f"[green]'size': [yellow]{internet_manager.format_file_size(byte_size)}[white])") max_length = max(max_length, len(progress_string)) diff --git a/StreamingCommunity/Lib/FFmpeg/command.py b/StreamingCommunity/Lib/FFmpeg/command.py index 7131bf0..09524d3 100644 --- a/StreamingCommunity/Lib/FFmpeg/command.py +++ b/StreamingCommunity/Lib/FFmpeg/command.py @@ -6,10 +6,13 @@ import subprocess from typing import List, Dict, Tuple, Optional +# External library +from rich.console import Console + + # Internal utilities -from StreamingCommunity.Util._jsonConfig import config_manager -from StreamingCommunity.Util.os import os_manager, os_summary, suppress_output -from StreamingCommunity.Util.console import console +from StreamingCommunity.Util.config_json import config_manager, get_use_large_bar +from StreamingCommunity.Util.os import os_manager, suppress_output, get_ffmpeg_path # Logic class @@ -30,9 +33,7 @@ FFMPEG_DEFAULT_PRESET = config_manager.get("M3U8_CONVERSION", "default_preset") # Variable -USE_LARGE_BAR = not ("android" in sys.platform or "ios" in sys.platform) -FFMPEG_PATH = os_summary.ffmpeg_path - +console = Console() def check_subtitle_encoders() -> Tuple[Optional[bool], Optional[bool]]: @@ -45,7 +46,7 @@ def check_subtitle_encoders() -> Tuple[Optional[bool], Optional[bool]]: """ try: result = subprocess.run( - [FFMPEG_PATH, '-encoders'], + [get_ffmpeg_path(), '-encoders'], capture_output=True, text=True, check=True @@ -99,7 +100,7 @@ def join_video(video_path: str, out_path: str, codec: M3U8_Codec = None): - out_path (str): The path to save the output file. - codec (M3U8_Codec): The video codec to use. Defaults to 'copy'. """ - ffmpeg_cmd = [FFMPEG_PATH] + ffmpeg_cmd = [get_ffmpeg_path()] # Enabled the use of gpu if USE_GPU: @@ -156,7 +157,7 @@ def join_video(video_path: str, out_path: str, codec: M3U8_Codec = None): subprocess.run(ffmpeg_cmd, check=True) else: - if USE_LARGE_BAR: + if get_use_large_bar(): capture_ffmpeg_real_time(ffmpeg_cmd, "[cyan]Join video") print() @@ -182,7 +183,7 @@ def join_audios(video_path: str, audio_tracks: List[Dict[str, str]], out_path: s video_audio_same_duration = check_duration_v_a(video_path, audio_tracks[0].get('path')) # Start command with locate ffmpeg - ffmpeg_cmd = [FFMPEG_PATH] + ffmpeg_cmd = [get_ffmpeg_path()] # Enabled the use of gpu if USE_GPU: @@ -252,7 +253,7 @@ def join_audios(video_path: str, audio_tracks: List[Dict[str, str]], out_path: s subprocess.run(ffmpeg_cmd, check=True) else: - if USE_LARGE_BAR: + if get_use_large_bar(): capture_ffmpeg_real_time(ffmpeg_cmd, "[cyan]Join audio") print() @@ -275,7 +276,7 @@ def join_subtitle(video_path: str, subtitles_list: List[Dict[str, str]], out_pat Each dictionary should contain the 'path' key with the path to the subtitle file and the 'name' key with the name of the subtitle. - out_path (str): The path to save the output file. """ - ffmpeg_cmd = [FFMPEG_PATH, "-i", video_path] + ffmpeg_cmd = [get_ffmpeg_path(), "-i", video_path] # Add subtitle input files first for subtitle in subtitles_list: @@ -305,9 +306,9 @@ def join_subtitle(video_path: str, subtitles_list: List[Dict[str, str]], out_pat # Run join if DEBUG_MODE: subprocess.run(ffmpeg_cmd, check=True) - else: - if USE_LARGE_BAR: + else: + if get_use_large_bar(): capture_ffmpeg_real_time(ffmpeg_cmd, "[cyan]Join subtitle") print() diff --git a/StreamingCommunity/Lib/FFmpeg/util.py b/StreamingCommunity/Lib/FFmpeg/util.py index 82fa0d9..df28173 100644 --- a/StreamingCommunity/Lib/FFmpeg/util.py +++ b/StreamingCommunity/Lib/FFmpeg/util.py @@ -8,14 +8,16 @@ import logging from typing import Tuple +# External library +from rich.console import Console + + # Internal utilities -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util.os import os_summary +from StreamingCommunity.Util.os import get_ffprobe_path # Variable -FFPROB_PATH = os_summary.ffprobe_path - +console = Console() def has_audio_stream(video_path: str) -> bool: @@ -29,7 +31,7 @@ def has_audio_stream(video_path: str) -> bool: has_audio (bool): True if the input video has an audio stream, False otherwise. """ try: - ffprobe_cmd = [FFPROB_PATH, '-v', 'error', '-print_format', 'json', '-select_streams', 'a', '-show_streams', video_path] + ffprobe_cmd = [get_ffprobe_path(), '-v', 'error', '-print_format', 'json', '-select_streams', 'a', '-show_streams', video_path] logging.info(f"FFmpeg command: {ffprobe_cmd}") with subprocess.Popen(ffprobe_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) as proc: @@ -57,7 +59,7 @@ def get_video_duration(file_path: str) -> float: """ try: - ffprobe_cmd = [FFPROB_PATH, '-v', 'error', '-show_format', '-print_format', 'json', file_path] + ffprobe_cmd = [get_ffprobe_path(), '-v', 'error', '-show_format', '-print_format', 'json', file_path] logging.info(f"FFmpeg command: {ffprobe_cmd}") # Use a with statement to ensure the subprocess is cleaned up properly @@ -141,7 +143,7 @@ def get_ffprobe_info(file_path): """ try: result = subprocess.run( - [FFPROB_PATH, '-v', 'error', '-show_format', '-show_streams', '-print_format', 'json', file_path], + [get_ffprobe_path(), '-v', 'error', '-show_format', '-show_streams', '-print_format', 'json', file_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True ) output = result.stdout diff --git a/StreamingCommunity/Lib/M3U8/decryptor.py b/StreamingCommunity/Lib/M3U8/decryptor.py index 65a9cfc..6981910 100644 --- a/StreamingCommunity/Lib/M3U8/decryptor.py +++ b/StreamingCommunity/Lib/M3U8/decryptor.py @@ -6,11 +6,12 @@ import logging import importlib.util -# Internal utilities -from StreamingCommunity.Util.console import console +# External library +from rich.console import Console # Check if Cryptodome module is installed +console = Console() crypto_spec = importlib.util.find_spec("Cryptodome") crypto_installed = crypto_spec is not None diff --git a/StreamingCommunity/Lib/M3U8/estimator.py b/StreamingCommunity/Lib/M3U8/estimator.py index f9bfaa6..cff7980 100644 --- a/StreamingCommunity/Lib/M3U8/estimator.py +++ b/StreamingCommunity/Lib/M3U8/estimator.py @@ -14,13 +14,10 @@ from tqdm import tqdm # Internal utilities from StreamingCommunity.Util.color import Colors +from StreamingCommunity.Util.config_json import get_use_large_bar from StreamingCommunity.Util.os import internet_manager -# Variable -USE_LARGE_BAR = not ("android" in sys.platform or "ios" in sys.platform) - - class M3U8_Ts_Estimator: def __init__(self, total_segments: int, segments_instance=None): """ @@ -36,7 +33,7 @@ class M3U8_Ts_Estimator: self.lock = threading.Lock() self.speed = {"upload": "N/A", "download": "N/A"} - if USE_LARGE_BAR: + if get_use_large_bar(): logging.debug("USE_LARGE_BAR is True, starting speed capture thread") self.speed_thread = threading.Thread(target=self.capture_speed) self.speed_thread.daemon = True @@ -110,7 +107,7 @@ class M3U8_Ts_Estimator: number_file_total_size = file_total_size.split(' ')[0] units_file_total_size = file_total_size.split(' ')[1] - if USE_LARGE_BAR: + if get_use_large_bar(): speed_data = self.speed['download'].split(" ") if len(speed_data) >= 2: @@ -122,16 +119,16 @@ class M3U8_Ts_Estimator: retry_count = self.segments_instance.active_retries if self.segments_instance else 0 progress_str = ( - f"{Colors.GREEN}{number_file_total_size} {Colors.RED}{units_file_total_size}" + f"{Colors.GREEN}{number_file_total_size} {Colors.WHITE}< {Colors.RED}{units_file_total_size}" f"{Colors.WHITE} {Colors.CYAN}{average_internet_speed} {Colors.RED}{average_internet_unit}" - f"{Colors.WHITE} {Colors.GREEN}CRR {Colors.RED}{retry_count} " + f"{Colors.WHITE}, {Colors.GREEN}CRR {Colors.RED}{retry_count} " ) else: retry_count = self.segments_instance.active_retries if self.segments_instance else 0 progress_str = ( - f"{Colors.GREEN}{number_file_total_size} {Colors.RED}{units_file_total_size}" - f"{Colors.WHITE} {Colors.GREEN}CRR {Colors.RED}{retry_count} " + f"{Colors.GREEN}{number_file_total_size} {Colors.WHITE}< {Colors.RED}{units_file_total_size}" + f"{Colors.WHITE}, {Colors.GREEN}CRR {Colors.RED}{retry_count} " ) progress_counter.set_postfix_str(progress_str) diff --git a/StreamingCommunity/Lib/TMBD/tmdb.py b/StreamingCommunity/Lib/TMBD/tmdb.py index 0647880..22ed01e 100644 --- a/StreamingCommunity/Lib/TMBD/tmdb.py +++ b/StreamingCommunity/Lib/TMBD/tmdb.py @@ -6,22 +6,22 @@ from typing import Dict # External libraries import httpx +from rich.console import Console # Internal utilities from .obj_tmbd import Json_film -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.table import TVShowManager # Variable +console = Console() table_show_manager = TVShowManager() api_key = "a800ed6c93274fb857ea61bd9e7256c5" MAX_TIMEOUT = config_manager.get_int("REQUESTS", "timeout") - def get_select_title(table_show_manager, generic_obj): """ Display a selection of titles and prompt the user to choose one. @@ -29,11 +29,6 @@ def get_select_title(table_show_manager, generic_obj): Returns: dict: The selected media item. """ - - # Set up table for displaying titles - table_show_manager.set_slice_end(10) - - # Check if the generic_obj list is empty if not generic_obj: console.print("\n[red]No media items available.") return None @@ -158,7 +153,7 @@ class TheMovieDB: # Join with colored arrows and print with proper category label console.print( - f"[bold purple]{category}:[/] {' [red]→[/] '.join(colored_items)}" + f"[bold purple]{category}:[/] {' [red][/] '.join(colored_items)}" ) def display_trending_tv_shows(self): diff --git a/StreamingCommunity/Upload/update.py b/StreamingCommunity/Upload/update.py index f562ec8..4d7a9b2 100644 --- a/StreamingCommunity/Upload/update.py +++ b/StreamingCommunity/Upload/update.py @@ -7,12 +7,12 @@ import time # External library import httpx +from rich.console import Console # Internal utilities from .version import __version__, __author__, __title__ -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.headers import get_userAgent @@ -22,6 +22,7 @@ if getattr(sys, 'frozen', False): # Modalità PyInstaller base_path = os.path.join(sys._MEIPASS, "StreamingCommunity") else: base_path = os.path.dirname(__file__) +console = Console() def update(): diff --git a/StreamingCommunity/Util/call_stack.py b/StreamingCommunity/Util/call_stack.py deleted file mode 100644 index b0e878b..0000000 --- a/StreamingCommunity/Util/call_stack.py +++ /dev/null @@ -1,42 +0,0 @@ -# 21.06.24 - -import os -import inspect - - -def get_call_stack(): - """ - Retrieves the current call stack with details about each call. - - This function inspects the current call stack and returns a list of dictionaries, - where each dictionary contains details about a function call in the stack. - - Returns: - list: A list of dictionaries, each containing the following keys: - - function (str): The name of the function. - - folder (str): The directory path of the script containing the function. - - folder_base (str): The base name of the directory path. - - script (str): The name of the script file containing the function. - - line (int): The line number in the script where the function is defined. - """ - - stack = inspect.stack() - call_stack = [] - - for frame_info in stack: - function_name = frame_info.function - filename = frame_info.filename - lineno = frame_info.lineno - folder_name = os.path.dirname(filename) - folder_base = os.path.basename(folder_name) - script_name = os.path.basename(filename) - - call_stack.append({ - "function": function_name, - "folder": folder_name, - "folder_base": folder_base, - "script": script_name, - "line": lineno - }) - - return call_stack \ No newline at end of file diff --git a/StreamingCommunity/Util/_jsonConfig.py b/StreamingCommunity/Util/config_json.py similarity index 98% rename from StreamingCommunity/Util/_jsonConfig.py rename to StreamingCommunity/Util/config_json.py index 1d08ffb..6d6396c 100644 --- a/StreamingCommunity/Util/_jsonConfig.py +++ b/StreamingCommunity/Util/config_json.py @@ -405,4 +405,17 @@ class ConfigManager: config_manager = ConfigManager() -config_manager.read_config() \ No newline at end of file +config_manager.read_config() + + +import sys + +def get_use_large_bar(): + """ + Determines whether the large bar feature should be enabled. + + Returns: + bool: True if running on a PC (Windows, macOS, Linux), + False if running on Android or iOS. + """ + return not any(platform in sys.platform for platform in ("android", "ios")) \ No newline at end of file diff --git a/StreamingCommunity/Util/console.py b/StreamingCommunity/Util/console.py deleted file mode 100644 index 2ad1f8d..0000000 --- a/StreamingCommunity/Util/console.py +++ /dev/null @@ -1,12 +0,0 @@ -# 24.02.24 - -from rich.console import Console -from rich.prompt import Prompt, Confirm -from rich.panel import Panel -from rich.table import Table -from rich.text import Text - - -# Variable -msg = Prompt() -console = Console() \ No newline at end of file diff --git a/StreamingCommunity/Util/logger.py b/StreamingCommunity/Util/logger.py index 621b7d8..3c7fe91 100644 --- a/StreamingCommunity/Util/logger.py +++ b/StreamingCommunity/Util/logger.py @@ -6,7 +6,7 @@ from logging.handlers import RotatingFileHandler # Internal utilities -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager class Logger: diff --git a/StreamingCommunity/Util/message.py b/StreamingCommunity/Util/message.py index 3f8b0b1..eaff772 100644 --- a/StreamingCommunity/Util/message.py +++ b/StreamingCommunity/Util/message.py @@ -3,12 +3,17 @@ import os import platform + +# External library +from rich.console import Console + + # Internal utilities -from StreamingCommunity.Util.console import console -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager # Variable +console = Console() CLEAN = config_manager.get_bool('DEFAULT', 'clean_console') SHOW = config_manager.get_bool('DEFAULT', 'show_message') diff --git a/StreamingCommunity/Util/os.py b/StreamingCommunity/Util/os.py index 7af4db7..36d2511 100644 --- a/StreamingCommunity/Util/os.py +++ b/StreamingCommunity/Util/os.py @@ -9,6 +9,7 @@ import shutil import hashlib import logging import platform +import inspect import subprocess import contextlib import importlib.metadata @@ -18,14 +19,19 @@ from pathlib import Path # External library import httpx from unidecode import unidecode +from rich.console import Console +from rich.prompt import Prompt from pathvalidate import sanitize_filename, sanitize_filepath # Internal utilities from .ffmpeg_installer import check_ffmpeg -from StreamingCommunity.Util.console import console, msg +# Variable +msg = Prompt() +console = Console() + class OsManager: def __init__(self): @@ -488,17 +494,36 @@ def suppress_output(): yield def compute_sha1_hash(input_string: str) -> str: - """ - Computes the SHA-1 hash of the input string. + """Computes the SHA-1 hash of the input string.""" + return hashlib.sha1(input_string.encode()).hexdigest() - Parameters: - - input_string (str): The string to be hashed. +def get_call_stack(): + """Retrieves the current call stack with details about each call.""" + stack = inspect.stack() + call_stack = [] - Returns: - str: The SHA-1 hash of the input string. - """ - # Compute the SHA-1 hash - hashed_string = hashlib.sha1(input_string.encode()).hexdigest() + for frame_info in stack: + function_name = frame_info.function + filename = frame_info.filename + lineno = frame_info.lineno + folder_name = os.path.dirname(filename) + folder_base = os.path.basename(folder_name) + script_name = os.path.basename(filename) - # Return the hashed string - return hashed_string \ No newline at end of file + call_stack.append({ + "function": function_name, + "folder": folder_name, + "folder_base": folder_base, + "script": script_name, + "line": lineno + }) + + return call_stack + +def get_ffmpeg_path(): + """Returns the path of FFmpeg.""" + return os_summary.ffmpeg_path + +def get_ffprobe_path(): + """Returns the path of FFprobe.""" + return os_summary.ffprobe_path \ No newline at end of file diff --git a/StreamingCommunity/Util/table.py b/StreamingCommunity/Util/table.py index 232e075..477fbb5 100644 --- a/StreamingCommunity/Util/table.py +++ b/StreamingCommunity/Util/table.py @@ -16,13 +16,13 @@ from rich.style import Style # Internal utilities +from .os import get_call_stack from .message import start_message -from .call_stack import get_call_stack # Telegram bot instance from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager TELEGRAM_BOT = config_manager.get_bool('DEFAULT', 'telegram_bot') @@ -32,21 +32,11 @@ class TVShowManager: """Initialize TVShowManager with default values.""" self.console = Console() self.tv_shows: List[Dict[str, Any]] = [] - self.slice_start: int = 0 - self.slice_end: int = 5 - self.step: int = self.slice_end + self.slice_start = 0 + self.slice_end = 10 + self.step = self.slice_end self.column_info = [] - def set_slice_end(self, new_slice: int) -> None: - """ - Set the end of the slice for displaying TV shows. - - Parameters: - - new_slice (int): The new value for the slice end. - """ - self.slice_end = new_slice - self.step = new_slice - def add_column(self, column_info: Dict[str, Dict[str, str]]) -> None: """ Add column information. diff --git a/StreamingCommunity/run.py b/StreamingCommunity/run.py index 28cd327..b5fd26c 100644 --- a/StreamingCommunity/run.py +++ b/StreamingCommunity/run.py @@ -12,17 +12,18 @@ import threading, asyncio from typing import Callable +# External library +from rich.console import Console +from rich.prompt import Prompt + + # Internal utilities from StreamingCommunity.Util.message import start_message -from StreamingCommunity.Util.console import console, msg -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.Util.os import os_summary from StreamingCommunity.Util.logger import Logger from StreamingCommunity.Upload.update import update as git_update from StreamingCommunity.Lib.TMBD import tmdb - - -# Telegram util from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance, TelegramSession @@ -32,6 +33,10 @@ CLOSE_CONSOLE = config_manager.get_bool('DEFAULT', 'not_close') TELEGRAM_BOT = config_manager.get_bool('DEFAULT', 'telegram_bot') +# Variable +console = Console() +msg = Prompt() + def run_function(func: Callable[..., None], close_console: bool = False, search_terms: str = None) -> None: """ diff --git a/test_run.py b/test_run.py index b542d59..70dc0b8 100644 --- a/test_run.py +++ b/test_run.py @@ -5,7 +5,7 @@ import sys # Internal utilities from StreamingCommunity.run import main -from StreamingCommunity.Util._jsonConfig import config_manager +from StreamingCommunity.Util.config_json import config_manager from StreamingCommunity.TelegramHelp.telegram_bot import TelegramRequestManager, TelegramSession diff --git a/update.py b/update.py index 133e196..9f9a1bd 100644 --- a/update.py +++ b/update.py @@ -16,7 +16,7 @@ from rich.table import Table # Variable -max_timeout = 20 +max_timeout = 15 console = Console() local_path = os.path.join(".") from StreamingCommunity.Upload.version import __author__, __title__