Skip to content

Commit

Permalink
html5 resources included in create_video dict
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdul-Muqadim-Arbisoft committed May 9, 2024
1 parent 5d7e5a3 commit fe3a6f7
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions openedx_google_cdn/views.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import tempfile
# from google.cloud import storage
from rest_framework.response import Response
from rest_framework import status as rest_status

import json
import logging
import tempfile
from uuid import uuid4

from django.conf import settings
from django.http import HttpResponseNotFound
from django.http import HttpResponseNotFound
from django.utils.translation import gettext as _
from edxval.api import (
create_video,
get_transcript_preferences,
remove_video_for_course,
)
from pytz import UTC
from rest_framework import status as rest_status
from rest_framework.response import Response

from common.djangoapps.util.json_request import JsonResponse
from openedx.core.djangoapps.video_config.models import VideoTranscriptEnabledFlag
from cms.djangoapps.contentstore.toggles import use_mock_video_uploads
from cms.djangoapps.contentstore.video_storage_handlers import (
_get_and_validate_course,
videos_index_json,
Expand All @@ -28,20 +22,22 @@
_update_pagination_context,
send_video_status_update,
videos_post,

)
from cms.djangoapps.contentstore.toggles import use_mock_video_uploads
from edxval.api import (
create_video,
get_transcript_preferences,
remove_video_for_course,
)
from openedx.core.djangoapps.video_config.models import VideoTranscriptEnabledFlag
from xmodule.exceptions import NotFoundError
from xmodule.video_block.transcripts_utils import Transcript
from xmodule.video_block.video_block import VideoBlock

try:
import edxval.api as edxval_api
except ImportError:
edxval_api = None

from xmodule.video_block.transcripts_utils import (
Transcript,
)
from xmodule.exceptions import NotFoundError

LOGGER = logging.getLogger(__name__)

VIDEO_SUPPORTED_FILE_FORMATS = {
Expand All @@ -54,9 +50,6 @@






def enhanced_handle_videos(prev_fn, request, course_key_string, edx_video_id=None):

course = _get_and_validate_course(course_key_string, request.user)
Expand Down Expand Up @@ -175,6 +168,15 @@ def videos_post_cdn(course, request):
method="PUT",
content_type=req_file['content_type'],
)

if getattr(settings, "ENABLE_GOOGLE_CDN", None):
source_url = "{}/{}/{}".format(
settings.GOOGLE_CDN_HOST,
settings.VIDEO_UPLOAD_PIPELINE.get("ROOT_PATH", ""),
edx_video_id
)
else:
source_url = None

# persist edx_video_id in VAL
create_video({
Expand All @@ -183,7 +185,8 @@ def videos_post_cdn(course, request):
'client_video_id': file_name,
'duration': 0,
'encoded_videos': [],
'courses': [str(course.id)]
'courses': [str(course.id)],
'html5_sources': [source_url] if source_url else []
})

resp_files.append({'file_name': file_name, 'upload_url': upload_url, 'edx_video_id': edx_video_id})
Expand Down

0 comments on commit fe3a6f7

Please sign in to comment.