Skip to content

Commit

Permalink
feat: [ICNC-597] Implemented video downloading
Browse files Browse the repository at this point in the history
(cherry picked from commit 4a388b574c8a44e999514950aae02cbd96987686)
  • Loading branch information
Vladyslav Zherebkin authored and monteri committed May 14, 2024
1 parent 6d4dd70 commit eb3842d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions xmodule/video_block/video_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,9 +1214,9 @@ def student_view_data(self, context=None):
# Fall back to other video URLs in the video block if not found in VAL
if not encoded_videos:
if all_sources:
encoded_videos["fallback"] = {
encoded_videos["mobile_high"] = {
"url": all_sources[0],
"file_size": 0, # File size is unknown for fallback URLs
"file_size": self.file_size,
}

# Include youtube link if there is no encoding for mobile- ie only a fallback URL or no encodings at all
Expand All @@ -1235,7 +1235,7 @@ def student_view_data(self, context=None):

return {
"only_on_web": self.only_on_web,
"duration": val_video_data.get('duration', None),
"duration": int(val_video_data.get('duration', self.file_length.total_seconds())),
"transcripts": transcripts,
"encoded_videos": encoded_videos,
"all_sources": all_sources,
Expand Down
14 changes: 13 additions & 1 deletion xmodule/video_block/video_xfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import datetime

from xblock.fields import Boolean, DateTime, Dict, Float, List, Scope, String
from xblock.fields import Boolean, DateTime, Dict, Float, List, Scope, String, Integer

from xmodule.fields import RelativeTime

Expand Down Expand Up @@ -93,6 +93,18 @@ class VideoFields:
display_name=_("Video File URLs"),
scope=Scope.settings,
)
file_size = Integer(
help=_("Add video size. This size appears in mobile app via file downloading"),
display_name=_("Video File Size"),
scope=Scope.settings,
default=0
)
file_length = RelativeTime(
help=_("Add video length. This length appears in mobile app via file downloading. Formatted as HH:MM:SS"),
display_name=_("Video File Length"),
scope=Scope.settings,
default=datetime.timedelta(seconds=0)
)
track = String(
help=_("By default, students can download an .srt or .txt transcript when you set Download Transcript "
"Allowed to True. If you want to provide a downloadable transcript in a different format, we recommend "
Expand Down

0 comments on commit eb3842d

Please sign in to comment.