Commit 271e9076 by Carlos Andrés Rocha

Merge pull request #632 from rocha/ignore-invalid-youtube-ids

Fix error when there is an invalid YouTube property in a video module
parents a7568fbf 8a527d16
...@@ -287,19 +287,17 @@ class VideoDescriptor(VideoFields, TabsEditingDescriptor, EmptyDataRawDescriptor ...@@ -287,19 +287,17 @@ class VideoDescriptor(VideoFields, TabsEditingDescriptor, EmptyDataRawDescriptor
XML-based courses. XML-based courses.
""" """
ret = {'0.75': '', '1.00': '', '1.25': '', '1.50': ''} ret = {'0.75': '', '1.00': '', '1.25': '', '1.50': ''}
if data == '':
return ret
videos = data.split(',') videos = data.split(',')
for video in videos: for video in videos:
pieces = video.split(':') pieces = video.split(':')
# HACK try:
# To elaborate somewhat: in many LMS tests, the keys for speed = '%.2f' % float(pieces[0]) # normalize speed
# Youtube IDs are inconsistent. Sometimes a particular youtube_id = pieces[1]
# speed isn't present, and formatting is also inconsistent ret[speed] = youtube_id
# ('1.0' versus '1.00'). So it's necessary to either do except (ValueError, IndexError):
# something like this or update all the tests to work log.warning('Invalid YouTube ID: %s' % video)
# properly.
ret['%.2f' % float(pieces[0])] = pieces[1]
return ret return ret
@staticmethod @staticmethod
......
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