mirror of
https://github.com/UrloMythus/UnHided.git
synced 2026-04-11 03:40:54 +00:00
update
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from typing import Dict, Literal, Optional, Union
|
||||
from typing import Dict, Literal, Optional
|
||||
|
||||
import httpx
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, SecretStr
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
|
||||
@@ -28,48 +27,6 @@ class TransportConfig(BaseSettings):
|
||||
)
|
||||
timeout: int = Field(60, description="Timeout for HTTP requests in seconds")
|
||||
|
||||
def get_mounts(
|
||||
self, async_http: bool = True
|
||||
) -> Dict[str, Optional[Union[httpx.HTTPTransport, httpx.AsyncHTTPTransport]]]:
|
||||
"""
|
||||
Get a dictionary of httpx mount points to transport instances.
|
||||
"""
|
||||
mounts = {}
|
||||
transport_cls = httpx.AsyncHTTPTransport if async_http else httpx.HTTPTransport
|
||||
global_verify = not self.disable_ssl_verification_globally
|
||||
|
||||
# Configure specific routes
|
||||
for pattern, route in self.transport_routes.items():
|
||||
mounts[pattern] = transport_cls(
|
||||
verify=route.verify_ssl if global_verify else False,
|
||||
proxy=route.proxy_url or self.proxy_url if route.proxy else None,
|
||||
)
|
||||
|
||||
# Hardcoded configuration for jxoplay.xyz domain - SSL verification disabled
|
||||
mounts["all://jxoplay.xyz"] = transport_cls(
|
||||
verify=False, proxy=self.proxy_url if self.all_proxy else None
|
||||
)
|
||||
|
||||
mounts["all://dlhd.dad"] = transport_cls(
|
||||
verify=False, proxy=self.proxy_url if self.all_proxy else None
|
||||
)
|
||||
|
||||
mounts["all://*.newkso.ru"] = transport_cls(
|
||||
verify=False, proxy=self.proxy_url if self.all_proxy else None
|
||||
)
|
||||
|
||||
# Apply global settings for proxy and SSL
|
||||
default_proxy_url = self.proxy_url if self.all_proxy else None
|
||||
if default_proxy_url or not global_verify:
|
||||
mounts["all://"] = transport_cls(proxy=default_proxy_url, verify=global_verify)
|
||||
|
||||
# Set default proxy for all routes if enabled
|
||||
# This part is now handled above to combine proxy and SSL settings
|
||||
# if self.all_proxy:
|
||||
# mounts["all://"] = transport_cls(proxy=self.proxy_url)
|
||||
|
||||
return mounts
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
extra = "ignore"
|
||||
@@ -78,30 +35,80 @@ class TransportConfig(BaseSettings):
|
||||
class Settings(BaseSettings):
|
||||
api_password: str | None = None # The password for protecting the API endpoints.
|
||||
log_level: str = "INFO" # The logging level to use.
|
||||
transport_config: TransportConfig = Field(default_factory=TransportConfig) # Configuration for httpx transport.
|
||||
transport_config: TransportConfig = Field(default_factory=TransportConfig) # Configuration for HTTP transport.
|
||||
enable_streaming_progress: bool = False # Whether to enable streaming progress tracking.
|
||||
disable_home_page: bool = False # Whether to disable the home page UI.
|
||||
disable_docs: bool = False # Whether to disable the API documentation (Swagger UI).
|
||||
disable_speedtest: bool = False # Whether to disable the speedtest UI.
|
||||
clear_cache_on_startup: bool = (
|
||||
False # Whether to clear all caches (extractor, MPD, etc.) on startup. Useful for development.
|
||||
)
|
||||
stremio_proxy_url: str | None = None # The Stremio server URL for alternative content proxying.
|
||||
m3u8_content_routing: Literal["mediaflow", "stremio", "direct"] = (
|
||||
"mediaflow" # Routing strategy for M3U8 content URLs: "mediaflow", "stremio", or "direct"
|
||||
)
|
||||
enable_hls_prebuffer: bool = False # Whether to enable HLS pre-buffering for improved streaming performance.
|
||||
enable_hls_prebuffer: bool = True # Whether to enable HLS pre-buffering for improved streaming performance.
|
||||
livestream_start_offset: (
|
||||
float | None
|
||||
) = -18 # Default start offset for live streams (e.g., -18 to start 18 seconds behind live edge). Applies to HLS and MPD live playlists. Set to None to disable.
|
||||
hls_prebuffer_segments: int = 5 # Number of segments to pre-buffer ahead.
|
||||
hls_prebuffer_cache_size: int = 50 # Maximum number of segments to cache in memory.
|
||||
hls_prebuffer_max_memory_percent: int = 80 # Maximum percentage of system memory to use for HLS pre-buffer cache.
|
||||
hls_prebuffer_emergency_threshold: int = 90 # Emergency threshold percentage to trigger aggressive cache cleanup.
|
||||
enable_dash_prebuffer: bool = False # Whether to enable DASH pre-buffering for improved streaming performance.
|
||||
hls_prebuffer_inactivity_timeout: int = 60 # Seconds of inactivity before stopping playlist refresh loop.
|
||||
hls_segment_cache_ttl: int = 300 # TTL (seconds) for cached HLS segments; 300s (5min) for VOD, lower for live.
|
||||
enable_dash_prebuffer: bool = True # Whether to enable DASH pre-buffering for improved streaming performance.
|
||||
dash_prebuffer_segments: int = 5 # Number of segments to pre-buffer ahead.
|
||||
dash_prebuffer_cache_size: int = 50 # Maximum number of segments to cache in memory.
|
||||
dash_prebuffer_max_memory_percent: int = 80 # Maximum percentage of system memory to use for DASH pre-buffer cache.
|
||||
dash_prebuffer_emergency_threshold: int = 90 # Emergency threshold percentage to trigger aggressive cache cleanup.
|
||||
mpd_live_init_cache_ttl: int = 0 # TTL (seconds) for live init segment cache; 0 disables caching.
|
||||
dash_prebuffer_inactivity_timeout: int = 60 # Seconds of inactivity before cleaning up stream state.
|
||||
dash_segment_cache_ttl: int = 60 # TTL (seconds) for cached media segments; longer = better for slow playback.
|
||||
mpd_live_init_cache_ttl: int = 60 # TTL (seconds) for live init segment cache; 0 disables caching.
|
||||
mpd_live_playlist_depth: int = 8 # Number of recent segments to expose per live playlist variant.
|
||||
remux_to_ts: bool = False # Remux fMP4 segments to MPEG-TS for ExoPlayer/VLC compatibility.
|
||||
processed_segment_cache_ttl: int = 60 # TTL (seconds) for caching processed (decrypted/remuxed) segments.
|
||||
|
||||
user_agent: str = (
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36" # The user agent to use for HTTP requests.
|
||||
# FlareSolverr settings (for Cloudflare bypass)
|
||||
flaresolverr_url: str | None = None # FlareSolverr service URL. Example: http://localhost:8191
|
||||
flaresolverr_timeout: int = 60 # Timeout (seconds) for FlareSolverr requests.
|
||||
|
||||
# Acestream settings
|
||||
enable_acestream: bool = False # Whether to enable Acestream proxy support.
|
||||
acestream_host: str = "localhost" # Acestream engine host.
|
||||
acestream_port: int = 6878 # Acestream engine port.
|
||||
acestream_buffer_size: int = 4 * 1024 * 1024 # Buffer size for MPEG-TS streaming (4MB default, like acexy).
|
||||
acestream_empty_timeout: int = 30 # Timeout (seconds) when no data is received from upstream.
|
||||
acestream_session_timeout: int = 60 # Session timeout (seconds) for cleanup of inactive sessions.
|
||||
acestream_keepalive_interval: int = 15 # Interval (seconds) for session keepalive polling.
|
||||
|
||||
# Telegram MTProto settings
|
||||
enable_telegram: bool = False # Whether to enable Telegram MTProto proxy support.
|
||||
telegram_api_id: int | None = None # Telegram API ID from https://my.telegram.org/apps
|
||||
telegram_api_hash: SecretStr | None = None # Telegram API hash from https://my.telegram.org/apps
|
||||
telegram_session_string: SecretStr | None = None # Persistent session string (avoids re-authentication).
|
||||
telegram_max_connections: int = 8 # Max parallel DC connections for downloads (max 20, careful of floods).
|
||||
telegram_request_timeout: int = 30 # Request timeout in seconds.
|
||||
|
||||
# Transcode settings
|
||||
enable_transcode: bool = True # Whether to enable on-the-fly transcoding endpoints (MKV→fMP4, HLS VOD).
|
||||
transcode_prefer_gpu: bool = True # Prefer GPU acceleration (NVENC/VideoToolbox/VAAPI) when available.
|
||||
transcode_video_bitrate: str = "4M" # Target video bitrate for re-encoding (e.g. "4M", "2000k").
|
||||
transcode_audio_bitrate: int = 192000 # AAC audio bitrate in bits/s for the Python transcode pipeline.
|
||||
transcode_video_preset: str = "medium" # Encoding speed/quality tradeoff (libx264: ultrafast..veryslow).
|
||||
|
||||
user_agent: str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36" # The user agent to use for HTTP requests.
|
||||
|
||||
# Upstream error resilience settings
|
||||
upstream_retry_on_disconnect: bool = True # Enable/disable retry when upstream disconnects mid-stream.
|
||||
upstream_retry_attempts: int = 2 # Number of retry attempts when upstream disconnects during streaming.
|
||||
upstream_retry_delay: float = 1.0 # Delay (seconds) between retry attempts.
|
||||
graceful_stream_end: bool = True # Return valid empty playlist instead of error when upstream fails.
|
||||
|
||||
# Redis settings
|
||||
redis_url: str | None = None # Redis URL for distributed locking and caching. None = disabled.
|
||||
cache_namespace: str | None = (
|
||||
None # Optional namespace for instance-specific caches (e.g. pod name or hostname). When set, extractor results and other IP-bound data are stored under this namespace so multiple pods sharing one Redis don't serve each other's IP-specific URLs.
|
||||
)
|
||||
|
||||
class Config:
|
||||
|
||||
Reference in New Issue
Block a user