Commit 6ac35caf by muhammad-ammar Committed by Qubad786

improve val status update logic

EDUCATOR-2033
parent b71d6d31
...@@ -23,6 +23,7 @@ class VedaDeliverRunTest(TestCase): ...@@ -23,6 +23,7 @@ class VedaDeliverRunTest(TestCase):
def setUp(self): def setUp(self):
self.veda_id = 'XXXXXXXX2014-V00TES1' self.veda_id = 'XXXXXXXX2014-V00TES1'
self.encode_profile = 'hls' self.encode_profile = 'hls'
self.encode_profile_mp4 = 'desktop_mp4'
self.course = Course.objects.create( self.course = Course.objects.create(
institution='XXX', institution='XXX',
edx_classid='XXXXX', edx_classid='XXXXX',
...@@ -46,6 +47,13 @@ class VedaDeliverRunTest(TestCase): ...@@ -46,6 +47,13 @@ class VedaDeliverRunTest(TestCase):
product_spec=self.encode_profile, product_spec=self.encode_profile,
encode_filetype='HLS' encode_filetype='HLS'
) )
self.encode_mp4 = Encode.objects.create(
encode_destination=self.destination,
profile_active=True,
encode_suffix='DTH',
product_spec=self.encode_profile_mp4,
encode_filetype='mpeg-4'
)
self.deliver_instance = VedaDelivery( self.deliver_instance = VedaDelivery(
veda_id=self.veda_id, veda_id=self.veda_id,
encode_profile=self.encode_profile, encode_profile=self.encode_profile,
...@@ -141,6 +149,12 @@ class VedaDeliverRunTest(TestCase): ...@@ -141,6 +149,12 @@ class VedaDeliverRunTest(TestCase):
videoID=self.video, videoID=self.video,
encode_url='Test_URL' encode_url='Test_URL'
) )
URL.objects.create(
encode_profile=self.encode_mp4,
videoID=self.video,
encode_url='Test_URL'
)
self.assertEqual(self.deliver_instance._DETERMINE_STATUS(), 'Complete') self.assertEqual(self.deliver_instance._DETERMINE_STATUS(), 'Complete')
def test_validate_url(self): def test_validate_url(self):
......
...@@ -101,7 +101,9 @@ class VedaDelivery: ...@@ -101,7 +101,9 @@ class VedaDelivery:
""" """
if self.encode_profile == 'youtube': if self.encode_profile == 'youtube':
self._CLEANUP() self._CLEANUP()
self.start_transcription(self._DETERMINE_STATUS())
return None return None
if self.encode_profile == 'review': if self.encode_profile == 'review':
return None return None
...@@ -127,17 +129,34 @@ class VedaDelivery: ...@@ -127,17 +129,34 @@ class VedaDelivery:
self._UPDATE_DATA() self._UPDATE_DATA()
self._CLEANUP() self._CLEANUP()
# Transcription Process self.start_transcription(self.status)
# We only want to generate transcripts for `desktop_mp4` profile.
if self.encode_profile == 'desktop_mp4' and self.video_query.process_transcription: def start_transcription(self, status):
"""
Kick off the transcription process
Arguments:
status (str): `Complete` or `Progress`
"""
# We only want to generate transcripts when all encodings are completed
if status == 'Complete' and self.video_query.process_transcription:
encode_query = Encode.objects.get(
product_spec='desktop_mp4'
)
encoded_file = '%s_%s.%s' % (
self.veda_id,
encode_query.encode_suffix,
encode_query.encode_filetype
)
# 3PlayMedia # 3PlayMedia
if self.video_query.provider == TranscriptProvider.THREE_PLAY: if self.video_query.provider == TranscriptProvider.THREE_PLAY:
self.start_3play_transcription_process() self.start_3play_transcription_process(encoded_file)
# Cielo24 # Cielo24
if self.video_query.provider == TranscriptProvider.CIELO24: if self.video_query.provider == TranscriptProvider.CIELO24:
self.cielo24_transcription_flow() self.cielo24_transcription_flow(encoded_file)
def hls_run(self): def hls_run(self):
""" """
...@@ -500,9 +519,12 @@ class VedaDelivery: ...@@ -500,9 +519,12 @@ class VedaDelivery:
os.chdir(homedir) os.chdir(homedir)
return True return True
def cielo24_transcription_flow(self): def cielo24_transcription_flow(self, encoded_file):
""" """
Cielo24 transcription flow. Cielo24 transcription flow.
Arguments:
encoded_file (str): name of encoded file to construct video url
""" """
org = extract_course_org(self.video_proto.platform_course_url[0]) org = extract_course_org(self.video_proto.platform_course_url[0])
...@@ -515,7 +537,7 @@ class VedaDelivery: ...@@ -515,7 +537,7 @@ class VedaDelivery:
s3_video_url = build_url( s3_video_url = build_url(
self.auth_dict['s3_base_url'], self.auth_dict['s3_base_url'],
self.auth_dict['edx_s3_endpoint_bucket'], self.auth_dict['edx_s3_endpoint_bucket'],
self.encoded_file encoded_file
) )
callback_base_url = build_url( callback_base_url = build_url(
...@@ -547,9 +569,12 @@ class VedaDelivery: ...@@ -547,9 +569,12 @@ class VedaDelivery:
) )
cielo24.start_transcription_flow() cielo24.start_transcription_flow()
def start_3play_transcription_process(self): def start_3play_transcription_process(self, encoded_file):
""" """
3PlayMedia Transcription Flow 3PlayMedia Transcription Flow
Arguments:
encoded_file (str): name of encoded file to construct video url
""" """
try: try:
# Picks the first course from the list as there may be multiple # Picks the first course from the list as there may be multiple
...@@ -569,7 +594,7 @@ class VedaDelivery: ...@@ -569,7 +594,7 @@ class VedaDelivery:
s3_video_url = build_url( s3_video_url = build_url(
self.auth_dict['s3_base_url'], self.auth_dict['s3_base_url'],
self.auth_dict['edx_s3_endpoint_bucket'], self.auth_dict['edx_s3_endpoint_bucket'],
self.encoded_file encoded_file
) )
callback_url = build_url( callback_url = build_url(
self.auth_dict['veda_base_url'], self.auth_dict['veda_base_url'],
......
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