blob: 771fbd0e1f8b3f772cc7ce009ceb479d17421127 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
|