diff options
| author | Astounds <kirito@disroot.org> | 2026-04-05 14:56:51 -0500 |
|---|---|---|
| committer | Astounds <kirito@disroot.org> | 2026-04-05 14:56:51 -0500 |
| commit | f0649be5dec84ce06a3164a2d9ee90f5385ac92f (patch) | |
| tree | 6dcae30ff3e0d66c895033aab9e92a4c9e4ed513 /youtube/hls_cache.py | |
| parent | 62a028968e6d9b4e821b6014d6658b8317328fcf (diff) | |
| download | yt-local-f0649be5dec84ce06a3164a2d9ee90f5385ac92f.tar.lz yt-local-f0649be5dec84ce06a3164a2d9ee90f5385ac92f.tar.xz yt-local-f0649be5dec84ce06a3164a2d9ee90f5385ac92f.zip | |
Add HLS support to multi-audio
Diffstat (limited to 'youtube/hls_cache.py')
| -rw-r--r-- | youtube/hls_cache.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/youtube/hls_cache.py b/youtube/hls_cache.py new file mode 100644 index 0000000..771fbd0 --- /dev/null +++ b/youtube/hls_cache.py @@ -0,0 +1,23 @@ +"""Multi-audio track support via HLS streaming. + +Instead of downloading all segments, we proxy the HLS playlist and +let the browser stream the audio directly. Zero local storage needed. +""" + +_tracks = {} # cache_key -> {'hls_url': str, ...} + + +def register_track(cache_key, hls_playlist_url, content_length=0, + video_id=None, track_id=None): + print(f'[audio-track-cache] Registering track: {cache_key} -> {hls_playlist_url[:80]}...') + _tracks[cache_key] = {'hls_url': hls_playlist_url} + print(f'[audio-track-cache] Available tracks: {list(_tracks.keys())}') + + +def get_hls_url(cache_key): + entry = _tracks.get(cache_key) + if entry: + print(f'[audio-track-cache] Found track: {cache_key}') + else: + print(f'[audio-track-cache] Track not found: {cache_key}') + return entry['hls_url'] if entry else None |
