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