Commit c0fa6884 by muhammad-ammar Committed by muzaffaryousaf

replace 3rdparty transcript urls

parent b059bd35
......@@ -36,20 +36,39 @@ ERROR = 'error'
# Transcript format
TRANSCRIPT_SJSON = 'sjson'
CIELO24_TRANSCRIPT_COMPLETED = django.dispatch.Signal(providing_args=['job_id', 'lang_code', 'org', 'video_id'])
CIELO24_GET_CAPTION_URL = 'https://api.cielo24.com/api/job/get_caption'
CONFIG = utils.get_config()
# Cielo24 API URLs
CIELO24_GET_CAPTION_URL = utils.build_url(
CONFIG['cielo24_api_base_url'],
'api/job/get_caption'
)
# 3PlayMedia callback signal
THREE_PLAY_TRANSCRIPTION_DONE = django.dispatch.Signal(
providing_args=['org', 'lang_code', 'edx_video_id', 'file_id', 'status', 'error_description']
)
# 3PlayMedia API URLs.
THREE_PLAY_TRANSCRIPT_URL = u'https://static.3playmedia.com/files/{file_id}/transcript.srt'
THREE_PLAY_TRANSLATION_SERVICES_URL = u'https://static.3playmedia.com/translation_services'
THREE_PLAY_ORDER_TRANSLATION_URL = u'https://api.3playmedia.com/files/{file_id}/translations/order'
THREE_PLAY_TRANSLATION_STATUS_URL = u'https://static.3playmedia.com/files/{file_id}/translations/{translation_id}'
THREE_PLAY_TRANSLATION_DOWNLOAD_URL = (u'https://static.3playmedia.com/files/{file_id}/translations/{translation_id}/'
u'captions.srt')
THREE_PLAY_TRANSCRIPT_URL = utils.build_url(
CONFIG['three_play_api_transcript_url'],
'files/{file_id}/transcript.srt'
)
THREE_PLAY_TRANSLATION_SERVICES_URL = utils.build_url(
CONFIG['three_play_api_transcript_url'],
'translation_services'
)
THREE_PLAY_ORDER_TRANSLATION_URL = utils.build_url(
CONFIG['three_play_api_base_url'],
'files/{file_id}/translations/order'
)
THREE_PLAY_TRANSLATION_STATUS_URL = utils.build_url(
CONFIG['three_play_api_transcript_url'],
'files/{file_id}/translations/{translation_id}'
)
THREE_PLAY_TRANSLATION_DOWNLOAD_URL = utils.build_url(
CONFIG['three_play_api_transcript_url'],
'files/{file_id}/translations/{translation_id}/captions.srt'
)
class TranscriptError(Exception):
......
......@@ -53,7 +53,8 @@ class ThreePlayMediaClientTests(TestCase):
'api_key': u'insecure_api_key',
'api_secret': u'insecure_api_secret',
'turnaround_level': ThreePlayTurnaround.DEFAULT,
'callback_url': 'https://veda.edx.org/3playmedia/transcripts/handle/123123?org=MAx&edx_video_id=12345'
'callback_url': 'https://veda.edx.org/3playmedia/transcripts/handle/123123?org=MAx&edx_video_id=12345',
'three_play_api_base_url': 'https://api.3playmedia.com/',
}
def assert_request(self, received_request, expected_request):
......
......@@ -46,6 +46,7 @@ class Cielo24TranscriptTests(TestCase):
'preferred_languages': ['en', 'ur'],
's3_video_url': 'https://s3.amazonaws.com/bkt/video.mp4',
'callback_base_url': 'https://veda.edx.org/cielo24/transcript_completed/1234567890',
'cielo24_api_base_url': 'https://sandbox.cielo24.com/api',
}
def tearDown(self):
......@@ -65,7 +66,7 @@ class Cielo24TranscriptTests(TestCase):
Returns:
absolute url
"""
return build_url(cielo24.cielo24_site, endpoint)
return build_url(cielo24.cielo24_api_base_url, endpoint)
def assert_request(self, received_request, expected_request):
"""
......@@ -116,17 +117,44 @@ class Cielo24TranscriptTests(TestCase):
# pylint: disable=line-too-long
expected_data = [
{
'url': 'https://api.cielo24.com/api/job/new?api_token=cielo24_api_key&job_name=12345&language=en&v=1',
'url': build_url(
'https://sandbox.cielo24.com/api/job/new',
v=1,
job_name='12345',
language='en',
api_token='cielo24_api_key',
),
'body': None,
'method': 'GET'
},
{
'url': 'https://api.cielo24.com/api/job/add_media?media_url=https%253A%252F%252Fs3.amazonaws.com%252Fbkt%252Fvideo.mp4&api_token=cielo24_api_key&job_id=000-111-222&v=1',
'url': build_url(
'https://sandbox.cielo24.com/api/job/add_media',
v=1,
job_id='000-111-222',
api_token='cielo24_api_key',
media_url='https://s3.amazonaws.com/bkt/video.mp4',
),
'body': None,
'method': 'GET'
'method': 'GET',
},
{
'url': 'https://api.cielo24.com/api/job/perform_transcription?transcription_fidelity=PROFESSIONAL&job_id=000-111-222&v=1&priority=PRIORITY&api_token=cielo24_api_key&callback_url=https%3A%2F%2Fveda.edx.org%2Fcielo24%2Ftranscript_completed%2F1234567890%3Flang_code%3D{}%26video_id%3D12345%26job_id%3D000-111-222%26org%3DMAx&target_language={}',
'url': build_url(
'https://sandbox.cielo24.com/api/job/perform_transcription',
v=1,
job_id='000-111-222',
target_language='TARGET_LANG',
callback_url=build_url(
'https://veda.edx.org/cielo24/transcript_completed/1234567890',
lang_code='TARGET_LANG',
video_id='12345',
job_id='000-111-222',
org='MAx',
),
api_token='cielo24_api_key',
priority='PRIORITY',
transcription_fidelity='PROFESSIONAL',
),
'body': None,
'method': 'GET'
}
......@@ -138,7 +166,7 @@ class Cielo24TranscriptTests(TestCase):
# replace target language with appropriate value
if 'api/job/perform_transcription' in request_data['url']:
request_data = dict(request_data)
request_data['url'] = request_data['url'].format(preferred_language, preferred_language)
request_data['url'] = request_data['url'].replace('TARGET_LANG', preferred_language)
self.assert_request(
responses.calls[received_request_index].request,
......
......@@ -569,7 +569,8 @@ class VedaDelivery:
self.video_query.cielo24_fidelity,
self.video_query.preferred_languages,
s3_video_url,
callback_base_url
callback_base_url,
self.auth_dict['cielo24_api_base_url'],
)
cielo24.start_transcription_flow()
......@@ -615,6 +616,7 @@ class VedaDelivery:
api_secret=transcript_secrets.api_secret,
callback_url=callback_url,
turnaround_level=self.video_query.three_play_turnaround,
three_play_api_base_url=self.auth_dict['three_play_api_base_url'],
)
three_play_media.generate_transcripts()
......
......@@ -45,7 +45,17 @@ class ThreePlayMediaUrlError(ThreePlayMediaError):
class ThreePlayMediaClient(object):
def __init__(self, org, video, media_url, api_key, api_secret, callback_url, turnaround_level):
def __init__(
self,
org,
video,
media_url,
api_key,
api_secret,
callback_url,
turnaround_level,
three_play_api_base_url
):
"""
Initialize 3play media client
"""
......@@ -57,7 +67,7 @@ class ThreePlayMediaClient(object):
self.callback_url = callback_url
self.turnaround_level = turnaround_level
# default attributes
self.base_url = u'https://api.3playmedia.com/'
self.base_url = three_play_api_base_url
self.upload_media_file_url = u'files/'
self.available_languages_url = u'caption_imports/available_languages/'
self.allowed_content_type = u'video/mp4'
......
......@@ -49,7 +49,18 @@ class Cielo24Transcript(object):
"""
Cielo24 Integration
"""
def __init__(self, video, org, api_key, turnaround, fidelity, preferred_languages, s3_video_url, callback_base_url):
def __init__(
self,
video,
org,
api_key,
turnaround,
fidelity,
preferred_languages,
s3_video_url,
callback_base_url,
cielo24_api_base_url
):
self.org = org
self.video = video
self.api_key = api_key
......@@ -60,7 +71,7 @@ class Cielo24Transcript(object):
self.callback_base_url = callback_base_url
# Defaults
self.cielo24_site = 'https://api.cielo24.com/api'
self.cielo24_api_base_url = cielo24_api_base_url
self.cielo24_new_job = '/job/new'
self.cielo24_add_media = '/job/add_media'
self.cielo24_perform_transcription = '/job/perform_transcription'
......@@ -115,7 +126,7 @@ class Cielo24Transcript(object):
response = requests.get(
build_url(
self.cielo24_site,
self.cielo24_api_base_url,
self.cielo24_perform_transcription,
v=1,
job_id=job_id,
......@@ -156,12 +167,12 @@ class Cielo24Transcript(object):
"""
response = requests.get(
build_url(
self.cielo24_site,
self.cielo24_api_base_url,
self.cielo24_add_media,
v=1,
job_id=job_id,
api_token=self.api_key,
media_url=urllib.quote_plus(self.s3_video_url)
media_url=self.s3_video_url
)
)
......@@ -190,7 +201,7 @@ class Cielo24Transcript(object):
cielo24 job id
"""
create_job_url = build_url(
self.cielo24_site,
self.cielo24_api_base_url,
self.cielo24_new_job,
v=1,
language='en',
......
......@@ -55,6 +55,13 @@ s3_base_url: https://s3.amazonaws.com
aws_video_transcripts_bucket:
aws_video_transcripts_prefix: video-transcripts/
# cielo24 api urls
cielo24_api_base_url: https://sandbox.cielo24.com/api
# 3playmedia api urls
three_play_api_base_url: https://api.3playmedia.com/
three_play_api_transcript_url: https://static.3playmedia.com/
# a token identifying a valid request from transcript provider
transcript_provider_request_token: test-token
......
......@@ -9,6 +9,12 @@ s3_base_url: https://s3.amazonaws.com
aws_video_transcripts_bucket: bucket_name
aws_video_transcripts_prefix: video-transcripts/
# cielo24 api urls
cielo24_api_base_url: https://sandbox.cielo24.com/api
# 3playmedia api urls
three_play_api_base_url: https://api.3playmedia.com/
three_play_api_transcript_url: https://static.3playmedia.com/
# a token identifying a valid request from transcript provider
transcript_provider_request_token: 1234a5a67cr890
......
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