Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/stream_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ def _rewrite_url(self, original_url: str, base_proxy_url: str) -> str:
parent_param = f"&parent={self.parent_stream_id}" if self.parent_stream_id else ""
return f"{base_proxy_url}/playlist.m3u8?url={encoded_url}&client_id={self.client_id}{parent_param}"
else:
# Fix: Remove .ts extension to match actual API endpoint /hls/{stream_id}/segment
return f"{base_proxy_url}/segment?url={encoded_url}&client_id={self.client_id}"
return f"{base_proxy_url}/segment.ts?url={encoded_url}&client_id={self.client_id}"


class StreamManager:
Expand Down
7 changes: 3 additions & 4 deletions tests/test_stream_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,13 @@ def test_rewrite_absolute_urls(self):
result = processor.process_playlist(
playlist, proxy_base_url, "http://original.com/")

# Verify that the segment URLs are correctly rewritten and encoded
# Note: Changed from 'segment.ts' to 'segment' to match actual API endpoint
# Verify that the segment URLs are correctly rewritten and encoded, .ts added back
encoded_segment1 = quote("http://original.com/segment1.ts", safe='')
expected_url1 = f"{proxy_base_url}/segment?url={encoded_segment1}&client_id=stream123"
expected_url1 = f"{proxy_base_url}/segment.ts?url={encoded_segment1}&client_id=stream123"
assert expected_url1 in result

encoded_segment2 = quote("http://original.com/segment2.ts", safe='')
expected_url2 = f"{proxy_base_url}/segment?url={encoded_segment2}&client_id=stream123"
expected_url2 = f"{proxy_base_url}/segment.ts?url={encoded_segment2}&client_id=stream123"
assert expected_url2 in result


Expand Down