Enhance HLS proxy functionality and improve caching mechanism
- Updated AGENTS.md to clarify dlp.py module usage and segment handling. - Modified README.md to include ALLOW_LOCAL configuration for testing. - Refactored app.py to streamline HLS proxy logic and improve error handling. - Enhanced dlp.py to optimize caching and segment retrieval processes. - Updated player.html to ensure proper JSON formatting for proxy URLs. - Improved test_integration.py to validate HLS segment proxying and added test for Pornhub HLS extraction. - Adjusted test_proxy.py to reflect changes in caching functions and data structure.
This commit is contained in:
+8
-5
@@ -55,18 +55,21 @@ class TestCacheMechanics:
|
||||
dlp._session_cache.clear()
|
||||
dlp._cache_timestamps.clear()
|
||||
|
||||
test_data = {"test": "data"}
|
||||
dlp._set_cached_session("http://test.com/video", test_data)
|
||||
test_data = {"title": "Test Video", "thumbnail": "http://test.com/thumb.jpg", "hls_url": "http://test.com/stream.m3u8"}
|
||||
dlp._set_cached_info("http://test.com/video", test_data)
|
||||
|
||||
cached = dlp._get_cached_session("http://test.com/video")
|
||||
assert cached == test_data
|
||||
cached = dlp._get_cached_info("http://test.com/video")
|
||||
assert cached is not None
|
||||
assert cached["title"] == "Test Video"
|
||||
assert cached["thumbnail"] == "http://test.com/thumb.jpg"
|
||||
assert cached["hls_url"] == "http://test.com/stream.m3u8"
|
||||
|
||||
def test_cache_expiry(self):
|
||||
dlp.CACHE_TTL = 1
|
||||
dlp._session_cache.clear()
|
||||
dlp._cache_timestamps.clear()
|
||||
|
||||
dlp._set_cached_session("http://test.com/video", {"data": "test"})
|
||||
dlp._set_cached_info("http://test.com/video", {"data": "test"})
|
||||
import time
|
||||
time.sleep(1.1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user