diff options
| author | Bobby <[email protected]> | 2025-03-11 01:14:10 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2025-03-11 01:14:10 +0530 |
| commit | 9085fa19a9972f0c31f0ba92505c77a52acf3d66 (patch) | |
| tree | b7f4f57e95fb0467014d20a8ce227a062c500a8f /services | |
| parent | f5ef9d42ebe7b2be932b35db7c5d801e9cfeb2c1 (diff) | |
| download | thatcomputerscientist-dev.tar.xz thatcomputerscientist-dev.zip | |
separate video/tracks in anime stream service and encodedev
Diffstat (limited to 'services')
| -rw-r--r-- | services/stream/urls.py | 3 | ||||
| -rw-r--r-- | services/stream/views.py | 22 |
2 files changed, 21 insertions, 4 deletions
diff --git a/services/stream/urls.py b/services/stream/urls.py index aaedb926..7aa9ea5e 100644 --- a/services/stream/urls.py +++ b/services/stream/urls.py @@ -6,5 +6,6 @@ app_name = "stream" urlpatterns = [ path("random-song", views.random_song, name="random_song"), path("song/<int:song_id>", views.stream_song, name="stream_song"), - path("anime/", views.anime_stream, name="anime_stream"), + path("anime", views.anime_stream, name="anime_stream"), + path("track", views.track_stream, name="track_stream"), ] diff --git a/services/stream/views.py b/services/stream/views.py index 516c3ba4..4e4a4cce 100644 --- a/services/stream/views.py +++ b/services/stream/views.py @@ -5,6 +5,7 @@ import re from urllib.parse import quote, urljoin, urlparse from django.conf import settings +from internal.crypto_utilities import decode_url, encode_url from services.stream.songs import MUSIC_FILES import requests from django.http import ( @@ -69,10 +70,19 @@ def stream_song(request, song_id: int) -> HttpResponse: def anime_stream(request): + return handle_stream(request) + + +def track_stream(request): + return handle_stream(request, isTrack=True) + + +def handle_stream(request, isTrack=False): if not request.user.is_authenticated: return HttpResponseForbidden("Access not allowed") - url = request.GET.get("url") + url = request.GET.get("video_id") if not isTrack else request.GET.get("track_id") + url = decode_url(url) if not str(url).endswith(".vtt"): referrer = request.META.get("HTTP_REFERER") @@ -116,7 +126,10 @@ def anime_stream(request): # Handle both absolute and relative URLs if not line.startswith("http"): line = urljoin(base_url, line) - proxy_url = f"/services/stream/anime?url={quote(line)}" + proxy_url = ( + f"/services/stream/anime?video_id={quote(encode_url(line))}" + ) + # proxy_url = f"/services/stream/anime?url={quote(line)}" modified_content.append(proxy_url) else: modified_content.append(line) @@ -139,7 +152,10 @@ def anime_stream(request): # 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)}" + return ( + f"/services/stream/track?track_id={quote(encode_url(sprite_url))}" + ) + # return f"/watch/stream?url={quote(sprite_url)}" # Replace all image URLs with proxied versions modified_content = re.sub(sprite_pattern, replace_url, content) |
