StreamingCommunity 3.2.9__py3-none-any.whl → 3.3.1__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.
- StreamingCommunity/Api/Site/altadefinizione/__init__.py +67 -30
- StreamingCommunity/Api/Site/animeunity/__init__.py +65 -29
- StreamingCommunity/Api/Site/animeworld/__init__.py +80 -10
- StreamingCommunity/Api/Site/crunchyroll/__init__.py +75 -15
- StreamingCommunity/Api/Site/crunchyroll/site.py +7 -1
- StreamingCommunity/Api/Site/guardaserie/__init__.py +80 -10
- StreamingCommunity/Api/Site/mediasetinfinity/__init__.py +78 -15
- StreamingCommunity/Api/Site/mediasetinfinity/film.py +1 -1
- StreamingCommunity/Api/Site/mediasetinfinity/site.py +12 -2
- StreamingCommunity/Api/Site/mediasetinfinity/util/ScrapeSerie.py +6 -7
- StreamingCommunity/Api/Site/mediasetinfinity/util/get_license.py +162 -0
- StreamingCommunity/Api/Site/raiplay/__init__.py +78 -12
- StreamingCommunity/Api/Site/raiplay/film.py +2 -1
- StreamingCommunity/Api/Site/raiplay/series.py +21 -7
- StreamingCommunity/Api/Site/streamingcommunity/__init__.py +12 -9
- StreamingCommunity/Api/Site/streamingcommunity/site.py +4 -1
- StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py +5 -2
- StreamingCommunity/Api/Site/streamingwatch/__init__.py +76 -12
- StreamingCommunity/Lib/Downloader/DASH/cdm_helpher.py +8 -0
- StreamingCommunity/Lib/Downloader/DASH/downloader.py +109 -75
- StreamingCommunity/Lib/Downloader/HLS/downloader.py +18 -6
- StreamingCommunity/Lib/Downloader/HLS/segments.py +1 -1
- StreamingCommunity/Lib/Downloader/MP4/downloader.py +21 -3
- StreamingCommunity/Lib/FFmpeg/command.py +66 -7
- StreamingCommunity/Lib/FFmpeg/util.py +16 -13
- StreamingCommunity/Upload/update.py +2 -2
- StreamingCommunity/Upload/version.py +2 -2
- StreamingCommunity/Util/os.py +4 -1
- StreamingCommunity/run.py +4 -4
- {streamingcommunity-3.2.9.dist-info → streamingcommunity-3.3.1.dist-info}/METADATA +2 -7
- {streamingcommunity-3.2.9.dist-info → streamingcommunity-3.3.1.dist-info}/RECORD +35 -38
- StreamingCommunity/Api/Site/cb01new/__init__.py +0 -72
- StreamingCommunity/Api/Site/cb01new/film.py +0 -64
- StreamingCommunity/Api/Site/cb01new/site.py +0 -78
- {streamingcommunity-3.2.9.dist-info → streamingcommunity-3.3.1.dist-info}/WHEEL +0 -0
- {streamingcommunity-3.2.9.dist-info → streamingcommunity-3.3.1.dist-info}/entry_points.txt +0 -0
- {streamingcommunity-3.2.9.dist-info → streamingcommunity-3.3.1.dist-info}/licenses/LICENSE +0 -0
- {streamingcommunity-3.2.9.dist-info → streamingcommunity-3.3.1.dist-info}/top_level.txt +0 -0
|
@@ -6,11 +6,13 @@ import shutil
|
|
|
6
6
|
|
|
7
7
|
# External libraries
|
|
8
8
|
from rich.console import Console
|
|
9
|
+
from rich.panel import Panel
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
# Internal utilities
|
|
12
13
|
from StreamingCommunity.Util.config_json import config_manager
|
|
13
|
-
from StreamingCommunity.
|
|
14
|
+
from StreamingCommunity.Util.os import internet_manager
|
|
15
|
+
from ...FFmpeg import print_duration_table
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
# Logic class
|
|
@@ -20,6 +22,7 @@ from .decrypt import decrypt_with_mp4decrypt
|
|
|
20
22
|
from .cdm_helpher import get_widevine_keys
|
|
21
23
|
|
|
22
24
|
|
|
25
|
+
|
|
23
26
|
# Config
|
|
24
27
|
DOWNLOAD_SPECIFIC_AUDIO = config_manager.get_list('M3U8_DOWNLOAD', 'specific_list_audio')
|
|
25
28
|
FILTER_CUSTOM_REOLUTION = str(config_manager.get('M3U8_CONVERSION', 'force_resolution')).strip().lower()
|
|
@@ -35,8 +38,8 @@ class DASH_Downloader:
|
|
|
35
38
|
self.cdm_device = cdm_device
|
|
36
39
|
self.license_url = license_url
|
|
37
40
|
self.mpd_url = mpd_url
|
|
38
|
-
self.
|
|
39
|
-
self.
|
|
41
|
+
self.out_path = os.path.splitext(os.path.abspath(str(output_path)))[0]
|
|
42
|
+
self.original_output_path = output_path
|
|
40
43
|
self.parser = None
|
|
41
44
|
self._setup_temp_dirs()
|
|
42
45
|
|
|
@@ -94,55 +97,58 @@ class DASH_Downloader:
|
|
|
94
97
|
self.error = None
|
|
95
98
|
self.stopped = False
|
|
96
99
|
|
|
100
|
+
# Fetch keys immediately after obtaining PSSH
|
|
101
|
+
if not self.parser.pssh:
|
|
102
|
+
console.print("[red]No PSSH found: segments are not encrypted, skipping decryption.")
|
|
103
|
+
self.download_segments(clear=True)
|
|
104
|
+
return True
|
|
105
|
+
|
|
106
|
+
keys = get_widevine_keys(
|
|
107
|
+
pssh=self.parser.pssh,
|
|
108
|
+
license_url=self.license_url,
|
|
109
|
+
cdm_device_path=self.cdm_device,
|
|
110
|
+
headers=custom_headers,
|
|
111
|
+
payload=custom_payload
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
if not keys:
|
|
115
|
+
console.print("[red]No keys found, cannot proceed with download.[/red]")
|
|
116
|
+
return False
|
|
117
|
+
|
|
118
|
+
# Extract the first key for decryption
|
|
119
|
+
key = keys[0]
|
|
120
|
+
KID = key['kid']
|
|
121
|
+
KEY = key['key']
|
|
122
|
+
|
|
97
123
|
for typ in ["video", "audio"]:
|
|
98
124
|
rep = self.get_representation_by_type(typ)
|
|
99
125
|
if rep:
|
|
100
126
|
encrypted_path = os.path.join(self.encrypted_dir, f"{rep['id']}_encrypted.m4s")
|
|
101
127
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
128
|
+
# If m4s file doesn't exist, start downloading
|
|
129
|
+
if not os.path.exists(encrypted_path):
|
|
130
|
+
downloader = MPD_Segments(
|
|
131
|
+
tmp_folder=self.encrypted_dir,
|
|
132
|
+
representation=rep,
|
|
133
|
+
pssh=self.parser.pssh
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
try:
|
|
137
|
+
result = downloader.download_streams()
|
|
138
|
+
|
|
139
|
+
# Check for interruption or failure
|
|
140
|
+
if result.get("stopped"):
|
|
141
|
+
self.stopped = True
|
|
142
|
+
self.error = "Download interrupted"
|
|
143
|
+
return False
|
|
144
|
+
|
|
145
|
+
if result.get("nFailed", 0) > 0:
|
|
146
|
+
self.error = f"Failed segments: {result['nFailed']}"
|
|
147
|
+
return False
|
|
148
|
+
|
|
149
|
+
except Exception as ex:
|
|
150
|
+
self.error = str(ex)
|
|
119
151
|
return False
|
|
120
|
-
|
|
121
|
-
except Exception as ex:
|
|
122
|
-
self.error = str(ex)
|
|
123
|
-
return False
|
|
124
|
-
|
|
125
|
-
if not self.parser.pssh:
|
|
126
|
-
print("No PSSH found: segments are not encrypted, skipping decryption.")
|
|
127
|
-
self.download_segments(clear=True)
|
|
128
|
-
return True
|
|
129
|
-
|
|
130
|
-
keys = get_widevine_keys(
|
|
131
|
-
pssh=self.parser.pssh,
|
|
132
|
-
license_url=self.license_url,
|
|
133
|
-
cdm_device_path=self.cdm_device,
|
|
134
|
-
headers=custom_headers,
|
|
135
|
-
payload=custom_payload
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
if not keys:
|
|
139
|
-
self.error = f"No key found, cannot decrypt {typ}"
|
|
140
|
-
print(self.error)
|
|
141
|
-
return False
|
|
142
|
-
|
|
143
|
-
key = keys[0]
|
|
144
|
-
KID = key['kid']
|
|
145
|
-
KEY = key['key']
|
|
146
152
|
|
|
147
153
|
decrypted_path = os.path.join(self.decrypted_dir, f"{typ}.mp4")
|
|
148
154
|
result_path = decrypt_with_mp4decrypt(
|
|
@@ -167,46 +173,74 @@ class DASH_Downloader:
|
|
|
167
173
|
pass
|
|
168
174
|
|
|
169
175
|
def finalize_output(self):
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
# fallback: if one of the two is missing, look in encrypted
|
|
174
|
-
if not os.path.exists(video_file):
|
|
175
|
-
for f in os.listdir(self.encrypted_dir):
|
|
176
|
-
if f.endswith("_encrypted.m4s") and ("video" in f or f.startswith("1_")):
|
|
177
|
-
video_file = os.path.join(self.encrypted_dir, f)
|
|
178
|
-
break
|
|
179
|
-
if not os.path.exists(audio_file):
|
|
180
|
-
for f in os.listdir(self.encrypted_dir):
|
|
181
|
-
if f.endswith("_encrypted.m4s") and ("audio" in f or f.startswith("0_")):
|
|
182
|
-
audio_file = os.path.join(self.encrypted_dir, f)
|
|
183
|
-
break
|
|
184
|
-
|
|
185
|
-
# Usa il nome file originale per il file finale
|
|
176
|
+
|
|
177
|
+
# Use the original output path for the final file
|
|
186
178
|
output_file = self.original_output_path
|
|
179
|
+
|
|
180
|
+
# Set the output file path for status tracking
|
|
181
|
+
self.output_file = output_file
|
|
182
|
+
use_shortest = False
|
|
187
183
|
|
|
188
|
-
if os.path.exists(video_file) and os.path.exists(audio_file):
|
|
184
|
+
"""if os.path.exists(video_file) and os.path.exists(audio_file):
|
|
189
185
|
audio_tracks = [{"path": audio_file}]
|
|
190
|
-
join_audios(video_file, audio_tracks, output_file)
|
|
186
|
+
out_audio_path, use_shortest = join_audios(video_file, audio_tracks, output_file)
|
|
187
|
+
|
|
191
188
|
elif os.path.exists(video_file):
|
|
192
|
-
join_video(video_file, output_file, codec=None)
|
|
189
|
+
out_video_path = join_video(video_file, output_file, codec=None)
|
|
190
|
+
|
|
193
191
|
else:
|
|
194
192
|
print("Video file missing, cannot export")
|
|
193
|
+
return None
|
|
194
|
+
"""
|
|
195
195
|
|
|
196
|
-
#
|
|
196
|
+
# Handle failed sync case
|
|
197
|
+
if use_shortest:
|
|
198
|
+
new_filename = output_file.replace(".mp4", "_failed_sync.mp4")
|
|
199
|
+
os.rename(output_file, new_filename)
|
|
200
|
+
output_file = new_filename
|
|
201
|
+
self.output_file = new_filename
|
|
202
|
+
|
|
203
|
+
# Display file information
|
|
204
|
+
if os.path.exists(output_file):
|
|
205
|
+
file_size = internet_manager.format_file_size(os.path.getsize(output_file))
|
|
206
|
+
duration = print_duration_table(output_file, description=False, return_string=True)
|
|
207
|
+
panel_content = (
|
|
208
|
+
f"[cyan]File size: [bold red]{file_size}[/bold red]\n"
|
|
209
|
+
f"[cyan]Duration: [bold]{duration}[/bold]\n"
|
|
210
|
+
f"[cyan]Output: [bold]{os.path.abspath(output_file)}[/bold]"
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
console.print(Panel(
|
|
214
|
+
panel_content,
|
|
215
|
+
title=f"{os.path.basename(output_file.replace('.mp4', ''))}",
|
|
216
|
+
border_style="green"
|
|
217
|
+
))
|
|
218
|
+
|
|
219
|
+
# Clean up: delete only the tmp directory, not the main directory
|
|
197
220
|
if os.path.exists(self.tmp_dir):
|
|
198
221
|
shutil.rmtree(self.tmp_dir, ignore_errors=True)
|
|
199
222
|
|
|
200
|
-
#
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
os.rmdir(self.out_path)
|
|
204
|
-
except Exception as e:
|
|
205
|
-
print(f"[WARN] Impossibile eliminare la cartella {self.out_path}: {e}")
|
|
223
|
+
# Only remove the temp base directory if it was created specifically for this download
|
|
224
|
+
# and if the final output is NOT inside this directory
|
|
225
|
+
output_dir = os.path.dirname(self.original_output_path)
|
|
206
226
|
|
|
227
|
+
# Check if out_path is different from the actual output directory
|
|
228
|
+
# and if it's empty, then it's safe to remove
|
|
229
|
+
if (self.out_path != output_dir and
|
|
230
|
+
os.path.exists(self.out_path) and
|
|
231
|
+
not os.listdir(self.out_path)):
|
|
232
|
+
try:
|
|
233
|
+
os.rmdir(self.out_path)
|
|
234
|
+
except Exception as e:
|
|
235
|
+
print(f"[WARN] Cannot remove directory {self.out_path}: {e}")
|
|
207
236
|
|
|
208
|
-
|
|
209
|
-
|
|
237
|
+
# Verify the final file exists before returning
|
|
238
|
+
if os.path.exists(output_file):
|
|
239
|
+
return output_file
|
|
240
|
+
else:
|
|
241
|
+
self.error = "Final output file was not created successfully"
|
|
242
|
+
return None
|
|
243
|
+
|
|
210
244
|
def get_status(self):
|
|
211
245
|
"""
|
|
212
246
|
Returns a dict with 'path', 'error', and 'stopped' for external use.
|
|
@@ -215,4 +249,4 @@ class DASH_Downloader:
|
|
|
215
249
|
"path": self.output_file,
|
|
216
250
|
"error": self.error,
|
|
217
251
|
"stopped": self.stopped
|
|
218
|
-
}
|
|
252
|
+
}
|
|
@@ -360,6 +360,7 @@ class MergeManager:
|
|
|
360
360
|
"""
|
|
361
361
|
video_file = os.path.join(self.temp_dir, 'video', '0.ts')
|
|
362
362
|
merged_file = video_file
|
|
363
|
+
use_shortest = False
|
|
363
364
|
|
|
364
365
|
if not self.audio_streams and not self.sub_streams:
|
|
365
366
|
merged_file = join_video(
|
|
@@ -376,7 +377,7 @@ class MergeManager:
|
|
|
376
377
|
} for a in self.audio_streams]
|
|
377
378
|
|
|
378
379
|
merged_audio_path = os.path.join(self.temp_dir, 'merged_audio.mp4')
|
|
379
|
-
merged_file = join_audios(
|
|
380
|
+
merged_file, use_shortest = join_audios(
|
|
380
381
|
video_path=video_file,
|
|
381
382
|
audio_tracks=audio_tracks,
|
|
382
383
|
out_path=merged_audio_path,
|
|
@@ -396,7 +397,7 @@ class MergeManager:
|
|
|
396
397
|
out_path=merged_subs_path
|
|
397
398
|
)
|
|
398
399
|
|
|
399
|
-
return merged_file
|
|
400
|
+
return merged_file, use_shortest
|
|
400
401
|
|
|
401
402
|
|
|
402
403
|
class HLS_Downloader:
|
|
@@ -467,9 +468,9 @@ class HLS_Downloader:
|
|
|
467
468
|
sub_streams=self.m3u8_manager.sub_streams
|
|
468
469
|
)
|
|
469
470
|
|
|
470
|
-
final_file = self.merge_manager.merge()
|
|
471
|
+
final_file, use_shortest = self.merge_manager.merge()
|
|
471
472
|
self.path_manager.move_final_file(final_file)
|
|
472
|
-
self._print_summary()
|
|
473
|
+
self._print_summary(use_shortest)
|
|
473
474
|
self.path_manager.cleanup()
|
|
474
475
|
|
|
475
476
|
return {
|
|
@@ -495,7 +496,7 @@ class HLS_Downloader:
|
|
|
495
496
|
'stopped': False
|
|
496
497
|
}
|
|
497
498
|
|
|
498
|
-
def _print_summary(self):
|
|
499
|
+
def _print_summary(self, use_shortest):
|
|
499
500
|
"""Prints download summary including file size, duration, and any missing segments."""
|
|
500
501
|
if TELEGRAM_BOT:
|
|
501
502
|
bot = get_bot_instance()
|
|
@@ -523,7 +524,18 @@ class HLS_Downloader:
|
|
|
523
524
|
|
|
524
525
|
if missing_ts:
|
|
525
526
|
panel_content += f"\n{missing_info}"
|
|
526
|
-
|
|
527
|
+
|
|
528
|
+
new_filename = self.path_manager.output_path
|
|
529
|
+
if missing_ts and use_shortest:
|
|
530
|
+
new_filename = new_filename.replace(".mp4", "_failed_sync_ts.mp4")
|
|
531
|
+
elif missing_ts:
|
|
532
|
+
new_filename = new_filename.replace(".mp4", "_failed_ts.mp4")
|
|
533
|
+
elif use_shortest:
|
|
534
|
+
new_filename = new_filename.replace(".mp4", "_failed_sync.mp4")
|
|
535
|
+
|
|
536
|
+
if missing_ts or use_shortest:
|
|
537
|
+
os.rename(self.path_manager.output_path, new_filename)
|
|
538
|
+
self.path_manager.output_path = new_filename
|
|
527
539
|
|
|
528
540
|
console.print(Panel(
|
|
529
541
|
panel_content,
|
|
@@ -249,7 +249,7 @@ class M3U8_Segments:
|
|
|
249
249
|
self.info_nRetry += 1
|
|
250
250
|
|
|
251
251
|
if attempt + 1 == REQUEST_MAX_RETRY:
|
|
252
|
-
console.
|
|
252
|
+
console.print(f"[red]Final retry failed for segment: {index}")
|
|
253
253
|
self.queue.put((index, None)) # Marker for failed segment
|
|
254
254
|
progress_bar.update(1)
|
|
255
255
|
self.info_nFailed += 1
|
|
@@ -7,6 +7,7 @@ import time
|
|
|
7
7
|
import signal
|
|
8
8
|
import logging
|
|
9
9
|
from functools import partial
|
|
10
|
+
import threading
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
# External libraries
|
|
@@ -101,10 +102,23 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No
|
|
|
101
102
|
else:
|
|
102
103
|
headers['User-Agent'] = get_userAgent()
|
|
103
104
|
|
|
104
|
-
# Set interrupt handler
|
|
105
|
+
# Set interrupt handler (only in main thread). In background threads (e.g., Django), skip custom signal handling.
|
|
105
106
|
temp_path = f"{path}.temp"
|
|
106
107
|
interrupt_handler = InterruptHandler()
|
|
107
|
-
original_handler =
|
|
108
|
+
original_handler = None
|
|
109
|
+
try:
|
|
110
|
+
if threading.current_thread() is threading.main_thread():
|
|
111
|
+
original_handler = signal.signal(
|
|
112
|
+
signal.SIGINT,
|
|
113
|
+
partial(
|
|
114
|
+
signal_handler,
|
|
115
|
+
interrupt_handler=interrupt_handler,
|
|
116
|
+
original_handler=signal.getsignal(signal.SIGINT),
|
|
117
|
+
),
|
|
118
|
+
)
|
|
119
|
+
except Exception:
|
|
120
|
+
# If setting signal handler fails (non-main thread), continue without it
|
|
121
|
+
original_handler = None
|
|
108
122
|
|
|
109
123
|
# Ensure the output directory exists
|
|
110
124
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
@@ -184,4 +198,8 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No
|
|
|
184
198
|
return None, interrupt_handler.kill_download
|
|
185
199
|
|
|
186
200
|
finally:
|
|
187
|
-
|
|
201
|
+
if original_handler is not None:
|
|
202
|
+
try:
|
|
203
|
+
signal.signal(signal.SIGINT, original_handler)
|
|
204
|
+
except Exception:
|
|
205
|
+
pass
|
|
@@ -15,7 +15,7 @@ from StreamingCommunity.Util.os import os_manager, suppress_output, get_ffmpeg_p
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
# Logic class
|
|
18
|
-
from .util import need_to_force_to_ts, check_duration_v_a
|
|
18
|
+
from .util import need_to_force_to_ts, check_duration_v_a, get_video_duration
|
|
19
19
|
from .capture import capture_ffmpeg_real_time
|
|
20
20
|
from ..M3U8 import M3U8_Codec
|
|
21
21
|
|
|
@@ -99,6 +99,14 @@ def join_video(video_path: str, out_path: str, codec: M3U8_Codec = None):
|
|
|
99
99
|
- out_path (str): The path to save the output file.
|
|
100
100
|
- codec (M3U8_Codec): The video codec to use. Defaults to 'copy'.
|
|
101
101
|
"""
|
|
102
|
+
if video_path is None:
|
|
103
|
+
console.log("[red]No video path provided for joining.")
|
|
104
|
+
return None
|
|
105
|
+
|
|
106
|
+
if out_path is None:
|
|
107
|
+
console.log("[red]No output path provided for joining.")
|
|
108
|
+
return None
|
|
109
|
+
|
|
102
110
|
ffmpeg_cmd = [get_ffmpeg_path()]
|
|
103
111
|
|
|
104
112
|
# Enabled the use of gpu
|
|
@@ -175,10 +183,50 @@ def join_audios(video_path: str, audio_tracks: List[Dict[str, str]], out_path: s
|
|
|
175
183
|
Parameters:
|
|
176
184
|
- video_path (str): The path to the video file.
|
|
177
185
|
- audio_tracks (list[dict[str, str]]): A list of dictionaries containing information about audio tracks.
|
|
178
|
-
Each dictionary should contain the 'path'
|
|
186
|
+
Each dictionary should contain the 'path' and 'name' keys.
|
|
179
187
|
- out_path (str): The path to save the output file.
|
|
180
188
|
"""
|
|
181
|
-
|
|
189
|
+
if video_path is None:
|
|
190
|
+
console.log("[red]No video path provided for joining audios.")
|
|
191
|
+
return None, False
|
|
192
|
+
|
|
193
|
+
if audio_tracks is None or len(audio_tracks) == 0:
|
|
194
|
+
console.log("[red]No audio tracks provided for joining.")
|
|
195
|
+
return None, False
|
|
196
|
+
|
|
197
|
+
if out_path is None:
|
|
198
|
+
console.log("[red]No output path provided for joining audios.")
|
|
199
|
+
return None, False
|
|
200
|
+
|
|
201
|
+
use_shortest = False
|
|
202
|
+
duration_diffs = []
|
|
203
|
+
|
|
204
|
+
# Get video duration first
|
|
205
|
+
video_duration = get_video_duration(video_path, None)
|
|
206
|
+
|
|
207
|
+
for audio_track in audio_tracks:
|
|
208
|
+
audio_path = audio_track.get('path')
|
|
209
|
+
audio_lang = audio_track.get('name', 'unknown')
|
|
210
|
+
audio_duration, diff = check_duration_v_a(video_path, audio_path)
|
|
211
|
+
|
|
212
|
+
duration_diffs.append({
|
|
213
|
+
'language': audio_lang,
|
|
214
|
+
'difference': diff,
|
|
215
|
+
'has_error': diff > 0.5,
|
|
216
|
+
'video_duration': video_duration,
|
|
217
|
+
'audio_duration': audio_duration
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
if diff > 0.5:
|
|
221
|
+
use_shortest = True
|
|
222
|
+
console.log("[red]Warning: Some audio tracks have duration differences (>0.5s)")
|
|
223
|
+
|
|
224
|
+
# Print duration differences for each track
|
|
225
|
+
if use_shortest:
|
|
226
|
+
for track in duration_diffs:
|
|
227
|
+
color = "red" if track['has_error'] else "green"
|
|
228
|
+
console.print(f"[{color}]Audio {track['language']}: Video duration: {track['video_duration']:.2f}s, Audio duration: {track['audio_duration']:.2f}s, Difference: {track['difference']:.2f}s[/{color}]")
|
|
229
|
+
|
|
182
230
|
|
|
183
231
|
# Start command with locate ffmpeg
|
|
184
232
|
ffmpeg_cmd = [get_ffmpeg_path()]
|
|
@@ -238,9 +286,8 @@ def join_audios(video_path: str, audio_tracks: List[Dict[str, str]], out_path: s
|
|
|
238
286
|
else:
|
|
239
287
|
ffmpeg_cmd.extend(['-preset', 'fast'])
|
|
240
288
|
|
|
241
|
-
# Use shortest input path
|
|
242
|
-
if
|
|
243
|
-
console.log(f"[red]Use shortest input (Duration difference: {duration_diff:.2f} seconds)...")
|
|
289
|
+
# Use shortest input path if any audio track has significant difference
|
|
290
|
+
if use_shortest:
|
|
244
291
|
ffmpeg_cmd.extend(['-shortest', '-strict', 'experimental'])
|
|
245
292
|
|
|
246
293
|
# Overwrite
|
|
@@ -261,7 +308,7 @@ def join_audios(video_path: str, audio_tracks: List[Dict[str, str]], out_path: s
|
|
|
261
308
|
capture_ffmpeg_real_time(ffmpeg_cmd, "[cyan]Join audio")
|
|
262
309
|
print()
|
|
263
310
|
|
|
264
|
-
return out_path
|
|
311
|
+
return out_path, use_shortest
|
|
265
312
|
|
|
266
313
|
|
|
267
314
|
def join_subtitle(video_path: str, subtitles_list: List[Dict[str, str]], out_path: str):
|
|
@@ -274,6 +321,18 @@ def join_subtitle(video_path: str, subtitles_list: List[Dict[str, str]], out_pat
|
|
|
274
321
|
Each dictionary should contain the 'path' key with the path to the subtitle file and the 'name' key with the name of the subtitle.
|
|
275
322
|
- out_path (str): The path to save the output file.
|
|
276
323
|
"""
|
|
324
|
+
if video_path is None:
|
|
325
|
+
console.log("[red]No video path provided for joining subtitles.")
|
|
326
|
+
return None
|
|
327
|
+
|
|
328
|
+
if subtitles_list is None or len(subtitles_list) == 0:
|
|
329
|
+
console.log("[red]No subtitles provided for joining.")
|
|
330
|
+
return None
|
|
331
|
+
|
|
332
|
+
if out_path is None:
|
|
333
|
+
console.log("[red]No output path provided for joining subtitles.")
|
|
334
|
+
return None
|
|
335
|
+
|
|
277
336
|
ffmpeg_cmd = [get_ffmpeg_path(), "-i", video_path]
|
|
278
337
|
|
|
279
338
|
# Add subtitle input files first
|
|
@@ -47,15 +47,16 @@ def has_audio_stream(video_path: str) -> bool:
|
|
|
47
47
|
return False
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def get_video_duration(file_path: str) -> float:
|
|
50
|
+
def get_video_duration(file_path: str, file_type: str = "file") -> float:
|
|
51
51
|
"""
|
|
52
|
-
Get the duration of a video
|
|
52
|
+
Get the duration of a media file (video or audio).
|
|
53
53
|
|
|
54
54
|
Parameters:
|
|
55
|
-
- file_path (str): The path to the
|
|
55
|
+
- file_path (str): The path to the media file.
|
|
56
|
+
- file_type (str): The type of the file ('video' or 'audio'). Defaults to 'file'.
|
|
56
57
|
|
|
57
58
|
Returns:
|
|
58
|
-
(float): The duration of the
|
|
59
|
+
(float): The duration of the media file in seconds if successful, None if there's an error.
|
|
59
60
|
"""
|
|
60
61
|
try:
|
|
61
62
|
ffprobe_cmd = [get_ffprobe_path(), '-v', 'error', '-show_format', '-print_format', 'json', file_path]
|
|
@@ -64,23 +65,23 @@ def get_video_duration(file_path: str) -> float:
|
|
|
64
65
|
# Use a with statement to ensure the subprocess is cleaned up properly
|
|
65
66
|
with subprocess.Popen(ffprobe_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) as proc:
|
|
66
67
|
stdout, stderr = proc.communicate()
|
|
67
|
-
|
|
68
|
+
|
|
68
69
|
if proc.returncode != 0:
|
|
69
70
|
logging.error(f"Error: {stderr}")
|
|
70
71
|
return None
|
|
71
|
-
|
|
72
|
+
|
|
72
73
|
# Parse JSON output
|
|
73
74
|
probe_result = json.loads(stdout)
|
|
74
75
|
|
|
75
|
-
# Extract duration from the
|
|
76
|
+
# Extract duration from the media information
|
|
76
77
|
try:
|
|
77
78
|
return float(probe_result['format']['duration'])
|
|
78
|
-
|
|
79
|
+
|
|
79
80
|
except Exception:
|
|
80
81
|
return 1
|
|
81
82
|
|
|
82
83
|
except Exception as e:
|
|
83
|
-
logging.error(f"Get
|
|
84
|
+
logging.error(f"Get {file_type} duration error: {e}, ffprobe path: {get_ffprobe_path()}, file path: {file_path}")
|
|
84
85
|
sys.exit(0)
|
|
85
86
|
|
|
86
87
|
|
|
@@ -242,20 +243,22 @@ def check_duration_v_a(video_path, audio_path, tolerance=1.0):
|
|
|
242
243
|
Returns:
|
|
243
244
|
- tuple: (bool, float) -> True if the duration of the video and audio matches, False otherwise, along with the difference in duration.
|
|
244
245
|
"""
|
|
245
|
-
video_duration = get_video_duration(video_path)
|
|
246
|
-
audio_duration = get_video_duration(audio_path)
|
|
246
|
+
video_duration = get_video_duration(video_path, file_type="video")
|
|
247
|
+
audio_duration = get_video_duration(audio_path, file_type="audio")
|
|
247
248
|
|
|
248
249
|
# Check if either duration is None and specify which one is None
|
|
249
250
|
if video_duration is None and audio_duration is None:
|
|
250
251
|
console.print("[yellow]Warning: Both video and audio durations are None. Returning 0 as duration difference.[/yellow]")
|
|
251
252
|
return False, 0.0
|
|
253
|
+
|
|
252
254
|
elif video_duration is None:
|
|
253
255
|
console.print("[yellow]Warning: Video duration is None. Returning 0 as duration difference.[/yellow]")
|
|
254
256
|
return False, 0.0
|
|
257
|
+
|
|
255
258
|
elif audio_duration is None:
|
|
256
259
|
console.print("[yellow]Warning: Audio duration is None. Returning 0 as duration difference.[/yellow]")
|
|
257
260
|
return False, 0.0
|
|
258
|
-
|
|
261
|
+
|
|
259
262
|
# Calculate the duration difference
|
|
260
263
|
duration_difference = abs(video_duration - audio_duration)
|
|
261
264
|
|
|
@@ -263,4 +266,4 @@ def check_duration_v_a(video_path, audio_path, tolerance=1.0):
|
|
|
263
266
|
if duration_difference <= tolerance:
|
|
264
267
|
return True, duration_difference
|
|
265
268
|
else:
|
|
266
|
-
return False, duration_difference
|
|
269
|
+
return False, duration_difference
|
|
@@ -90,7 +90,7 @@ def update():
|
|
|
90
90
|
latest_commit_message = 'No commit history available'
|
|
91
91
|
|
|
92
92
|
console.print(f"\n[cyan]Current installed version: [yellow]{current_version}")
|
|
93
|
-
console.print(f"[cyan]Last commit: [yellow]{latest_commit_message}")
|
|
93
|
+
console.print(f"[cyan]Last commit: [yellow]{latest_commit_message.splitlines()[0]}")
|
|
94
94
|
|
|
95
95
|
if str(current_version).replace('v', '') != str(last_version).replace('v', ''):
|
|
96
96
|
console.print(f"\n[cyan]New version available: [yellow]{last_version}")
|
|
@@ -98,4 +98,4 @@ def update():
|
|
|
98
98
|
console.print(f"\n[red]{__title__} has been downloaded [yellow]{total_download_count} [red]times, but only [yellow]{percentual_stars}% [red]of users have starred it.\n\
|
|
99
99
|
[cyan]Help the repository grow today by leaving a [yellow]star [cyan]and [yellow]sharing [cyan]it with others online!")
|
|
100
100
|
|
|
101
|
-
time.sleep(4)
|
|
101
|
+
time.sleep(4)
|
StreamingCommunity/Util/os.py
CHANGED
|
@@ -435,7 +435,10 @@ class OsSummary:
|
|
|
435
435
|
ffmpeg_str = f"'{self.ffmpeg_path}'" if self.ffmpeg_path else "None"
|
|
436
436
|
ffprobe_str = f"'{self.ffprobe_path}'" if self.ffprobe_path else "None"
|
|
437
437
|
mp4decrypt_str = f"'{self.mp4decrypt_path}'" if self.mp4decrypt_path else "None"
|
|
438
|
-
|
|
438
|
+
wvd_path = get_wvd_path()
|
|
439
|
+
wvd_str = f"'{wvd_path}'" if wvd_path else "None"
|
|
440
|
+
|
|
441
|
+
console.print(f"[cyan]Path: [red]ffmpeg [bold yellow]{ffmpeg_str}[/bold yellow][white], [red]ffprobe [bold yellow]{ffprobe_str}[/bold yellow][white], [red]mp4decrypt [bold yellow]{mp4decrypt_str}[/bold yellow][white], [red]wvd [bold yellow]{wvd_str}[/bold yellow]")
|
|
439
442
|
|
|
440
443
|
|
|
441
444
|
os_manager = OsManager()
|
StreamingCommunity/run.py
CHANGED
|
@@ -329,13 +329,13 @@ def check_dns_and_exit_if_needed():
|
|
|
329
329
|
]
|
|
330
330
|
|
|
331
331
|
if not internet_manager.check_dns_resolve(hostname_list):
|
|
332
|
-
console.print("[red]
|
|
332
|
+
console.print("[red]\nERROR: DNS configuration is required!")
|
|
333
333
|
console.print("[red]The program cannot function correctly without proper DNS settings.")
|
|
334
|
-
console.print("[yellow]Please configure one of these DNS servers:")
|
|
334
|
+
console.print("\n[yellow]Please configure one of these DNS servers:")
|
|
335
335
|
console.print("[red]• Cloudflare (1.1.1.1) 'https://developers.cloudflare.com/1.1.1.1/setup/windows/'")
|
|
336
336
|
console.print("[red]• Quad9 (9.9.9.9) 'https://docs.quad9.net/Setup_Guides/Windows/Windows_10/'")
|
|
337
|
-
console.print("\n[yellow]
|
|
338
|
-
|
|
337
|
+
console.print("\n[yellow]-> The program will not work until you configure your DNS settings.")
|
|
338
|
+
sys.exit(0)
|
|
339
339
|
|
|
340
340
|
|
|
341
341
|
def setup_argument_parser(search_functions):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: StreamingCommunity
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.1
|
|
4
4
|
Home-page: https://github.com/Lovi-0/StreamingCommunity
|
|
5
5
|
Author: Lovi-0
|
|
6
6
|
Project-URL: Bug Reports, https://github.com/Lovi-0/StreamingCommunity/issues
|
|
@@ -25,6 +25,7 @@ Requires-Dist: ua-generator
|
|
|
25
25
|
Requires-Dist: qbittorrent-api
|
|
26
26
|
Requires-Dist: pyTelegramBotAPI
|
|
27
27
|
Requires-Dist: pywidevine
|
|
28
|
+
Requires-Dist: seleniumbase
|
|
28
29
|
Dynamic: author
|
|
29
30
|
Dynamic: description
|
|
30
31
|
Dynamic: description-content-type
|
|
@@ -913,17 +914,11 @@ python3 telegram_bot.py
|
|
|
913
914
|
- [Pypy](https://www.youtube.com/watch?v=C6m9ZKOK0p4)
|
|
914
915
|
- [Compiled](https://www.youtube.com/watch?v=pm4lqsxkTVo)
|
|
915
916
|
|
|
916
|
-
# To Do
|
|
917
|
-
|
|
918
|
-
- To Finish [website API](https://github.com/Arrowar/StreamingCommunity/tree/test_gui_1)
|
|
919
|
-
- To finish [website API 2](https://github.com/hydrosh/StreamingCommunity/tree/test_gui_1)
|
|
920
|
-
|
|
921
917
|
## Useful Project
|
|
922
918
|
|
|
923
919
|
### 🎯 [Unit3Dup](https://github.com/31December99/Unit3Dup)
|
|
924
920
|
Bot in Python per la generazione e l'upload automatico di torrent su tracker basati su Unit3D.
|
|
925
921
|
|
|
926
|
-
|
|
927
922
|
### 🇮🇹 [MammaMia](https://github.com/UrloMythus/MammaMia)
|
|
928
923
|
Addon per Stremio che consente lo streaming HTTPS di film, serie, anime e TV in diretta in lingua italiana.
|
|
929
924
|
|