Skip to content

Commit 7ab2102

Browse files
Arrowargithub-actions[bot]
authored andcommitted
Improve M3U8_CONVERSION
1 parent b6d9de0 commit 7ab2102

File tree

16 files changed

+302
-175
lines changed

16 files changed

+302
-175
lines changed

.github/.domain/domains.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"cb01new": {
3-
"domain": "site",
4-
"full_url": "https://cb01net.site/",
5-
"old_domain": "xyz",
6-
"time_change": "2025-10-06 15:20:32"
3+
"domain": "bond",
4+
"full_url": "https://cb01net.bond/",
5+
"old_domain": "site",
6+
"time_change": "2025-10-13 19:15:23"
77
},
88
"animeunity": {
99
"domain": "so",
@@ -18,10 +18,10 @@
1818
"time_change": "2025-03-21 12:20:27"
1919
},
2020
"guardaserie": {
21-
"domain": "one",
22-
"full_url": "https://guardaserietv.one/",
23-
"old_domain": "help",
24-
"time_change": "2025-10-06 17:18:02"
21+
"domain": "uno",
22+
"full_url": "https://guardaserietv.uno/",
23+
"old_domain": "one",
24+
"time_change": "2025-10-13 19:15:26"
2525
},
2626
"streamingwatch": {
2727
"domain": "org",
@@ -36,10 +36,10 @@
3636
"time_change": "2025-09-06 18:24:29"
3737
},
3838
"streamingcommunity": {
39-
"domain": "me",
40-
"full_url": "https://streamingcommunityz.me/",
41-
"old_domain": "li",
42-
"time_change": "2025-10-06 13:30:00"
39+
"domain": "bz",
40+
"full_url": "https://streamingcommunityz.bz/",
41+
"old_domain": "it",
42+
"time_change": "2025-10-16 15:22:19"
4343
},
4444
"altadefinizionegratis": {
4545
"domain": "ist",

StreamingCommunity/Api/Site/altadefinizione/film.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# Variable
3232
console = Console()
3333
max_timeout = config_manager.get_int("REQUESTS", "timeout")
34+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
3435

3536

3637
def download_film(select_title: MediaItem) -> str:
@@ -92,8 +93,8 @@ def download_film(select_title: MediaItem) -> str:
9293
master_playlist = video_source.get_playlist()
9394

9495
# Define the filename and path for the downloaded film
95-
title_name = os_manager.get_sanitize_file(select_title.name) + ".mp4"
96-
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))
96+
title_name = os_manager.get_sanitize_file(select_title.name) + extension_output
97+
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(extension_output, ""))
9798

9899
# Download the film using the m3u8 playlist, and output filename
99100
hls_process = HLS_Downloader(

StreamingCommunity/Api/Site/crunchyroll/film.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
# Variable
2828
console = Console()
2929
max_timeout = config_manager.get_int("REQUESTS", "timeout")
30+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
3031

3132

3233
def download_film(select_title: MediaItem) -> str:
@@ -49,8 +50,8 @@ def download_film(select_title: MediaItem) -> str:
4950
return None, True
5051

5152
# Define filename and path for the downloaded video
52-
mp4_name = os_manager.get_sanitize_file(select_title.name) + ".mp4"
53-
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, mp4_name.replace(".mp4", ""))
53+
mp4_name = os_manager.get_sanitize_file(select_title.name) + extension_output
54+
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, mp4_name.replace(extension_output, ""))
5455

5556
# Generate mpd and license URLs
5657
url_id = select_title.get('url').split('/')[-1]

StreamingCommunity/Api/Site/mediasetinfinity/film.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010

1111
# Internal utilities
12+
from StreamingCommunity.Util.config_json import config_manager
1213
from StreamingCommunity.Util.os import os_manager, get_wvd_path
1314
from StreamingCommunity.Util.message import start_message
1415
from StreamingCommunity.Util.headers import get_headers
@@ -27,6 +28,7 @@
2728

2829
# Variable
2930
console = Console()
31+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
3032

3133

3234
def download_film(select_title: MediaItem) -> Tuple[str, bool]:
@@ -43,17 +45,17 @@ def download_film(select_title: MediaItem) -> Tuple[str, bool]:
4345
console.print(f"\n[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{select_title.name}[/cyan] \n")
4446

4547
# Define the filename and path for the downloaded film
46-
title_name = os_manager.get_sanitize_file(select_title.name) + ".mp4"
47-
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))
48+
title_name = os_manager.get_sanitize_file(select_title.name) + extension_output
49+
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(extension_output, ""))
4850

4951
# Generate mpd and license URLs
5052
bearer = get_bearer_token()
5153

52-
playback_json = get_playback_url(bearer, select_title.id)
53-
tracking_info = get_tracking_info(bearer, playback_json)[0]
54+
playback_json = get_playback_url(select_title.id)
55+
tracking_info = get_tracking_info(playback_json)['videos'][0]
5456

55-
license_url = generate_license_url(bearer, tracking_info)
56-
mpd_url = get_manifest(tracking_info['video_src'])
57+
license_url = generate_license_url(tracking_info)
58+
mpd_url = get_manifest(tracking_info['url'])
5759

5860
# Download the episode
5961
dash_process = DASH_Downloader(

StreamingCommunity/Api/Site/raiplay/film.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
# Internal utilities
1313
from StreamingCommunity.Util.os import os_manager
14+
from StreamingCommunity.Util.config_json import config_manager
1415
from StreamingCommunity.Util.headers import get_headers
15-
from StreamingCommunity.Util.os import get_wvd_path
1616
from StreamingCommunity.Util.message import start_message
17-
17+
from StreamingCommunity.Util.os import get_wvd_path
1818

1919
# Logic class
2020
from .util.get_license import generate_license_url
@@ -29,6 +29,7 @@
2929

3030
# Variable
3131
console = Console()
32+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
3233

3334

3435
def download_film(select_title: MediaItem) -> Tuple[str, bool]:
@@ -51,8 +52,8 @@ def download_film(select_title: MediaItem) -> Tuple[str, bool]:
5152
master_playlist = VideoSource.extract_m3u8_url(first_item_path)
5253

5354
# Define the filename and path for the downloaded film
54-
mp4_name = os_manager.get_sanitize_file(select_title.name) + ".mp4"
55-
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, mp4_name.replace(".mp4", ""))
55+
mp4_name = os_manager.get_sanitize_file(select_title.name) + extension_output
56+
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, mp4_name.replace(extension_output, ""))
5657

5758
# HLS
5859
if ".mpd" not in master_playlist:

StreamingCommunity/Api/Site/streamingcommunity/film.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
# Internal utilities
1111
from StreamingCommunity.Util.os import os_manager
12+
from StreamingCommunity.Util.config_json import config_manager
1213
from StreamingCommunity.Util.message import start_message
1314
from StreamingCommunity.TelegramHelp.telegram_bot import TelegramSession, get_bot_instance
1415

@@ -25,6 +26,7 @@
2526

2627
# Variable
2728
console = Console()
29+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
2830

2931

3032
def download_film(select_title: MediaItem) -> str:
@@ -67,8 +69,8 @@ def download_film(select_title: MediaItem) -> str:
6769
return None
6870

6971
# Define the filename and path for the downloaded film
70-
title_name = os_manager.get_sanitize_file(select_title.name) + ".mp4"
71-
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))
72+
title_name = os_manager.get_sanitize_file(select_title.name) + extension_output
73+
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(extension_output, ""))
7274

7375
# Download the film using the m3u8 playlist, and output filename
7476
hls_process = HLS_Downloader(

StreamingCommunity/Api/Site/streamingwatch/film.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
# Internal utilities
1111
from StreamingCommunity.Util.os import os_manager
12+
from StreamingCommunity.Util.config_json import config_manager
1213
from StreamingCommunity.Util.message import start_message
1314

1415

@@ -24,6 +25,7 @@
2425

2526
# Variable
2627
console = Console()
28+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
2729

2830

2931
def download_film(select_title: MediaItem) -> str:
@@ -45,8 +47,8 @@ def download_film(select_title: MediaItem) -> str:
4547
master_playlist = video_source.get_m3u8_url(select_title.url)
4648

4749
# Define the filename and path for the downloaded film
48-
title_name = os_manager.get_sanitize_file(select_title.name) + ".mp4"
49-
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))
50+
title_name = os_manager.get_sanitize_file(select_title.name) + extension_output
51+
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(extension_output, ""))
5052

5153
# Download the film using the m3u8 playlist, and output filename
5254
hls_process = HLS_Downloader(

StreamingCommunity/Lib/Downloader/DASH/decrypt.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,30 @@
33
import os
44
import subprocess
55
import logging
6+
import threading
7+
import time
68

79

810
# External libraries
911
from rich.console import Console
12+
from tqdm import tqdm
1013

1114

1215
# Internal utilities
1316
from StreamingCommunity.Util.os import get_mp4decrypt_path
17+
from StreamingCommunity.Util.color import Colors
1418

1519
# Variable
1620
console = Console()
1721

1822

1923
# NOTE!: SAREBBE MEGLIO FARLO PER OGNI FILE DURANTE IL DOWNLOAD ... MA PER ORA LO LASCIO COSI
20-
def decrypt_with_mp4decrypt(encrypted_path, kid, key, output_path=None, cleanup=True):
24+
def decrypt_with_mp4decrypt(type, encrypted_path, kid, key, output_path=None, cleanup=True):
2125
"""
2226
Decrypt an mp4/m4s file using mp4decrypt.
2327
2428
Args:
29+
type (str): Type of file ('video' or 'audio').
2530
encrypted_path (str): Path to encrypted file.
2631
kid (str): Hexadecimal KID.
2732
key (str): Hexadecimal key.
@@ -48,15 +53,63 @@ def decrypt_with_mp4decrypt(encrypted_path, kid, key, output_path=None, cleanup=
4853
if not output_path:
4954
output_path = os.path.splitext(encrypted_path)[0] + "_decrypted.mp4"
5055

56+
# Get file size for progress tracking
57+
file_size = os.path.getsize(encrypted_path)
58+
5159
key_format = f"{kid.lower()}:{key.lower()}"
5260
cmd = [get_mp4decrypt_path(), "--key", key_format, encrypted_path, output_path]
5361
logging.info(f"Running command: {' '.join(cmd)}")
5462

63+
# Create progress bar with custom format
64+
bar_format = (
65+
f"{Colors.YELLOW}DECRYPT{Colors.CYAN} {type}{Colors.WHITE}: "
66+
f"{Colors.MAGENTA}{{bar:40}} "
67+
f"{Colors.LIGHT_GREEN}{{n_fmt}}{Colors.WHITE}/{Colors.CYAN}{{total_fmt}} "
68+
f"{Colors.DARK_GRAY}[{Colors.YELLOW}{{elapsed}}{Colors.WHITE} < {Colors.CYAN}{{remaining}}{Colors.DARK_GRAY}] "
69+
f"{Colors.WHITE}{{postfix}}"
70+
)
71+
72+
progress_bar = tqdm(
73+
total=100,
74+
bar_format=bar_format,
75+
unit="",
76+
ncols=150
77+
)
78+
79+
def monitor_output_file():
80+
"""Monitor output file growth and update progress bar."""
81+
last_size = 0
82+
while True:
83+
if os.path.exists(output_path):
84+
current_size = os.path.getsize(output_path)
85+
if current_size > 0:
86+
progress_percent = min(int((current_size / file_size) * 100), 100)
87+
progress_bar.n = progress_percent
88+
progress_bar.refresh()
89+
90+
if current_size == last_size and current_size > 0:
91+
# File stopped growing, likely finished
92+
break
93+
94+
last_size = current_size
95+
96+
time.sleep(0.1)
97+
98+
# Start monitoring thread
99+
monitor_thread = threading.Thread(target=monitor_output_file, daemon=True)
100+
monitor_thread.start()
101+
55102
try:
56103
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
57104
except Exception as e:
105+
progress_bar.close()
58106
console.print(f"[bold red] mp4decrypt execution failed: {e}[/bold red]")
59107
return None
108+
109+
# Ensure progress bar reaches 100%
110+
progress_bar.n = 100
111+
progress_bar.refresh()
112+
progress_bar.close()
60113

61114
if result.returncode == 0 and os.path.exists(output_path):
62115

0 commit comments

Comments
 (0)