Skip to content

Commit

Permalink
Merge pull request #955 from AI4Bharat/minorchange-01
Browse files Browse the repository at this point in the history
minor changes for azure blob video url
  • Loading branch information
kartikvirendrar authored Dec 18, 2024
2 parents cab4161 + 19993e4 commit 51437eb
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions backend/video/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand All @@ -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(
Expand Down

0 comments on commit 51437eb

Please sign in to comment.