diff --git a/common/lib/xmodule/xmodule/video_module/video_module.py b/common/lib/xmodule/xmodule/video_module/video_module.py index 6e2dc44790..a02231318d 100644 --- a/common/lib/xmodule/xmodule/video_module/video_module.py +++ b/common/lib/xmodule/xmodule/video_module/video_module.py @@ -285,10 +285,11 @@ class VideoModule(VideoFields, VideoTranscriptsMixin, VideoStudentViewHandlers, if getattr(self, 'video_speed_optimizations', True) and cdn_url: branding_info = BrandingInfoConfig.get_config().get(self.system.user_location) - for index, source_url in enumerate(sources): - new_url = rewrite_video_url(cdn_url, source_url) - if new_url: - sources[index] = new_url + if self.edx_video_id and edxval_api: + for index, source_url in enumerate(sources): + new_url = rewrite_video_url(cdn_url, source_url) + if new_url: + sources[index] = new_url # If there was no edx_video_id, or if there was no download specified # for it, we fall back on whatever we find in the VideoDescriptor diff --git a/lms/djangoapps/courseware/tests/test_video_mongo.py b/lms/djangoapps/courseware/tests/test_video_mongo.py index 29662dfe7c..1f215e4ae6 100644 --- a/lms/djangoapps/courseware/tests/test_video_mongo.py +++ b/lms/djangoapps/courseware/tests/test_video_mongo.py @@ -842,9 +842,9 @@ class TestGetHtmlMethod(BaseTestXmodule): }, } - # test with and without edx_video_id specified. + # Only videos with a video id should have their URLs rewritten + # based on CDN settings cases = [ - dict(case_data, edx_video_id=""), dict(case_data, edx_video_id="vid-v1:12345"), ]