Skip to content

Commit 4aaa929

Browse files
committed
Fix Jellyfin undefined subtitle
1 parent c68658c commit 4aaa929

File tree

14 files changed

+51
-80
lines changed

14 files changed

+51
-80
lines changed

StreamingCommunity/Api/Site/altadefinizione/series.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# Internal utilities
1313
from StreamingCommunity.Util.message import start_message
14+
from StreamingCommunity.Util.config_json import config_manager
1415
from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance, TelegramSession
1516

1617

@@ -36,6 +37,7 @@
3637
# Variable
3738
msg = Prompt()
3839
console = Console()
40+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
3941

4042

4143
def download_video(index_season_selected: int, index_episode_selected: int, scrape_serie: GetSerieInfo) -> Tuple[str,bool]:
@@ -73,7 +75,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
7375
TelegramSession.updateScriptId(script_id, f"{scrape_serie.series_name} - S{index_season_selected} - E{index_episode_selected} - {obj_episode.name}")
7476

7577
# Define filename and path for the downloaded video
76-
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.name)}.mp4"
78+
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.name)}.{extension_output}"
7779
mp4_path = os.path.join(site_constant.SERIES_FOLDER, scrape_serie.series_name, f"S{index_season_selected}")
7880

7981
# Retrieve scws and if available master playlist

StreamingCommunity/Api/Site/crunchyroll/series.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# Internal utilities
1414
from StreamingCommunity.Util.message import start_message
1515
from StreamingCommunity.Util.os import os_manager
16+
from StreamingCommunity.Util.config_json import config_manager
1617

1718

1819
# Logic class
@@ -37,6 +38,7 @@
3738
# Variable
3839
msg = Prompt()
3940
console = Console()
41+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
4042

4143

4244
def download_video(index_season_selected: int, index_episode_selected: int, scrape_serie: GetSerieInfo) -> Tuple[str,bool]:
@@ -61,7 +63,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
6163
console.print(f"\n[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{scrape_serie.series_name}[/cyan] \\ [bold magenta]{obj_episode.get('name')}[/bold magenta] ([cyan]S{index_season_selected}E{index_episode_selected}[/cyan]) \n")
6264

6365
# Define filename and path for the downloaded video
64-
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.get('name'))}.mp4"
66+
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.get('name'))}.{extension_output}"
6567
mp4_path = os_manager.get_sanitize_path(os.path.join(site_constant.SERIES_FOLDER, scrape_serie.series_name, f"S{index_season_selected}"))
6668

6769
# Generate mpd and license URLs

StreamingCommunity/Api/Site/guardaserie/series.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# Internal utilities
1313
from StreamingCommunity.Util.message import start_message
14+
from StreamingCommunity.Util.config_json import config_manager
1415

1516

1617
# Logic class
@@ -36,6 +37,7 @@
3637
# Variable
3738
msg = Prompt()
3839
console = Console()
40+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
3941

4042

4143
def download_video(index_season_selected: int, index_episode_selected: int, scape_info_serie: GetSerieInfo) -> Tuple[str,bool]:
@@ -59,7 +61,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scap
5961
console.print(f"\n[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{scape_info_serie.tv_name}[/cyan] \\ [bold magenta]{obj_episode.get('name')}[/bold magenta] ([cyan]S{index_season_selected}E{index_episode_selected}[/cyan]) \n")
6062

6163
# Define filename and path for the downloaded video
62-
mp4_name = f"{map_episode_title(scape_info_serie.tv_name, index_season_selected, index_episode_selected, obj_episode.get('name'))}.mp4"
64+
mp4_name = f"{map_episode_title(scape_info_serie.tv_name, index_season_selected, index_episode_selected, obj_episode.get('name'))}.{extension_output}"
6365
mp4_path = os.path.join(site_constant.SERIES_FOLDER, scape_info_serie.tv_name, f"S{index_season_selected}")
6466

6567
# Setup video source

StreamingCommunity/Api/Site/mediasetinfinity/series.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
# Internal utilities
13+
from StreamingCommunity.Util.config_json import config_manager
1314
from StreamingCommunity.Util.headers import get_headers
1415
from StreamingCommunity.Util.message import start_message
1516
from StreamingCommunity.Util.os import os_manager
@@ -38,6 +39,7 @@
3839
# Variable
3940
msg = Prompt()
4041
console = Console()
42+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
4143

4244

4345
def download_video(index_season_selected: int, index_episode_selected: int, scrape_serie: GetSerieInfo) -> Tuple[str,bool]:
@@ -60,7 +62,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
6062
console.print(f"\n[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{scrape_serie.series_name}[/cyan] \\ [bold magenta]{obj_episode.name}[/bold magenta] ([cyan]S{index_season_selected}E{index_episode_selected}[/cyan]) \n")
6163

6264
# Define filename and path for the downloaded video
63-
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.name)}.mp4"
65+
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.name)}.{extension_output}"
6466
mp4_path = os_manager.get_sanitize_path(os.path.join(site_constant.SERIES_FOLDER, scrape_serie.series_name, f"S{index_season_selected}"))
6567

6668
# Generate mpd and license URLs

StreamingCommunity/Api/Site/mediasetinfinity/util/get_license.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def get_playback_url(CONTENT_ID):
134134
return playback_json
135135

136136
except Exception as e:
137-
raise RuntimeError(f"Failed to get playback URL: {e}")
137+
raise RuntimeError(f"Failed to get playback URL: {e}, {resp_json if 'resp_json' in locals() else 'No response'}")
138138

139139
def parse_smil_for_media_info(smil_xml):
140140
"""

StreamingCommunity/Api/Site/raiplay/series.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
# Internal utilities
13+
from StreamingCommunity.Util.config_json import config_manager
1314
from StreamingCommunity.Util.headers import get_headers, get_userAgent
1415
from StreamingCommunity.Util.message import start_message
1516

@@ -38,6 +39,7 @@
3839
# Variable
3940
msg = Prompt()
4041
console = Console()
42+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
4143

4244

4345
def download_video(index_season_selected: int, index_episode_selected: int, scrape_serie: GetSerieInfo) -> Tuple[str,bool]:
@@ -60,7 +62,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
6062
console.print(f"\n[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{scrape_serie.series_name}[/cyan] \\ [bold magenta]{obj_episode.name}[/bold magenta] ([cyan]S{index_season_selected}E{index_episode_selected}[/cyan]) \n")
6163

6264
# Define filename and path
63-
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.name)}.mp4"
65+
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.name)}.{extension_output}"
6466
mp4_path = os.path.join(site_constant.SERIES_FOLDER, scrape_serie.series_name, f"S{index_season_selected}")
6567

6668
# Get streaming URL

StreamingCommunity/Api/Site/streamingcommunity/series.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# Internal utilities
1313
from StreamingCommunity.Util.message import start_message
14+
from StreamingCommunity.Util.config_json import config_manager
1415
from StreamingCommunity.TelegramHelp.telegram_bot import TelegramSession, get_bot_instance
1516

1617

@@ -36,6 +37,7 @@
3637
# Variable
3738
msg = Prompt()
3839
console = Console()
40+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
3941

4042

4143
def download_video(index_season_selected: int, index_episode_selected: int, scrape_serie: GetSerieInfo, video_source: VideoSource) -> Tuple[str,bool]:
@@ -73,7 +75,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
7375
TelegramSession.updateScriptId(script_id, f"{scrape_serie.series_name} - S{index_season_selected} - E{index_episode_selected} - {obj_episode.name}")
7476

7577
# Define filename and path for the downloaded video
76-
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.name)}.mp4"
78+
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.name)}.{extension_output}"
7779
mp4_path = os.path.join(site_constant.SERIES_FOLDER, scrape_serie.series_name, f"S{index_season_selected}")
7880

7981
# Retrieve scws and if available master playlist

StreamingCommunity/Api/Site/streamingwatch/series.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# Internal utilities
1313
from StreamingCommunity.Util.message import start_message
14+
from StreamingCommunity.Util.config_json import config_manager
1415
from StreamingCommunity.Lib.Downloader import HLS_Downloader
1516

1617

@@ -35,6 +36,7 @@
3536
# Variable
3637
msg = Prompt()
3738
console = Console()
39+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
3840

3941

4042
def download_video(index_season_selected: int, index_episode_selected: int, scrape_serie: GetSerieInfo) -> Tuple[str,bool]:
@@ -57,7 +59,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
5759
console.print(f"\n[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{scrape_serie.series_name}[/cyan] \\ [bold magenta]{obj_episode.name}[/bold magenta] ([cyan]S{index_season_selected}E{index_episode_selected}[/cyan]) \n")
5860

5961
# Define filename and path for the downloaded video
60-
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.name)}.mp4"
62+
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.name)}.{extension_output}"
6163
mp4_path = os.path.join(site_constant.SERIES_FOLDER, scrape_serie.series_name, f"S{index_season_selected}")
6264

6365
# Retrieve scws and if available master playlist

StreamingCommunity/Lib/Downloader/DASH/decrypt.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313

1414

1515
# Internal utilities
16+
from StreamingCommunity.Util.config_json import config_manager
1617
from StreamingCommunity.Util.os import get_mp4decrypt_path
1718
from StreamingCommunity.Util.color import Colors
1819

20+
1921
# Variable
2022
console = Console()
23+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
2124

2225

23-
# NOTE!: SAREBBE MEGLIO FARLO PER OGNI FILE DURANTE IL DOWNLOAD ... MA PER ORA LO LASCIO COSI
2426
def decrypt_with_mp4decrypt(type, encrypted_path, kid, key, output_path=None, cleanup=True):
2527
"""
2628
Decrypt an mp4/m4s file using mp4decrypt.
@@ -51,7 +53,7 @@ def decrypt_with_mp4decrypt(type, encrypted_path, kid, key, output_path=None, cl
5153
return None
5254

5355
if not output_path:
54-
output_path = os.path.splitext(encrypted_path)[0] + "_decrypted.mp4"
56+
output_path = os.path.splitext(encrypted_path)[0] + f"_decrypted.{extension_output}"
5557

5658
# Get file size for progress tracking
5759
file_size = os.path.getsize(encrypted_path)
@@ -118,7 +120,7 @@ def monitor_output_file():
118120
if os.path.exists(encrypted_path):
119121
os.remove(encrypted_path)
120122

121-
temp_dec = os.path.splitext(encrypted_path)[0] + "_decrypted.mp4"
123+
temp_dec = os.path.splitext(encrypted_path)[0] + f"_decrypted.{extension_output}"
122124

123125
# Do not delete the final output!
124126
if temp_dec != output_path and os.path.exists(temp_dec):

StreamingCommunity/Lib/Downloader/DASH/downloader.py

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

4242
# Variable
4343
console = Console()
44+
extension_output = config_manager.get("M3U8_CONVERSION", "extension")
4445

4546

4647
class DASH_Downloader:
@@ -303,7 +304,7 @@ def download_and_decrypt(self, custom_headers=None, custom_payload=None):
303304
self.current_download_type = None
304305

305306
# Decrypt video
306-
decrypted_path = os.path.join(self.decrypted_dir, "video.mp4")
307+
decrypted_path = os.path.join(self.decrypted_dir, f"video.{extension_output}")
307308
result_path = decrypt_with_mp4decrypt(
308309
"Video", encrypted_path, KID, KEY, output_path=decrypted_path
309310
)
@@ -360,7 +361,7 @@ def download_and_decrypt(self, custom_headers=None, custom_payload=None):
360361
self.current_download_type = None
361362

362363
# Decrypt audio
363-
decrypted_path = os.path.join(self.decrypted_dir, "audio.mp4")
364+
decrypted_path = os.path.join(self.decrypted_dir, f"audio.{extension_output}")
364365
result_path = decrypt_with_mp4decrypt(
365366
f"Audio {audio_language}", encrypted_path, KID, KEY, output_path=decrypted_path
366367
)
@@ -436,7 +437,7 @@ def download_segments(self, clear=False):
436437
self.current_download_type = None
437438

438439
# NO DECRYPTION: just copy/move to decrypted folder
439-
decrypted_path = os.path.join(self.decrypted_dir, "video.mp4")
440+
decrypted_path = os.path.join(self.decrypted_dir, f"video.{extension_output}")
440441
if os.path.exists(encrypted_path) and not os.path.exists(decrypted_path):
441442
shutil.copy2(encrypted_path, decrypted_path)
442443

@@ -488,7 +489,7 @@ def download_segments(self, clear=False):
488489
self.current_download_type = None
489490

490491
# NO DECRYPTION: just copy/move to decrypted folder
491-
decrypted_path = os.path.join(self.decrypted_dir, "audio.mp4")
492+
decrypted_path = os.path.join(self.decrypted_dir, f"audio.{extension_output}")
492493
if os.path.exists(encrypted_path) and not os.path.exists(decrypted_path):
493494
shutil.copy2(encrypted_path, decrypted_path)
494495

@@ -509,8 +510,8 @@ def finalize_output(self):
509510
return output_file
510511

511512
# Definition of decrypted files
512-
video_file = os.path.join(self.decrypted_dir, "video.mp4")
513-
audio_file = os.path.join(self.decrypted_dir, "audio.mp4")
513+
video_file = os.path.join(self.decrypted_dir, f"video.{extension_output}")
514+
audio_file = os.path.join(self.decrypted_dir, f"audio.{extension_output}")
514515
output_file = self.original_output_path
515516

516517
# Set the output file path for status tracking
@@ -548,7 +549,7 @@ def finalize_output(self):
548549
if existing_sub_tracks:
549550

550551
# Create temporary file for subtitle merge
551-
temp_output = output_file.replace('.mp4', '_temp.mp4')
552+
temp_output = output_file.replace(f'.{extension_output}', f'_temp.{extension_output}')
552553

553554
try:
554555
final_file = join_subtitle(

0 commit comments

Comments
 (0)