mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-06 19:45:24 +00:00
fix bug m3u8 url
This commit is contained in:
parent
beb015685f
commit
11a4120124
@ -1,9 +1,9 @@
|
||||
# 3.12.23 -> 10.12.23
|
||||
|
||||
# Class import
|
||||
from Stream.util.headers import get_headers
|
||||
from Stream.util.m3u8 import dw_m3u8
|
||||
from Stream.util.util import convert_utf8_name
|
||||
from Src.Util.Helper.headers import get_headers
|
||||
from Src.Util.Helper.util import convert_utf8_name
|
||||
from Src.Util.m3u8 import dw_m3u8
|
||||
|
||||
# General import
|
||||
import requests, os, re, json
|
@ -1,8 +1,8 @@
|
||||
# 10.12.23
|
||||
|
||||
# Class import
|
||||
from Stream.util.headers import get_headers
|
||||
from Stream.util.console import console
|
||||
from Src.Util.Helper.headers import get_headers
|
||||
from Src.Util.Helper.console import console
|
||||
|
||||
# General import
|
||||
import requests, json, sys
|
@ -1,10 +1,10 @@
|
||||
# 3.12.23 -> 10.12.23
|
||||
|
||||
# Class import
|
||||
from Stream.util.headers import get_headers
|
||||
from Stream.util.console import console, msg
|
||||
from Stream.util.m3u8 import dw_m3u8, join_audio_to_video
|
||||
from Stream.util.util import convert_utf8_name
|
||||
from Src.Util.Helper.headers import get_headers
|
||||
from Src.Util.Helper.util import convert_utf8_name
|
||||
from Src.Util.Helper.console import console, msg
|
||||
from Src.Util.m3u8 import dw_m3u8
|
||||
|
||||
# General import
|
||||
import requests, os, re, json
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 7.1 MiB After Width: | Height: | Size: 7.1 MiB |
@ -1,5 +1,5 @@
|
||||
__title__ = 'Streaming_community'
|
||||
__version__ = 'v0.7.1'
|
||||
__version__ = 'v0.7.0'
|
||||
__author__ = 'Ghost6446'
|
||||
__description__ = 'A command-line program to download film'
|
||||
__license__ = 'MIT License'
|
@ -1,7 +1,7 @@
|
||||
# 13.09.2023
|
||||
|
||||
# General import
|
||||
from Stream.util.console import console
|
||||
from Src.Util.Helper.console import console
|
||||
import os, requests, time
|
||||
|
||||
# Variable
|
@ -4,7 +4,6 @@
|
||||
from random_user_agent.user_agent import UserAgent
|
||||
from random_user_agent.params import SoftwareName, OperatingSystem
|
||||
|
||||
# [func]
|
||||
def get_headers():
|
||||
software_names = [SoftwareName.CHROME.value]
|
||||
operating_systems = [OperatingSystem.WINDOWS.value, OperatingSystem.LINUX.value]
|
@ -1,9 +1,8 @@
|
||||
# 3.12.23
|
||||
|
||||
# Import
|
||||
from Stream.util.console import console
|
||||
from Src.Util.Helper.console import console
|
||||
|
||||
# [Function]
|
||||
def msg_start():
|
||||
|
||||
msg = """
|
||||
@ -15,6 +14,6 @@ def msg_start():
|
||||
|_____/ \__|_| \___|\__,_|_| |_| |_|_|_| |_|\__, | \___\___/|_| |_| |_|\__,_|_| |_|_|\__|\__, |
|
||||
__/ | __/ |
|
||||
|___/ |___/
|
||||
"""
|
||||
"""
|
||||
|
||||
console.log(f"[purple]{msg}")
|
||||
console.print(f"[purple]{msg}")
|
@ -1,7 +1,7 @@
|
||||
# 4.01.2023
|
||||
|
||||
# Import
|
||||
import ffmpeg, subprocess
|
||||
import ffmpeg
|
||||
|
||||
def convert_utf8_name(name):
|
||||
return str(name).encode('utf-8').decode('latin-1')
|
||||
@ -12,20 +12,6 @@ def there_is_audio(ts_file_path):
|
||||
|
||||
|
||||
def merge_ts_files(video_path, audio_path, output_path):
|
||||
|
||||
"""command = [
|
||||
'ffmpeg',
|
||||
'-i', video_path,
|
||||
'-i', audio_path,
|
||||
'-c', 'copy',
|
||||
'-map', '0',
|
||||
'-map', '1',
|
||||
'-y', output_path
|
||||
]
|
||||
|
||||
subprocess.run(command)"""
|
||||
|
||||
input_video = ffmpeg.input(video_path)
|
||||
input_audio = ffmpeg.input(audio_path)
|
||||
|
||||
ffmpeg.output(input_video, input_audio, output_path, format='mpegts', acodec='copy', vcodec='copy', loglevel='quiet').run()
|
@ -1,7 +1,7 @@
|
||||
# 5.01.24
|
||||
# 5.01.24 -> 7.01.24
|
||||
|
||||
# Import
|
||||
import requests, re, os, ffmpeg, shutil, time
|
||||
import requests, re, os, ffmpeg, shutil, time, sys
|
||||
from tqdm.rich import tqdm
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||
@ -9,9 +9,10 @@ from cryptography.hazmat.backends import default_backend
|
||||
import moviepy.editor as mp
|
||||
|
||||
# Class import
|
||||
from Stream.util.console import console
|
||||
from Stream.util.headers import get_headers
|
||||
from Stream.util.util import there_is_audio, merge_ts_files
|
||||
from Src.Util.Helper.console import console
|
||||
from Src.Util.Helper.headers import get_headers
|
||||
from Src.Util.Helper.util import there_is_audio, merge_ts_files
|
||||
|
||||
|
||||
# Variable
|
||||
os.makedirs("videos", exist_ok=True)
|
||||
@ -66,10 +67,25 @@ class M3U8Downloader:
|
||||
ts_url = m3u8_base_url + ts_url
|
||||
|
||||
self.segments.append(ts_url)
|
||||
if self.m3u8_audio != None: self.segments_audio.append(m3u8_audio_line[i+1])
|
||||
|
||||
if self.m3u8_audio != None:
|
||||
self.segments_audio.append(m3u8_audio_line[i+1])
|
||||
|
||||
console.log(f"[cyan]Find: {len(self.segments)} ts file to download")
|
||||
|
||||
# Check video ts segment
|
||||
if len(self.segments) == 0:
|
||||
console.log("[red]No ts files to download")
|
||||
sys.exit(0)
|
||||
|
||||
# Check audio ts segment
|
||||
if self.m3u8_audio != None:
|
||||
console.log(f"[cyan]Find: {len(self.segments_audio)} ts audio file to download")
|
||||
|
||||
if len(self.segments_audio) == 0:
|
||||
console.log("[red]No ts audio files to download")
|
||||
sys.exit(0)
|
||||
|
||||
def download_m3u8(self):
|
||||
response = requests.get(self.m3u8_url, headers={'user-agent': get_headers()})
|
||||
|
||||
@ -77,18 +93,26 @@ class M3U8Downloader:
|
||||
m3u8_content = response.text
|
||||
self.parse_m3u8(m3u8_content)
|
||||
|
||||
# Check there is audio in first ts file
|
||||
path_test_ts_file = os.path.join(self.temp_folder, "ts_test.ts")
|
||||
if self.key and self.iv:
|
||||
open(path_test_ts_file, "wb").write(self.decrypt_ts(requests.get(self.segments[0]).content))
|
||||
else:
|
||||
open(path_test_ts_file, "wb").write(requests.get(self.segments[0]).content)
|
||||
console.log("[red]Wrong m3u8 url")
|
||||
sys.exit(0)
|
||||
|
||||
if not there_is_audio(path_test_ts_file):
|
||||
self.download_audio = True
|
||||
console.log("[cyan]=> Make req to get video and audio file")
|
||||
|
||||
os.remove(path_test_ts_file)
|
||||
if self.m3u8_audio != None:
|
||||
|
||||
# Check there is audio in first ts file
|
||||
path_test_ts_file = os.path.join(self.temp_folder, "ts_test.ts")
|
||||
if self.key and self.iv:
|
||||
open(path_test_ts_file, "wb").write(self.decrypt_ts(requests.get(self.segments[0]).content))
|
||||
else:
|
||||
open(path_test_ts_file, "wb").write(requests.get(self.segments[0]).content)
|
||||
|
||||
if not there_is_audio(path_test_ts_file):
|
||||
self.download_audio = True
|
||||
console.log("[cyan]=> Make req to get video and audio file")
|
||||
|
||||
console.log("[cyan]=> Download audio")
|
||||
os.remove(path_test_ts_file)
|
||||
|
||||
def decrypt_ts(self, encrypted_data):
|
||||
cipher = Cipher(algorithms.AES(self.key), modes.CBC(self.iv), backend=default_backend())
|
||||
@ -166,14 +190,15 @@ class M3U8Downloader:
|
||||
)
|
||||
console.log(f"[cyan]Clean ...")
|
||||
except ffmpeg.Error as e:
|
||||
print(f"Errore durante il salvataggio del file MP4: {e}")
|
||||
finally:
|
||||
time.sleep(2)
|
||||
os.remove(file_list_path)
|
||||
shutil.rmtree("tmp", ignore_errors=True)
|
||||
console.log(f"[red]Error saving MP4: {e.stdout}")
|
||||
sys.exit(0)
|
||||
|
||||
time.sleep(2)
|
||||
os.remove(file_list_path)
|
||||
shutil.rmtree("tmp", ignore_errors=True)
|
||||
|
||||
|
||||
# [ function ]
|
||||
# [ main function ]
|
||||
def dw_m3u8(url, audio_url=None, key=None, output_filename="output.mp4"):
|
||||
|
||||
downloader = M3U8Downloader(url, audio_url, key, output_filename)
|
12
run.py
12
run.py
@ -1,12 +1,12 @@
|
||||
# 10.12.23
|
||||
|
||||
# Class import
|
||||
import Stream.api.page as Page
|
||||
from Stream.util.message import msg_start
|
||||
from Stream.upload.update import main_update
|
||||
from Stream.util.console import console, msg
|
||||
from Stream.api.film import main_dw_film as download_film
|
||||
from Stream.api.tv import main_dw_tv as download_tv
|
||||
import Src.Api.page as Page
|
||||
from Src.Api.film import main_dw_film as download_film
|
||||
from Src.Api.tv import main_dw_tv as download_tv
|
||||
from Src.Util.Helper.message import msg_start
|
||||
from Src.Util.Helper.console import console, msg
|
||||
from Src.Upload.update import main_update
|
||||
|
||||
# General import
|
||||
import sys
|
||||
|
Loading…
x
Reference in New Issue
Block a user