mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-05 02:55:25 +00:00
core: HLS fix custom resolution parsing like 854x480
This commit is contained in:
parent
4789c147e4
commit
64efc67e6a
@ -21,7 +21,7 @@ from .film import download_film
|
|||||||
# Variable
|
# Variable
|
||||||
indice = 7
|
indice = 7
|
||||||
_useFor = "film"
|
_useFor = "film"
|
||||||
_deprecate = False
|
_deprecate = True
|
||||||
_priority = 2
|
_priority = 2
|
||||||
_engineDownload = "hls"
|
_engineDownload = "hls"
|
||||||
|
|
||||||
|
@ -189,16 +189,10 @@ class M3U8Manager:
|
|||||||
tuple_available_resolution = self.parser._video.get_list_resolution()
|
tuple_available_resolution = self.parser._video.get_list_resolution()
|
||||||
list_available_resolution = [f"{r[0]}x{r[1]}" for r in tuple_available_resolution]
|
list_available_resolution = [f"{r[0]}x{r[1]}" for r in tuple_available_resolution]
|
||||||
|
|
||||||
# Check if self.video_res is not None
|
|
||||||
if self.video_res is not None:
|
|
||||||
video_resolution = f"{self.video_res[0]}x{self.video_res[1]}"
|
|
||||||
else:
|
|
||||||
video_resolution = "Not set"
|
|
||||||
|
|
||||||
console.print(
|
console.print(
|
||||||
f"[cyan bold]Video [/cyan bold] [green]Available:[/green] [purple]{', '.join(list_available_resolution)}[/purple] | "
|
f"[cyan bold]Video [/cyan bold] [green]Available:[/green] [purple]{', '.join(list_available_resolution)}[/purple] | "
|
||||||
f"[red]Set:[/red] [purple]{FILTER_CUSTOM_REOLUTION}[/purple] | "
|
f"[red]Set:[/red] [purple]{FILTER_CUSTOM_REOLUTION}[/purple] | "
|
||||||
f"[yellow]Downloadable:[/yellow] [purple]{video_resolution}[/purple]"
|
f"[yellow]Downloadable:[/yellow] [purple]{self.video_res[0]}x{self.video_res[1]}[/purple]"
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.parser.codec is not None:
|
if self.parser.codec is not None:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# 20.04.25
|
# 20.04.25
|
||||||
|
|
||||||
import sys
|
import re
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
@ -418,18 +418,38 @@ class M3U8_Parser:
|
|||||||
- uri (str): The URI containing video information.
|
- uri (str): The URI containing video information.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
int: The video resolution if found, otherwise 0.
|
tuple: The video resolution (width, height) if found, otherwise (0, 0).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Log
|
# Log
|
||||||
logging.info(f"Try extract resolution from: {uri}")
|
logging.info(f"Try extract resolution from: {uri}")
|
||||||
|
|
||||||
|
# First try: Check for known resolutions
|
||||||
for resolution in RESOLUTIONS:
|
for resolution in RESOLUTIONS:
|
||||||
if "http" in str(uri):
|
if "http" in str(uri):
|
||||||
if str(resolution[1]) in uri:
|
if str(resolution[1]) in uri:
|
||||||
return resolution
|
return resolution
|
||||||
|
|
||||||
# Default resolution return (not best)
|
# Pattern to match common resolution formats like 854x480, 1280x720, etc.
|
||||||
|
resolution_patterns = [
|
||||||
|
r'(\d+)x(\d+)', # Match format: 854x480
|
||||||
|
r'(\d+)p', # Match format: 480p, 720p, etc.
|
||||||
|
r'_(\d+)x(\d+)' # Match format: _854x480
|
||||||
|
]
|
||||||
|
|
||||||
|
for pattern in resolution_patterns:
|
||||||
|
matches = re.findall(pattern, uri)
|
||||||
|
if matches:
|
||||||
|
if len(matches[0]) == 2: # Format like 854x480
|
||||||
|
width, height = int(matches[0][0]), int(matches[0][1])
|
||||||
|
return (width, height)
|
||||||
|
|
||||||
|
elif len(matches[0]) == 1: # Format like 480p
|
||||||
|
height = int(matches[0])
|
||||||
|
|
||||||
|
# Estimate width based on common aspect ratios (16:9)
|
||||||
|
width = int(height * 16 / 9)
|
||||||
|
return (width, height)
|
||||||
|
|
||||||
logging.warning("No resolution found with custom parsing.")
|
logging.warning("No resolution found with custom parsing.")
|
||||||
return (0, 0)
|
return (0, 0)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user