From 19993e4872d4d2e5add9fb7ca45c973c8cc31997 Mon Sep 17 00:00:00 2001 From: kartikvirendrar Date: Wed, 18 Dec 2024 12:14:06 +0530 Subject: [PATCH] minor changes for azure blob video url --- backend/video/utils.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/backend/video/utils.py b/backend/video/utils.py index 9bbfeaa2..94bd9f1b 100644 --- a/backend/video/utils.py +++ b/backend/video/utils.py @@ -493,14 +493,22 @@ def get_video_func(request): ) try: + if "blob.core.windows.net" in url: + info = ydl.extract_info(url, download=False) + title = info["title"] + video = VideoFileClip(url) + duration = timedelta(seconds=floor(video.duration)) + direct_video_url = url + normalized_url = url + else: # Get the video info from the YouTube API - ( - direct_video_url, - normalized_url, - title, - duration, - direct_audio_url, - ) = get_data_from_google_video(url) + ( + direct_video_url, + normalized_url, + title, + duration, + direct_audio_url, + ) = get_data_from_google_video(url) except: direct_video_url = "" direct_audio_url = "" @@ -523,17 +531,10 @@ def get_video_func(request): duration_iso8601 = video["contentDetails"]["duration"] duration = timedelta(seconds=iso8601_duration_to_seconds(duration_iso8601)) except: - if "blob.core.windows.net" in url: - info = ydl.extract_info(url, download=False) - title = info["title"] - video = VideoFileClip(url) - duration = timedelta(seconds=floor(video.duration)) - direct_video_url = url - else: - return Response( - {"message": "This is an invalid video URL."}, - status=status.HTTP_400_BAD_REQUEST, - ) + return Response( + {"message": "This is an invalid video URL."}, + status=status.HTTP_400_BAD_REQUEST, + ) # if title[-4:] == ".mp4" and "youtube.com" not in normalized_url: # return Response(