mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
fix download subtitle se il file vtt contiene un url
This commit is contained in:
parent
335d97ec2d
commit
0160868709
@ -279,16 +279,33 @@ class DownloadManager:
|
|||||||
return self.stopped
|
return self.stopped
|
||||||
|
|
||||||
def download_subtitle(self, sub: Dict):
|
def download_subtitle(self, sub: Dict):
|
||||||
"""Downloads and saves subtitle file for a specific language."""
|
"""Downloads and saves the actual subtitle file or keeps the original format if no external file is needed."""
|
||||||
if self.stopped:
|
if self.stopped:
|
||||||
return True
|
return True
|
||||||
|
# Scarica il contenuto della playlist M3U8 o del file VTT
|
||||||
content = self.client.request(sub['uri'])
|
content = self.client.request(sub['uri'])
|
||||||
if content:
|
if not content:
|
||||||
|
return self.stopped
|
||||||
|
vtt_url = None
|
||||||
|
for line in content.splitlines():
|
||||||
|
if line.startswith("http"): # Trova la prima URL nel file .m3u8
|
||||||
|
vtt_url = line.strip()
|
||||||
|
break
|
||||||
sub_path = os.path.join(self.temp_dir, 'subs', f"{sub['language']}.vtt")
|
sub_path = os.path.join(self.temp_dir, 'subs', f"{sub['language']}.vtt")
|
||||||
|
if vtt_url:
|
||||||
|
# Scarica il vero file VTT se esiste un URL nel file .m3u8
|
||||||
|
vtt_content = self.client.request(vtt_url)
|
||||||
|
if vtt_content:
|
||||||
|
with open(sub_path, 'w', encoding='utf-8') as f:
|
||||||
|
f.write(vtt_content)
|
||||||
|
print(f"Sottotitoli scaricati: {sub_path}")
|
||||||
|
else:
|
||||||
|
print(f"Errore nel download dei sottotitoli da {vtt_url}")
|
||||||
|
else:
|
||||||
|
# Se non c'è un URL, salva il contenuto direttamente
|
||||||
with open(sub_path, 'w', encoding='utf-8') as f:
|
with open(sub_path, 'w', encoding='utf-8') as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
print(f"Sottotitoli salvati direttamente: {sub_path}")
|
||||||
return self.stopped
|
return self.stopped
|
||||||
|
|
||||||
def download_all(self, video_url: str, audio_streams: List[Dict], sub_streams: List[Dict]):
|
def download_all(self, video_url: str, audio_streams: List[Dict], sub_streams: List[Dict]):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user