-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Populate video duration to edx call #1084
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left some comments but they're pretty minor so approving it, feel free to make the suggested changes or leave as is. I did not test with a local edx instance but added a log statement to dump the JSON that would be sent there and the duration value was as expected.
ui/api.py
Outdated
duration = 0.0 | ||
if submitted_encode_job: | ||
et_job = get_et_job(submitted_encode_job.id) | ||
duration = et_job["Output"].get("Duration") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple minor suggestions, feel free to take or leave: you don't necessarily have to run get_et_job
, the EncodeJob
object in the database should have that info already. But either way should work. Also, when assigning the duration from the encode job, might be good to add or 0
just in case it is null for some reason.
import ast
....
duration = 0.0
if submitted_encode_job:
duration = ast.literal_eval(submitted_encode_job.message).get("Output", {}).get("Duration", 0) or 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I've made the change for your suggestion.
What are the relevant tickets?
https://github.com/mitodl/hq/issues/3402
Description (What does it do?)
Adding functionality to populating duration when posting video to open edx. Duration can be found in EncodeJob json response (see https://video-rc.odl.mit.edu/admin/ui/video/165/change/)
How can this be tested?
To test this, you will need a working OVS and open edx (tutur or devstack) instances locally. For OVS setup, follow README instruction, you may need to ask for AWS and CloudFront env variables from devops.
In your local edx instance. e.g. tutor
Make a note of
Client id
andClient secret
Token can be populated with anything. Make a note of that
In your OVS instance
Add a edx endpoint to http://ovs.odl.local:8089/admin/ui/edxendpoint/
Access Token
,Client id
andSecret Key
should match the ones you generated above in edx instanceAdd a collection to your local OVS http://ovs.odl.local:8089/admin/ui/collection/
Edx course id
with course-v1:edX+DemoX+Demo_CourseAdd video from dropbox from http://ovs.odl.local:8089/collections/
Once video is uploaded to S3 successfully, you can view it from http://ovs.odl.local:8089/admin/ui/video/
At this point, you should be able to see the video posting to your local edx instance http://local.overhang.io/admin/edxval/video/ with duration populated.
Or you can run
docker-compose run web ./manage.py add_hls_video_to_edx --video-file-id <YOUR VIDEO FILE ID>
But I had no luck getting it posted to my tutor as I keep getting the following error, so maybe I am missing something.
I was able to modify
post_video_to_edx
to test the code I added to make sure duration is returned correctly.