Commit 178b545c by David Ormsbee

Add convenience methods to API when you only care about URLs.

parent 7ddf4ee7
...@@ -181,6 +181,27 @@ def get_video_info(edx_video_id, location=None): # pylint: disable=W0613 ...@@ -181,6 +181,27 @@ def get_video_info(edx_video_id, location=None): # pylint: disable=W0613
raise ValInternalError(error_message) raise ValInternalError(error_message)
return result.data # pylint: disable=E1101 return result.data # pylint: disable=E1101
def get_urls_for_profiles(edx_video_id, profiles):
"""Returns a dict mapping profiles to URLs.
If the profiles or video is not found, urls will be blank.
"""
profiles_to_urls = {profile: "" for profile in profiles}
try:
video_info = get_video_info(edx_video_id)
except ValVideoNotFoundError:
return profiles_to_urls
for encoded_video in video_info["encoded_videos"]:
if encoded_video["profile"] in profiles:
profiles_to_urls[encoded_video["profile"]] = encoded_video["url"]
return profiles_to_urls
def get_url_for_profile(edx_video_id, profile):
return get_urls_for_profiles(edx_video_id, [profile])[profile]
def get_videos_for_course(course_id): def get_videos_for_course(course_id):
""" """
Returns an iterator of videos for the given course id Returns an iterator of videos for the given course id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment