mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 20:15:24 +00:00
Added option to merge subtitles into one mp4 file or separate into .vtt files (#100)
This commit is contained in:
parent
eb6110e14f
commit
8e8c458024
@ -105,6 +105,7 @@ You can change some behaviors by tweaking the configuration file.
|
|||||||
| M3U8_OPTIONS | | Contains options specific to M3U8 file format. | |
|
| M3U8_OPTIONS | | Contains options specific to M3U8 file format. | |
|
||||||
| download_audio | true | Indicates whether audio files should be downloaded or not. | false |
|
| download_audio | true | Indicates whether audio files should be downloaded or not. | false |
|
||||||
| download_subtitles | true | Indicates whether subtitles should be downloaded or not. | false |
|
| download_subtitles | true | Indicates whether subtitles should be downloaded or not. | false |
|
||||||
|
| merge_subtitles | true | Indicates if you want to merge subs in mp4 file or separate files .vtt| false |
|
||||||
| specific_list_audio | ["ita"] | A list of specific audio languages to download. | ["eng", "fra"] |
|
| specific_list_audio | ["ita"] | A list of specific audio languages to download. | ["eng", "fra"] |
|
||||||
| specific_list_subtitles | ["eng"] | A list of specific subtitle languages to download. | ["spa", "por"] |
|
| specific_list_subtitles | ["eng"] | A list of specific subtitle languages to download. | ["spa", "por"] |
|
||||||
|map_episode_name |%(tv_name)_S%(season)E%(episode)_%(episode_name)| Mapping to choose the name of all episode of TV Show (see [Episode Name Usage](#Episode-name-usage)).
|
|map_episode_name |%(tv_name)_S%(season)E%(episode)_%(episode_name)| Mapping to choose the name of all episode of TV Show (see [Episode Name Usage](#Episode-name-usage)).
|
||||||
|
@ -54,6 +54,7 @@ DOWNLOAD_AUDIO = config_manager.get_bool('M3U8_OPTIONS', 'download_audio')
|
|||||||
DOWNLOAD_SUBTITLES = config_manager.get_bool('M3U8_OPTIONS', 'download_subtitles')
|
DOWNLOAD_SUBTITLES = config_manager.get_bool('M3U8_OPTIONS', 'download_subtitles')
|
||||||
DOWNLOAD_SPECIFIC_AUDIO = config_manager.get_list('M3U8_OPTIONS', 'specific_list_audio')
|
DOWNLOAD_SPECIFIC_AUDIO = config_manager.get_list('M3U8_OPTIONS', 'specific_list_audio')
|
||||||
DOWNLOAD_SPECIFIC_SUBTITLE = config_manager.get_list('M3U8_OPTIONS', 'specific_list_subtitles')
|
DOWNLOAD_SPECIFIC_SUBTITLE = config_manager.get_list('M3U8_OPTIONS', 'specific_list_subtitles')
|
||||||
|
MERGE_SUBTITLES = config_manager.get_bool('M3U8_OPTIONS', 'merge_subtitles')
|
||||||
TQDM_MAX_WORKER = config_manager.get_int('M3U8', 'tdqm_workers')
|
TQDM_MAX_WORKER = config_manager.get_int('M3U8', 'tdqm_workers')
|
||||||
TQDM_PROGRESS_TIMEOUT = config_manager.get_int('M3U8', 'tqdm_progress_timeout')
|
TQDM_PROGRESS_TIMEOUT = config_manager.get_int('M3U8', 'tqdm_progress_timeout')
|
||||||
COMPLETED_PERCENTAGE = config_manager.get_float('M3U8', 'download_percentage')
|
COMPLETED_PERCENTAGE = config_manager.get_float('M3U8', 'download_percentage')
|
||||||
@ -823,19 +824,33 @@ class Downloader():
|
|||||||
|
|
||||||
# Check if there are any downloaded subtitles
|
# Check if there are any downloaded subtitles
|
||||||
if len(self.downloaded_subtitle) > 0:
|
if len(self.downloaded_subtitle) > 0:
|
||||||
# Log adding subtitles
|
if MERGE_SUBTITLES:
|
||||||
console.log(f"[cyan]Add subtitles.")
|
# Log adding subtitles
|
||||||
|
console.log(f"[cyan]Add subtitles.")
|
||||||
|
|
||||||
# If no audio tracks were joined, use the original video path
|
# If no audio tracks were joined, use the original video path
|
||||||
if path_video_and_audio is None:
|
if path_video_and_audio is None:
|
||||||
path_video_and_audio = self.video_track_path
|
path_video_and_audio = self.video_track_path
|
||||||
|
|
||||||
# Transcode video with subtitles
|
# Transcode video with subtitles
|
||||||
path_join_subtitles = transcode_with_subtitles(
|
path_join_subtitles = transcode_with_subtitles(
|
||||||
path_video_and_audio,
|
path_video_and_audio,
|
||||||
self.downloaded_subtitle,
|
self.downloaded_subtitle,
|
||||||
os.path.join(self.base_path, "out.mkv")
|
os.path.join(self.base_path, "out.mkv")
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
console.log("[cyan]Moving subtitle out of tmp folder.")
|
||||||
|
for obj_sub in self.downloaded_subtitle:
|
||||||
|
try:
|
||||||
|
language = obj_sub.get('language').lower()
|
||||||
|
|
||||||
|
# Modifica la stringa se contiene "forced-", altrimenti la converte in minuscolo
|
||||||
|
language = (language.replace("forced-", "") + ".forced") if 'forced-' in language else language
|
||||||
|
sub_path = self.output_filename.replace(".mp4", f".{language}.vtt")
|
||||||
|
os.rename(obj_sub.get('path'), sub_path)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"Error moving subtitle: {e}. Skipping...")
|
||||||
|
continue
|
||||||
|
|
||||||
self.path_video_and_audio = path_video_and_audio
|
self.path_video_and_audio = path_video_and_audio
|
||||||
self.path_join_subtitles = path_join_subtitles
|
self.path_join_subtitles = path_join_subtitles
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
"M3U8_OPTIONS": {
|
"M3U8_OPTIONS": {
|
||||||
"download_audio": true,
|
"download_audio": true,
|
||||||
"download_subtitles": true,
|
"download_subtitles": true,
|
||||||
|
"merge_subtitles": true,
|
||||||
"specific_list_audio": [
|
"specific_list_audio": [
|
||||||
"ita"
|
"ita"
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user