diff options
| author | Bobby <[email protected]> | 2024-11-25 19:25:34 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2024-11-25 19:25:34 -0500 |
| commit | 04425868c98967510d6292ef35ea69d077695f6e (patch) | |
| tree | c25b992be0bd78b36eb8e1aa71e9e83e0bf46397 | |
| parent | 81866d83714414d3c7643a8562d85605308c83f1 (diff) | |
| download | yugen-04425868c98967510d6292ef35ea69d077695f6e.tar.xz yugen-04425868c98967510d6292ef35ea69d077695f6e.zip | |
fix thumbs
| -rw-r--r-- | watch/views.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/watch/views.py b/watch/views.py index bb7b889..0913da5 100644 --- a/watch/views.py +++ b/watch/views.py @@ -71,15 +71,20 @@ def proxy_stream(request): # Handle VTT files elif url.endswith('.vtt'): content = response.text - # Regular expression to find URLs in VTT file - url_pattern = r'(https?://[^\s<>"]+?(?:jpg|jpeg|png|webp))' + base_url = url.rsplit('/', 1)[0] + '/' + + # Pattern to match both full URLs and relative paths with optional #xywh fragment + sprite_pattern = r'((?:https?://[^\s<>"]+?|[\w-]+\.(?:jpg|jpeg|png|webp))(?:#xywh=[\d,]+)?)' def replace_url(match): - thumbnail_url = match.group(1) - return f'/watch/stream?url={quote(thumbnail_url)}' + sprite_url = match.group(1) + # If it's not a full URL, join it with the base URL + if not sprite_url.startswith('http'): + sprite_url = urljoin(base_url, sprite_url) + return f'/watch/stream?url={quote(sprite_url)}' # Replace all image URLs with proxied versions - modified_content = re.sub(url_pattern, replace_url, content) + modified_content = re.sub(sprite_pattern, replace_url, content) return HttpResponse( modified_content, |
