mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2025-10-23 15:11:08 +00:00
Add new session utility with curl_cffi support for anti-bot protection Update all manifest parsers (DASH, HLS, ISM, M3U8) to accept curl_cffi sessions Add browser impersonation support (Chrome, Firefox, Safari) Fix cookie handling compatibility between requests and curl_cffi Suppress HTTPS proxy warnings for better UX Maintain full backward compatibility with requests.Session
35 lines
860 B
Python
35 lines
860 B
Python
"""Utility functions for parsing M3U8 playlists."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Optional, Union
|
|
|
|
import m3u8
|
|
from curl_cffi.requests import Session as CurlSession
|
|
from requests import Session
|
|
|
|
from unshackle.core.manifests.hls import HLS
|
|
from unshackle.core.tracks import Tracks
|
|
|
|
|
|
def parse(
|
|
master: m3u8.M3U8,
|
|
language: str,
|
|
*,
|
|
session: Optional[Union[Session, CurlSession]] = None,
|
|
) -> Tracks:
|
|
"""Parse a variant playlist to ``Tracks`` with basic information, defer DRM loading."""
|
|
tracks = HLS(master, session=session).to_tracks(language)
|
|
|
|
bool(master.session_keys or HLS.parse_session_data_keys(master, session or Session()))
|
|
|
|
if True:
|
|
for t in tracks.videos + tracks.audio:
|
|
t.needs_drm_loading = True
|
|
t.session = session
|
|
|
|
return tracks
|
|
|
|
|
|
__all__ = ["parse"]
|