StreamingCommunity 2.4.0__py3-none-any.whl → 2.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of StreamingCommunity might be problematic. Click here for more details.

Files changed (91) hide show
  1. {StreamingCommunity-2.4.0.dist-info → StreamingCommunity-2.5.0.dist-info}/METADATA +9 -6
  2. StreamingCommunity-2.5.0.dist-info/RECORD +8 -0
  3. StreamingCommunity/Api/Player/Helper/Vixcloud/js_parser.py +0 -143
  4. StreamingCommunity/Api/Player/Helper/Vixcloud/util.py +0 -136
  5. StreamingCommunity/Api/Player/ddl.py +0 -89
  6. StreamingCommunity/Api/Player/maxstream.py +0 -151
  7. StreamingCommunity/Api/Player/supervideo.py +0 -194
  8. StreamingCommunity/Api/Player/vixcloud.py +0 -273
  9. StreamingCommunity/Api/Site/1337xx/__init__.py +0 -51
  10. StreamingCommunity/Api/Site/1337xx/costant.py +0 -15
  11. StreamingCommunity/Api/Site/1337xx/site.py +0 -89
  12. StreamingCommunity/Api/Site/1337xx/title.py +0 -66
  13. StreamingCommunity/Api/Site/altadefinizionegratis/__init__.py +0 -51
  14. StreamingCommunity/Api/Site/altadefinizionegratis/costant.py +0 -19
  15. StreamingCommunity/Api/Site/altadefinizionegratis/film.py +0 -74
  16. StreamingCommunity/Api/Site/altadefinizionegratis/site.py +0 -95
  17. StreamingCommunity/Api/Site/animeunity/__init__.py +0 -51
  18. StreamingCommunity/Api/Site/animeunity/costant.py +0 -19
  19. StreamingCommunity/Api/Site/animeunity/film_serie.py +0 -135
  20. StreamingCommunity/Api/Site/animeunity/site.py +0 -175
  21. StreamingCommunity/Api/Site/animeunity/util/ScrapeSerie.py +0 -97
  22. StreamingCommunity/Api/Site/cb01new/__init__.py +0 -52
  23. StreamingCommunity/Api/Site/cb01new/costant.py +0 -19
  24. StreamingCommunity/Api/Site/cb01new/film.py +0 -73
  25. StreamingCommunity/Api/Site/cb01new/site.py +0 -83
  26. StreamingCommunity/Api/Site/ddlstreamitaly/__init__.py +0 -56
  27. StreamingCommunity/Api/Site/ddlstreamitaly/costant.py +0 -20
  28. StreamingCommunity/Api/Site/ddlstreamitaly/series.py +0 -146
  29. StreamingCommunity/Api/Site/ddlstreamitaly/site.py +0 -99
  30. StreamingCommunity/Api/Site/ddlstreamitaly/util/ScrapeSerie.py +0 -85
  31. StreamingCommunity/Api/Site/guardaserie/__init__.py +0 -51
  32. StreamingCommunity/Api/Site/guardaserie/costant.py +0 -19
  33. StreamingCommunity/Api/Site/guardaserie/series.py +0 -198
  34. StreamingCommunity/Api/Site/guardaserie/site.py +0 -90
  35. StreamingCommunity/Api/Site/guardaserie/util/ScrapeSerie.py +0 -110
  36. StreamingCommunity/Api/Site/ilcorsaronero/__init__.py +0 -52
  37. StreamingCommunity/Api/Site/ilcorsaronero/costant.py +0 -19
  38. StreamingCommunity/Api/Site/ilcorsaronero/site.py +0 -72
  39. StreamingCommunity/Api/Site/ilcorsaronero/title.py +0 -46
  40. StreamingCommunity/Api/Site/ilcorsaronero/util/ilCorsarScraper.py +0 -149
  41. StreamingCommunity/Api/Site/mostraguarda/__init__.py +0 -49
  42. StreamingCommunity/Api/Site/mostraguarda/costant.py +0 -19
  43. StreamingCommunity/Api/Site/mostraguarda/film.py +0 -101
  44. StreamingCommunity/Api/Site/streamingcommunity/__init__.py +0 -56
  45. StreamingCommunity/Api/Site/streamingcommunity/costant.py +0 -19
  46. StreamingCommunity/Api/Site/streamingcommunity/film.py +0 -75
  47. StreamingCommunity/Api/Site/streamingcommunity/series.py +0 -206
  48. StreamingCommunity/Api/Site/streamingcommunity/site.py +0 -142
  49. StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py +0 -123
  50. StreamingCommunity/Api/Template/Class/SearchType.py +0 -101
  51. StreamingCommunity/Api/Template/Util/__init__.py +0 -5
  52. StreamingCommunity/Api/Template/Util/get_domain.py +0 -203
  53. StreamingCommunity/Api/Template/Util/manage_ep.py +0 -179
  54. StreamingCommunity/Api/Template/Util/recall_search.py +0 -37
  55. StreamingCommunity/Api/Template/__init__.py +0 -3
  56. StreamingCommunity/Api/Template/site.py +0 -87
  57. StreamingCommunity/Lib/Downloader/HLS/downloader.py +0 -965
  58. StreamingCommunity/Lib/Downloader/HLS/proxyes.py +0 -110
  59. StreamingCommunity/Lib/Downloader/HLS/segments.py +0 -573
  60. StreamingCommunity/Lib/Downloader/MP4/downloader.py +0 -155
  61. StreamingCommunity/Lib/Downloader/TOR/downloader.py +0 -296
  62. StreamingCommunity/Lib/Downloader/__init__.py +0 -5
  63. StreamingCommunity/Lib/FFmpeg/__init__.py +0 -4
  64. StreamingCommunity/Lib/FFmpeg/capture.py +0 -170
  65. StreamingCommunity/Lib/FFmpeg/command.py +0 -296
  66. StreamingCommunity/Lib/FFmpeg/util.py +0 -249
  67. StreamingCommunity/Lib/M3U8/__init__.py +0 -6
  68. StreamingCommunity/Lib/M3U8/decryptor.py +0 -165
  69. StreamingCommunity/Lib/M3U8/estimator.py +0 -229
  70. StreamingCommunity/Lib/M3U8/parser.py +0 -666
  71. StreamingCommunity/Lib/M3U8/url_fixer.py +0 -58
  72. StreamingCommunity/Lib/TMBD/__init__.py +0 -2
  73. StreamingCommunity/Lib/TMBD/obj_tmbd.py +0 -39
  74. StreamingCommunity/Lib/TMBD/tmdb.py +0 -346
  75. StreamingCommunity/Upload/update.py +0 -67
  76. StreamingCommunity/Upload/version.py +0 -5
  77. StreamingCommunity/Util/_jsonConfig.py +0 -228
  78. StreamingCommunity/Util/call_stack.py +0 -42
  79. StreamingCommunity/Util/color.py +0 -20
  80. StreamingCommunity/Util/console.py +0 -12
  81. StreamingCommunity/Util/ffmpeg_installer.py +0 -368
  82. StreamingCommunity/Util/headers.py +0 -160
  83. StreamingCommunity/Util/logger.py +0 -62
  84. StreamingCommunity/Util/message.py +0 -64
  85. StreamingCommunity/Util/os.py +0 -507
  86. StreamingCommunity/Util/table.py +0 -229
  87. StreamingCommunity-2.4.0.dist-info/RECORD +0 -92
  88. {StreamingCommunity-2.4.0.dist-info → StreamingCommunity-2.5.0.dist-info}/LICENSE +0 -0
  89. {StreamingCommunity-2.4.0.dist-info → StreamingCommunity-2.5.0.dist-info}/WHEEL +0 -0
  90. {StreamingCommunity-2.4.0.dist-info → StreamingCommunity-2.5.0.dist-info}/entry_points.txt +0 -0
  91. {StreamingCommunity-2.4.0.dist-info → StreamingCommunity-2.5.0.dist-info}/top_level.txt +0 -0
@@ -1,228 +0,0 @@
1
- # 29.01.24
2
-
3
- import os
4
- import sys
5
- import json
6
- import httpx
7
- import logging
8
- from typing import Any, List
9
-
10
-
11
- class ConfigManager:
12
- def __init__(self, file_path: str = 'config.json') -> None:
13
- """Initialize the ConfigManager.
14
-
15
- Parameters:
16
- - file_path (str, optional): The path to the configuration file. Default is 'config.json'.
17
- """
18
- self.file_path = file_path
19
- self.config = {}
20
- self.cache = {}
21
-
22
- def read_config(self) -> None:
23
- """Read the configuration file."""
24
- try:
25
- logging.info(f"Reading file: {self.file_path}")
26
-
27
- # Check if file exists
28
- if os.path.exists(self.file_path):
29
- with open(self.file_path, 'r') as f:
30
- self.config = json.load(f)
31
- logging.info("Configuration file loaded successfully.")
32
-
33
- # Download config.json if it doesn't exist locally
34
- else:
35
- logging.info("Configuration file does not exist. Downloading...")
36
- self.download_requirements(
37
- 'https://raw.githubusercontent.com/Lovi-0/StreamingCommunity/refs/heads/main/config.json',
38
- self.file_path
39
- )
40
-
41
- # Load the downloaded config.json into the config attribute
42
- with open(self.file_path, 'r') as f:
43
- self.config = json.load(f)
44
- logging.info("Configuration file downloaded and saved.")
45
-
46
- logging.info("Configuration file processed successfully.")
47
-
48
- except Exception as e:
49
- logging.error(f"Error reading configuration file: {e}")
50
-
51
- def download_requirements(self, url: str, filename: str):
52
- """
53
- Download the requirements.txt file from the specified URL if not found locally using requests.
54
-
55
- Args:
56
- url (str): The URL to download the requirements file from.
57
- filename (str): The local filename to save the requirements file as.
58
- """
59
- try:
60
- import requests
61
-
62
- logging.info(f"{filename} not found locally. Downloading from {url}...")
63
- response = requests.get(url)
64
-
65
- if response.status_code == 200:
66
- with open(filename, 'wb') as f:
67
- f.write(response.content)
68
-
69
- else:
70
- logging.error(f"Failed to download {filename}. HTTP Status code: {response.status_code}")
71
- sys.exit(0)
72
-
73
- except Exception as e:
74
- logging.error(f"Failed to download {filename}: {e}")
75
- sys.exit(0)
76
-
77
- def read_key(self, section: str, key: str, data_type: type = str) -> Any:
78
- """Read a key from the configuration file.
79
-
80
- Parameters:
81
- - section (str): The section in the configuration file.
82
- - key (str): The key to be read.
83
- - data_type (type, optional): The expected data type of the key's value. Default is str.
84
-
85
- Returns:
86
- The value of the key converted to the specified data type.
87
- """
88
- cache_key = f"{section}.{key}"
89
- logging.info(f"Read key: {cache_key}")
90
-
91
- if cache_key in self.cache:
92
- return self.cache[cache_key]
93
-
94
- if section in self.config and key in self.config[section]:
95
- value = self.config[section][key]
96
- else:
97
- raise ValueError(f"Key '{key}' not found in section '{section}'")
98
-
99
- value = self._convert_to_data_type(value, data_type)
100
- self.cache[cache_key] = value
101
-
102
- return value
103
-
104
- def _convert_to_data_type(self, value: str, data_type: type) -> Any:
105
- """Convert the value to the specified data type.
106
-
107
- Parameters:
108
- - value (str): The value to be converted.
109
- - data_type (type): The expected data type.
110
-
111
- Returns:
112
- The value converted to the specified data type.
113
- """
114
- if data_type == int:
115
- return int(value)
116
- elif data_type == bool:
117
- return bool(value)
118
- elif data_type == list:
119
- return value if isinstance(value, list) else [item.strip() for item in value.split(',')]
120
- elif data_type == type(None):
121
- return None
122
- else:
123
- return value
124
-
125
- def get(self, section: str, key: str) -> Any:
126
- """Read a value from the configuration file.
127
-
128
- Parameters:
129
- - section (str): The section in the configuration file.
130
- - key (str): The key to be read.
131
-
132
- Returns:
133
- The value associated with the key.
134
- """
135
- return self.read_key(section, key)
136
-
137
- def get_int(self, section: str, key: str) -> int:
138
- """Read an integer value from the configuration file.
139
-
140
- Parameters:
141
- - section (str): The section in the configuration file.
142
- - key (str): The key to be read.
143
-
144
- Returns:
145
- int: The integer value.
146
- """
147
- return self.read_key(section, key, int)
148
-
149
- def get_float(self, section: str, key: str) -> int:
150
- """Read an float value from the configuration file.
151
-
152
- Parameters:
153
- - section (str): The section in the configuration file.
154
- - key (str): The key to be read.
155
-
156
- Returns:
157
- float: The float value.
158
- """
159
- return self.read_key(section, key, float)
160
-
161
- def get_bool(self, section: str, key: str) -> bool:
162
- """Read a boolean value from the configuration file.
163
-
164
- Parameters:
165
- - section (str): The section in the configuration file.
166
- - key (str): The key to be read.
167
-
168
- Returns:
169
- bool: The boolean value.
170
- """
171
- return self.read_key(section, key, bool)
172
-
173
- def get_list(self, section: str, key: str) -> List[str]:
174
- """Read a list value from the configuration file.
175
-
176
- Parameters:
177
- - section (str): The section in the configuration file.
178
- - key (str): The key to be read.
179
-
180
- Returns:
181
- list: The list value.
182
- """
183
- return self.read_key(section, key, list)
184
-
185
- def get_dict(self, section: str, key: str) -> dict:
186
- """Read a dictionary value from the configuration file.
187
-
188
- Parameters:
189
- - section (str): The section in the configuration file.
190
- - key (str): The key to be read.
191
-
192
- Returns:
193
- dict: The dictionary value.
194
- """
195
- return self.read_key(section, key, dict)
196
-
197
- def set_key(self, section: str, key: str, value: Any) -> None:
198
- """Set a key in the configuration file.
199
-
200
- Parameters:
201
- - section (str): The section in the configuration file.
202
- - key (str): The key to be set.
203
- - value (Any): The value to be associated with the key.
204
- """
205
- try:
206
- if section not in self.config:
207
- self.config[section] = {}
208
-
209
- self.config[section][key] = value
210
- cache_key = f"{section}.{key}"
211
- self.cache[cache_key] = value
212
- self.write_config()
213
-
214
- except Exception as e:
215
- print(f"Error setting key '{key}' in section '{section}': {e}")
216
-
217
- def write_config(self) -> None:
218
- """Write the configuration to the file."""
219
- try:
220
- with open(self.file_path, 'w') as f:
221
- json.dump(self.config, f, indent=4)
222
- except Exception as e:
223
- print(f"Error writing configuration file: {e}")
224
-
225
-
226
- # Initialize
227
- config_manager = ConfigManager()
228
- config_manager.read_config()
@@ -1,42 +0,0 @@
1
- # 21.06.24
2
-
3
- import os
4
- import inspect
5
-
6
-
7
- def get_call_stack():
8
- """
9
- Retrieves the current call stack with details about each call.
10
-
11
- This function inspects the current call stack and returns a list of dictionaries,
12
- where each dictionary contains details about a function call in the stack.
13
-
14
- Returns:
15
- list: A list of dictionaries, each containing the following keys:
16
- - function (str): The name of the function.
17
- - folder (str): The directory path of the script containing the function.
18
- - folder_base (str): The base name of the directory path.
19
- - script (str): The name of the script file containing the function.
20
- - line (int): The line number in the script where the function is defined.
21
- """
22
-
23
- stack = inspect.stack()
24
- call_stack = []
25
-
26
- for frame_info in stack:
27
- function_name = frame_info.function
28
- filename = frame_info.filename
29
- lineno = frame_info.lineno
30
- folder_name = os.path.dirname(filename)
31
- folder_base = os.path.basename(folder_name)
32
- script_name = os.path.basename(filename)
33
-
34
- call_stack.append({
35
- "function": function_name,
36
- "folder": folder_name,
37
- "folder_base": folder_base,
38
- "script": script_name,
39
- "line": lineno
40
- })
41
-
42
- return call_stack
@@ -1,20 +0,0 @@
1
- # 24.05.24
2
-
3
- class Colors:
4
- BLACK = "\033[30m"
5
- RED = "\033[31m"
6
- GREEN = "\033[32m"
7
- YELLOW = "\033[33m"
8
- BLUE = "\033[34m"
9
- MAGENTA = "\033[35m"
10
- CYAN = "\033[36m"
11
- LIGHT_GRAY = "\033[37m"
12
- DARK_GRAY = "\033[90m"
13
- LIGHT_RED = "\033[91m"
14
- LIGHT_GREEN = "\033[92m"
15
- LIGHT_YELLOW = "\033[93m"
16
- LIGHT_BLUE = "\033[94m"
17
- LIGHT_MAGENTA = "\033[95m"
18
- LIGHT_CYAN = "\033[96m"
19
- WHITE = "\033[97m"
20
- RESET = "\033[0m"
@@ -1,12 +0,0 @@
1
- # 24.02.24
2
-
3
- from rich.console import Console
4
- from rich.prompt import Prompt, Confirm
5
- from rich.panel import Panel
6
- from rich.table import Table
7
- from rich.text import Text
8
-
9
-
10
- # Variable
11
- msg = Prompt()
12
- console = Console()
@@ -1,368 +0,0 @@
1
- # 24.01.2024
2
-
3
- import os
4
- import platform
5
- import subprocess
6
- import zipfile
7
- import tarfile
8
- import logging
9
- import requests
10
- import shutil
11
- import glob
12
- from typing import Optional, Tuple
13
-
14
-
15
- # External library
16
- from rich.console import Console
17
- from rich.progress import Progress, SpinnerColumn, BarColumn, TextColumn, TimeRemainingColumn
18
-
19
-
20
- # Variable
21
- console = Console()
22
-
23
- # https://github.com/eugeneware/ffmpeg-static/releases
24
- FFMPEG_CONFIGURATION = {
25
- 'windows': {
26
- 'base_dir': lambda home: os.path.join(os.path.splitdrive(home)[0] + os.path.sep, 'binary'),
27
- 'download_url': 'https://github.com/GyanD/codexffmpeg/releases/download/{version}/ffmpeg-{version}-full_build.zip',
28
- 'file_extension': '.zip',
29
- 'executables': ['ffmpeg.exe', 'ffprobe.exe', 'ffplay.exe']
30
- },
31
- 'darwin': {
32
- 'base_dir': lambda home: os.path.join(home, 'Applications', 'binary'),
33
- 'download_url': 'https://github.com/eugeneware/ffmpeg-static/releases/download/b{version}/ffmpeg-macOS-{arch}.zip',
34
- 'file_extension': '.zip',
35
- 'executables': ['ffmpeg', 'ffprobe', 'ffplay']
36
- },
37
- 'linux': {
38
- 'base_dir': lambda home: os.path.join(home, '.local', 'bin', 'binary'),
39
- 'download_url': 'https://github.com/eugeneware/ffmpeg-static/releases/download/b{version}/ffmpeg-linux-{arch}.tar.xz',
40
- 'file_extension': '.tar.xz',
41
- 'executables': ['ffmpeg', 'ffprobe', 'ffplay']
42
- }
43
- }
44
-
45
-
46
- class FFMPEGDownloader:
47
- """
48
- A class for downloading and managing FFmpeg executables.
49
-
50
- This class handles the detection of the operating system, downloading of FFmpeg binaries,
51
- and management of the FFmpeg executables (ffmpeg, ffprobe, and ffplay).
52
-
53
- Attributes:
54
- os_name (str): The detected operating system name
55
- arch (str): The system architecture (e.g., x86_64, arm64)
56
- home_dir (str): User's home directory path
57
- base_dir (str): Base directory for storing FFmpeg binaries
58
- """
59
-
60
- def __init__(self):
61
- self.os_name = self._detect_system()
62
- self.arch = self._detect_arch()
63
- self.home_dir = os.path.expanduser('~')
64
- self.base_dir = self._get_base_directory()
65
-
66
- def _detect_system(self) -> str:
67
- """
68
- Detect and normalize the operating system name.
69
-
70
- Returns:
71
- str: Normalized operating system name ('windows', 'darwin', or 'linux')
72
-
73
- Raises:
74
- ValueError: If the operating system is not supported
75
- """
76
- system = platform.system().lower()
77
- if system in FFMPEG_CONFIGURATION:
78
- return system
79
- raise ValueError(f"Unsupported operating system: {system}")
80
-
81
- def _detect_arch(self) -> str:
82
- """
83
- Detect and normalize the system architecture.
84
-
85
- Returns:
86
- str: Normalized architecture name (e.g., 'x86_64', 'arm64')
87
-
88
- The method normalizes various architecture names to consistent values:
89
- - amd64/x86_64/x64 -> x86_64
90
- - arm64/aarch64 -> arm64
91
- """
92
- machine = platform.machine().lower()
93
- arch_map = {
94
- 'amd64': 'x86_64',
95
- 'x86_64': 'x86_64',
96
- 'x64': 'x86_64',
97
- 'arm64': 'arm64',
98
- 'aarch64': 'arm64'
99
- }
100
- return arch_map.get(machine, machine)
101
-
102
- def _get_base_directory(self) -> str:
103
- """
104
- Get and create the base directory for storing FFmpeg binaries.
105
-
106
- Returns:
107
- str: Path to the base directory
108
-
109
- The directory location varies by operating system:
110
- - Windows: C:\\binary
111
- - macOS: ~/Applications/binary
112
- - Linux: ~/.local/bin/binary
113
- """
114
- base_dir = FFMPEG_CONFIGURATION[self.os_name]['base_dir'](self.home_dir)
115
- os.makedirs(base_dir, exist_ok=True)
116
- return base_dir
117
-
118
- def _check_existing_binaries(self) -> Tuple[Optional[str], Optional[str], Optional[str]]:
119
- """
120
- Check if FFmpeg binaries already exist in the base directory.
121
- Enhanced to check both the binary directory and system paths on macOS.
122
- """
123
- config = FFMPEG_CONFIGURATION[self.os_name]
124
- executables = config['executables']
125
- found_executables = []
126
-
127
- # For macOS, check both binary directory and system paths
128
- if self.os_name == 'darwin':
129
- potential_paths = [
130
- '/usr/local/bin',
131
- '/opt/homebrew/bin',
132
- '/usr/bin',
133
- self.base_dir
134
- ]
135
-
136
- for executable in executables:
137
- found = None
138
- for path in potential_paths:
139
- full_path = os.path.join(path, executable)
140
- if os.path.exists(full_path) and os.access(full_path, os.X_OK):
141
- found = full_path
142
- break
143
- found_executables.append(found)
144
- else:
145
-
146
- # Original behavior for other operating systems
147
- for executable in executables:
148
- exe_paths = glob.glob(os.path.join(self.base_dir, executable))
149
- found_executables.append(exe_paths[0] if exe_paths else None)
150
-
151
- return tuple(found_executables) if len(found_executables) == 3 else (None, None, None)
152
-
153
- def _get_latest_version(self) -> Optional[str]:
154
- """
155
- Get the latest FFmpeg version from the GitHub releases page.
156
-
157
- Returns:
158
- Optional[str]: The latest version string, or None if retrieval fails.
159
-
160
- Raises:
161
- requests.exceptions.RequestException: If there are network-related errors.
162
- """
163
- try:
164
- # Use GitHub API to fetch the latest release
165
- response = requests.get(
166
- 'https://api.github.com/repos/eugeneware/ffmpeg-static/releases/latest'
167
- )
168
- response.raise_for_status()
169
- latest_release = response.json()
170
-
171
- # Extract the tag name or version from the release
172
- return latest_release.get('tag_name')
173
- except Exception as e:
174
- logging.error(f"Unable to get version from GitHub: {e}")
175
- return None
176
-
177
- def _download_file(self, url: str, destination: str) -> bool:
178
- """
179
- Download a file from URL with a Rich progress bar display.
180
-
181
- Parameters:
182
- url (str): The URL to download the file from. Should be a direct download link.
183
- destination (str): Local file path where the downloaded file will be saved.
184
-
185
- Returns:
186
- bool: True if download was successful, False otherwise.
187
-
188
- Raises:
189
- requests.exceptions.RequestException: If there are network-related errors
190
- IOError: If there are issues writing to the destination file
191
- """
192
- try:
193
- response = requests.get(url, stream=True)
194
- response.raise_for_status()
195
- total_size = int(response.headers.get('content-length', 0))
196
-
197
- with open(destination, 'wb') as file, \
198
- Progress(
199
- SpinnerColumn(),
200
- TextColumn("[progress.description]{task.description}"),
201
- BarColumn(),
202
- TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
203
- TimeRemainingColumn()
204
- ) as progress:
205
-
206
- download_task = progress.add_task("[green]Downloading FFmpeg", total=total_size)
207
- for chunk in response.iter_content(chunk_size=8192):
208
- size = file.write(chunk)
209
- progress.update(download_task, advance=size)
210
- return True
211
- except Exception as e:
212
- logging.error(f"Download error: {e}")
213
- return False
214
-
215
- def _extract_and_copy_binaries(self, archive_path: str) -> Tuple[Optional[str], Optional[str], Optional[str]]:
216
- """
217
- Extract FFmpeg binaries from the downloaded archive and copy them to the base directory.
218
-
219
- Parameters:
220
- archive_path (str): Path to the downloaded archive file
221
-
222
- Returns:
223
- Tuple[Optional[str], Optional[str], Optional[str]]: Paths to the extracted ffmpeg,
224
- ffprobe, and ffplay executables. Returns None for each executable that couldn't be extracted.
225
- """
226
- try:
227
- extraction_path = os.path.join(self.base_dir, 'temp_extract')
228
- os.makedirs(extraction_path, exist_ok=True)
229
-
230
- if archive_path.endswith('.zip'):
231
- with zipfile.ZipFile(archive_path, 'r') as zip_ref:
232
- zip_ref.extractall(extraction_path)
233
- elif archive_path.endswith('.tar.xz'):
234
- with tarfile.open(archive_path) as tar_ref:
235
- tar_ref.extractall(extraction_path)
236
-
237
- config = FFMPEG_CONFIGURATION[self.os_name]
238
- executables = config['executables']
239
- found_paths = []
240
-
241
- for executable in executables:
242
- exe_paths = glob.glob(os.path.join(extraction_path, '**', executable), recursive=True)
243
-
244
- if exe_paths:
245
- dest_path = os.path.join(self.base_dir, executable)
246
- shutil.copy2(exe_paths[0], dest_path)
247
-
248
- if self.os_name != 'windows':
249
- os.chmod(dest_path, 0o755)
250
-
251
- found_paths.append(dest_path)
252
- else:
253
- found_paths.append(None)
254
-
255
- shutil.rmtree(extraction_path, ignore_errors=True)
256
- os.remove(archive_path)
257
-
258
- return tuple(found_paths) if len(found_paths) == 3 else (None, None, None)
259
-
260
- except Exception as e:
261
- logging.error(f"Extraction/copy error: {e}")
262
- return None, None, None
263
-
264
- def download(self) -> Tuple[Optional[str], Optional[str], Optional[str]]:
265
- """
266
- Main method to download and set up FFmpeg executables.
267
-
268
- Returns:
269
- Tuple[Optional[str], Optional[str], Optional[str]]: Paths to ffmpeg, ffprobe, and ffplay executables.
270
- Returns None for each executable that couldn't be downloaded or set up.
271
- """
272
- existing_ffmpeg, existing_ffprobe, existing_ffplay = self._check_existing_binaries()
273
- if all([existing_ffmpeg, existing_ffprobe, existing_ffplay]):
274
- return existing_ffmpeg, existing_ffprobe, existing_ffplay
275
-
276
- version = self._get_latest_version()
277
- if not version:
278
- logging.error("Cannot proceed: version not found")
279
- return None, None, None
280
-
281
- config = FFMPEG_CONFIGURATION[self.os_name]
282
- download_url = config['download_url'].format(
283
- version=version,
284
- arch=self.arch
285
- )
286
-
287
- download_path = os.path.join(
288
- self.base_dir,
289
- f'ffmpeg-{version}{config["file_extension"]}'
290
- )
291
-
292
- console.print(f"[bold blue]Downloading FFmpeg from:[/] {download_url}")
293
- if not self._download_file(download_url, download_path):
294
- return None, None, None
295
-
296
- return self._extract_and_copy_binaries(download_path)
297
-
298
- def check_ffmpeg() -> Tuple[Optional[str], Optional[str], Optional[str]]:
299
- """
300
- Check for FFmpeg executables in the system and download them if not found.
301
- Enhanced detection for macOS systems.
302
-
303
- Returns:
304
- Tuple[Optional[str], Optional[str], Optional[str]]: Paths to ffmpeg, ffprobe, and ffplay executables.
305
- """
306
- try:
307
- system_platform = platform.system().lower()
308
-
309
- # Special handling for macOS
310
- if system_platform == 'darwin':
311
-
312
- # Common installation paths on macOS
313
- potential_paths = [
314
- '/usr/local/bin', # Homebrew default
315
- '/opt/homebrew/bin', # Apple Silicon Homebrew
316
- '/usr/bin', # System default
317
- os.path.expanduser('~/Applications/binary'), # Custom installation
318
- '/Applications/binary' # Custom installation
319
- ]
320
-
321
- for path in potential_paths:
322
- ffmpeg_path = os.path.join(path, 'ffmpeg')
323
- ffprobe_path = os.path.join(path, 'ffprobe')
324
- ffplay_path = os.path.join(path, 'ffplay')
325
-
326
- if (os.path.exists(ffmpeg_path) and os.path.exists(ffprobe_path) and
327
- os.access(ffmpeg_path, os.X_OK) and os.access(ffprobe_path, os.X_OK)):
328
-
329
- # Return found executables, with ffplay being optional
330
- ffplay_path = ffplay_path if os.path.exists(ffplay_path) else None
331
- return ffmpeg_path, ffprobe_path, ffplay_path
332
-
333
- # Windows detection
334
- elif system_platform == 'windows':
335
- try:
336
- ffmpeg_path = subprocess.check_output(
337
- ['where', 'ffmpeg'], stderr=subprocess.DEVNULL, text=True
338
- ).strip().split('\n')[0]
339
-
340
- ffprobe_path = subprocess.check_output(
341
- ['where', 'ffprobe'], stderr=subprocess.DEVNULL, text=True
342
- ).strip().split('\n')[0]
343
-
344
- ffplay_path = subprocess.check_output(
345
- ['where', 'ffplay'], stderr=subprocess.DEVNULL, text=True
346
- ).strip().split('\n')[0]
347
-
348
- return ffmpeg_path, ffprobe_path, ffplay_path
349
-
350
- except subprocess.CalledProcessError:
351
- logging.warning("One or more FFmpeg binaries were not found with command where")
352
-
353
- # Linux detection
354
- else:
355
- ffmpeg_path = shutil.which('ffmpeg')
356
- ffprobe_path = shutil.which('ffprobe')
357
- ffplay_path = shutil.which('ffplay')
358
-
359
- if ffmpeg_path and ffprobe_path:
360
- return ffmpeg_path, ffprobe_path, ffplay_path
361
-
362
- # If executables were not found, attempt to download FFmpeg
363
- downloader = FFMPEGDownloader()
364
- return downloader.download()
365
-
366
- except Exception as e:
367
- logging.error(f"Error checking or downloading FFmpeg executables: {e}")
368
- return None, None, None