Skip to content

Commit

Permalink
Merge pull request #1356 from appsembler/bugfix/video-block-yt-metada…
Browse files Browse the repository at this point in the history
…ta-multitenant-url

Fix domain for video block LMS Root used for YT metadata
  • Loading branch information
bryanlandia committed Jul 6, 2023
2 parents bdf22f6 + e2e2f4e commit f45e0e0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion common/lib/xmodule/xmodule/video_module/video_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
from .video_utils import create_youtube_string, format_xml_exception_message, get_poster, rewrite_video_url
from .video_xfields import VideoFields

from openedx.core.djangoapps.appsembler.sites import utils as appsembler_site_utils

# The following import/except block for edxval is temporary measure until
# edxval is a proper XBlock Runtime Service.
#
Expand Down Expand Up @@ -393,6 +395,10 @@ def get_html(self, view=STUDENT_VIEW):
# it anymore; therefore we force-disable it in this case (when controls aren't visible).
autoadvance_this_video = self.auto_advance and autoadvance_enabled

scheme = "https" if settings.HTTPS == "on" else "http"
lms_base_url = appsembler_site_utils.get_lms_link_from_course_key(settings.LMS_ROOT_URL, self.course_id)
lms_root_url = "{}://{}".format(scheme, lms_base_url) if "http" not in lms_base_url else lms_base_url

metadata = {
'saveStateEnabled': view != PUBLIC_VIEW,
'saveStateUrl': self.ajax_url + '/save_user_state',
Expand All @@ -418,7 +424,7 @@ def get_html(self, view=STUDENT_VIEW):
'transcriptLanguages': sorted_languages,
'ytTestTimeout': settings.YOUTUBE['TEST_TIMEOUT'],
'ytApiUrl': settings.YOUTUBE['API'],
'lmsRootURL': settings.LMS_ROOT_URL,
'lmsRootURL': lms_root_url,
'ytMetadataEndpoint': (
# In the new runtime, get YouTube metadata via a handler. The handler supports anonymous users and
# can work in sandboxed iframes. In the old runtime, the JS will call the LMS's yt_video_metadata
Expand Down

0 comments on commit f45e0e0

Please sign in to comment.