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"
This commit is contained in:
Dark1291 2025-02-26 12:20:53 +01:00 committed by GitHub
parent 7916938c2d
commit 45f39b36c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
54 changed files with 317 additions and 219 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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):
"""

View File

@ -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")

View File

@ -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):
"""

View File

@ -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):

View File

@ -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)

View File

@ -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")

View File

@ -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

View File

@ -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):
"""

View File

@ -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:
"""

View File

@ -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")

View File

@ -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):
"""

View File

@ -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]:
"""

View File

@ -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")

View File

@ -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

View File

@ -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):
"""

View File

@ -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]:
"""

View File

@ -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.

View File

@ -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

View File

@ -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):
"""

View File

@ -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.

View File

@ -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):
"""

View File

@ -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.

View File

@ -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.

View File

@ -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")

View File

@ -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

View File

@ -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")

View File

@ -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 = {

View File

@ -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():

View File

@ -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.")

View File

@ -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]"
)

View File

@ -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}}% "

View File

@ -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):

View File

@ -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}"

View File

@ -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))

View File

@ -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()

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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):

View File

@ -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():

View File

@ -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

View File

@ -405,4 +405,17 @@ class ConfigManager:
config_manager = ConfigManager()
config_manager.read_config()
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"))

View File

@ -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()

View File

@ -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:

View File

@ -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')

View File

@ -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
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

View File

@ -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.

View File

@ -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:
"""

View File

@ -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

View File

@ -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__