Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-val
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-val
Commits
a744c98b
Commit
a744c98b
authored
Jan 31, 2018
by
Tyler Hallada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP download video and change xml exported url
parent
358c49a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
5 deletions
+24
-5
edxval/api.py
+24
-5
No files found.
edxval/api.py
View file @
a744c98b
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
The internal API for VAL.
The internal API for VAL.
"""
"""
import
logging
import
logging
import
urllib2
from
enum
import
Enum
from
enum
import
Enum
from
django.core.exceptions
import
ObjectDoesNotExist
,
ValidationError
from
django.core.exceptions
import
ObjectDoesNotExist
,
ValidationError
...
@@ -744,7 +745,8 @@ def copy_course_videos(source_course_id, destination_course_id):
...
@@ -744,7 +745,8 @@ def copy_course_videos(source_course_id, destination_course_id):
)
)
def
export_to_xml
(
video_ids
,
course_id
=
None
,
external
=
False
):
def
export_to_xml
(
video_ids
,
course_id
=
None
,
external
=
False
,
video_download_dir
=
None
,
resource_fs
=
None
):
"""
"""
Exports data for a video into an xml object.
Exports data for a video into an xml object.
...
@@ -757,6 +759,10 @@ def export_to_xml(video_ids, course_id=None, external=False):
...
@@ -757,6 +759,10 @@ def export_to_xml(video_ids, course_id=None, external=False):
so that we can export transcripts for each video id.
so that we can export transcripts for each video id.
course_id (str): The ID of the course with which this video is associated
course_id (str): The ID of the course with which this video is associated
external (bool): True if first video id in `video_ids` is not edx_video_id else False
external (bool): True if first video id in `video_ids` is not edx_video_id else False
video_download_dir (str): The directory to download videos files to. If None, do not
download videos.
resource_fs (???): The filesystem to download videos onto. If None, do not download
videos.
Returns:
Returns:
An lxml video_asset element containing export data
An lxml video_asset element containing export data
...
@@ -789,13 +795,26 @@ def export_to_xml(video_ids, course_id=None, external=False):
...
@@ -789,13 +795,26 @@ def export_to_xml(video_ids, course_id=None, external=False):
}
}
)
)
for
encoded_video
in
video
.
encoded_videos
.
all
():
for
encoded_video
in
video
.
encoded_videos
.
all
():
SubElement
(
if
video_download_dir
and
resource_fs
:
video_el
,
attributes
=
{
'encoded_video'
,
name
:
unicode
(
getattr
(
encoded_video
,
name
))
{
for
name
in
[
'profile'
,
'file_size'
,
'bitrate'
]
}
video_url
=
unicode
(
getattr
(
encoded_video
,
'url'
))
exported_url
=
'{}/{}'
.
format
(
video_download_dir
,
video_url
.
split
(
'/'
)[
-
1
])
resp
=
urllib2
.
urlopen
(
video_url
)
with
resource_fs
.
open
(
exported_url
,
'w'
)
as
f
:
f
.
write
(
resp
.
read
())
attributes
[
'url'
]
=
exported_url
else
:
attributes
=
{
name
:
unicode
(
getattr
(
encoded_video
,
name
))
name
:
unicode
(
getattr
(
encoded_video
,
name
))
for
name
in
[
'profile'
,
'url'
,
'file_size'
,
'bitrate'
]
for
name
in
[
'profile'
,
'url'
,
'file_size'
,
'bitrate'
]
}
}
SubElement
(
video_el
,
'encoded_video'
,
attributes
)
)
return
create_transcripts_xml
(
video_ids
,
video_el
)
return
create_transcripts_xml
(
video_ids
,
video_el
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment