mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
Fix some bug m3u8
This commit is contained in:
parent
7ce51745a0
commit
8c1baf929a
@ -139,13 +139,13 @@ class HLS_Downloader():
|
||||
str: The text content of the response.
|
||||
"""
|
||||
|
||||
if "http" not in url or "https" not in url:
|
||||
if "http" not in str(url).lower().strip() or "https" not in str(url).lower().strip():
|
||||
logging.error(f"Invalid url: {url}")
|
||||
sys.exit(0)
|
||||
|
||||
# Send a GET request to the provided URL
|
||||
logging.info(f"Test url: {url}")
|
||||
response = httpx.get(url, headers=headers_index)
|
||||
response = httpx.get(url, headers=headers_index, timeout=20)
|
||||
|
||||
try:
|
||||
response.raise_for_status()
|
||||
@ -268,7 +268,7 @@ class HLS_Downloader():
|
||||
|
||||
# Download the video segments
|
||||
self.expected_real_time = video_m3u8.expected_real_time
|
||||
list_available_resolution_size = self.main_obj_parser._video.get_list_resolution_and_size(video_m3u8.expected_real_time_s)
|
||||
#list_available_resolution_size = self.main_obj_parser._video.get_list_resolution_and_size(video_m3u8.expected_real_time_s)
|
||||
#console.print(f"[cyan]Estimate size [white]=> [red]{sorted(list_available_resolution_size, reverse=True)}")
|
||||
|
||||
video_m3u8.download_streams(f"{Colors.MAGENTA}video")
|
||||
@ -406,6 +406,10 @@ class HLS_Downloader():
|
||||
|
||||
if not os.path.exists(path_join_video):
|
||||
|
||||
# If codec not exist set to None
|
||||
if not hasattr(self, 'codec'):
|
||||
self.codec = None
|
||||
|
||||
# Join the video segments into a single video file
|
||||
join_video(
|
||||
video_path = self.downloaded_video[0].get('path'),
|
||||
@ -428,6 +432,10 @@ class HLS_Downloader():
|
||||
|
||||
if not os.path.exists(path_join_video_audio):
|
||||
|
||||
# If codec not exist set to None
|
||||
if not hasattr(self, 'codec'):
|
||||
self.codec = None
|
||||
|
||||
# Join the video with audio segments into a single video with audio file
|
||||
join_audios(
|
||||
video_path = self.downloaded_video[0].get('path'),
|
||||
|
@ -217,16 +217,16 @@ class M3U8_Segments:
|
||||
|
||||
with httpx.Client(proxies=proxy, verify=True) as client:
|
||||
if 'key_base_url' in self.__dict__:
|
||||
response = client.get(ts_url, headers=random_headers(self.key_base_url), timeout=REQUEST_TIMEOUT)
|
||||
response = client.get(ts_url, headers=random_headers(self.key_base_url), timeout=REQUEST_TIMEOUT, follow_redirects=True)
|
||||
else:
|
||||
response = client.get(ts_url, headers={'user-agent': get_headers()}, timeout=REQUEST_TIMEOUT)
|
||||
response = client.get(ts_url, headers={'user-agent': get_headers()}, timeout=REQUEST_TIMEOUT, follow_redirects=True)
|
||||
|
||||
else:
|
||||
with httpx.Client(verify=True) as client_2:
|
||||
if 'key_base_url' in self.__dict__:
|
||||
response = client_2.get(ts_url, headers=random_headers(self.key_base_url), timeout=REQUEST_TIMEOUT)
|
||||
response = client_2.get(ts_url, headers=random_headers(self.key_base_url), timeout=REQUEST_TIMEOUT, follow_redirects=True)
|
||||
else:
|
||||
response = client_2.get(ts_url, headers={'user-agent': get_headers()}, timeout=REQUEST_TIMEOUT)
|
||||
response = client_2.get(ts_url, headers={'user-agent': get_headers()}, timeout=REQUEST_TIMEOUT, follow_redirects=True)
|
||||
|
||||
# Get response content
|
||||
response.raise_for_status()
|
||||
|
@ -68,7 +68,11 @@ def get_video_duration(file_path: str) -> float:
|
||||
probe_result = json.loads(stdout)
|
||||
|
||||
# Extract duration from the video information
|
||||
try:
|
||||
return float(probe_result['format']['duration'])
|
||||
except:
|
||||
logging.error("Cant get duration.")
|
||||
return 1
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Error get video duration: {e}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user