Skip to content
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

Add ability for direct 3PlayMedia transcripts usage #251

Merged
merged 28 commits into from
Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3a9b6b2
Add basic "direct" 3PlayMedia transcript functionality
wowkalucky Jul 4, 2017
2f0f942
Add proxy transcript fetching handler
wowkalucky Jul 4, 2017
dcad13b
Fix unit-tests
wowkalucky Jul 4, 2017
d7dbcea
Add js 3PlayMedia credentials validation draft
wowkalucky Jul 5, 2017
be8f77e
Implement validation handler of 3PlayMedia configuration
wowkalucky Jul 5, 2017
3b566c4
Refactor: direct_enabled >> threeplaymedia_streaming
wowkalucky Jul 6, 2017
5085620
Change threeplaymedia_streaming field scope
wowkalucky Jul 6, 2017
18d46d2
Fix typo
wowkalucky Jul 6, 2017
870c379
Fix code review complaints
wowkalucky Jul 6, 2017
2488f40
Improve test-py coverage
wowkalucky Jul 6, 2017
a37020d
Make utility interface consistent
wowkalucky Jul 6, 2017
92af3f3
Fix 3PlayMedia validation handler
wowkalucky Jul 6, 2017
675d955
Fix exception cases
wowkalucky Jul 6, 2017
9e8f9a5
Fix BrightCove authentication error
wowkalucky Jul 6, 2017
c0fbacd
Refactor validation of 3PlayMedia options
wowkalucky Jul 6, 2017
067063b
Fix unicode chars in token error
wowkalucky Jul 7, 2017
10f5ce9
Remove deprecated 3PlayMedia transcript loading
wowkalucky Jul 7, 2017
17316cf
Add debug logging for default transcripts updating
wowkalucky Jul 7, 2017
ca4a5dd
Refactor 3PlayMedia utilities interface, fix tests, fix quality
wowkalucky Jul 7, 2017
5c75b16
Fix variables naming
wowkalucky Jul 7, 2017
75eca7e
Add unit test for 3PlayMedia API failure case
wowkalucky Jul 7, 2017
63bd9ee
Add unit test for 3PlayMedia validation handler: positive test case
wowkalucky Jul 10, 2017
e66000d
Cover with unit tests 3PlayMedia validation handler
wowkalucky Jul 10, 2017
9d1b3d5
Add additional transcripts configuration hint for staff
wowkalucky Jul 10, 2017
b4f8588
Refactor error message variable
wowkalucky Jul 10, 2017
81e44fb
Refactor STATUS to Enum
wowkalucky Jul 10, 2017
0981258
Fix review complaints
wowkalucky Jul 10, 2017
39219f2
Update CHANGELOG.md
z4y4ts Jul 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions video_xblock/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def advanced_fields(self):
"""
return [
'start_time', 'end_time', 'handout', 'transcripts',
'threeplaymedia_file_id', 'threeplaymedia_apikey', 'download_transcript_allowed',
'default_transcripts', 'download_video_allowed', 'download_video_url'
'threeplaymedia_file_id', 'threeplaymedia_apikey', 'threeplaymedia_streaming',
'download_transcript_allowed', 'default_transcripts', 'download_video_allowed', 'download_video_url'
]

@property
Expand Down
8 changes: 5 additions & 3 deletions video_xblock/backends/brightcove.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,15 @@ def authenticate_api(self, **kwargs):
error_status_message (str): Error messages for the sake of verbosity.
"""
token, account_id = kwargs.get('token'), kwargs.get('account_id')
client_secret, client_id, error_message = BrightcoveApiClient.create_credentials(token, account_id)
try:
client_secret, client_id, error_message = BrightcoveApiClient.create_credentials(token, account_id)
except BrightcoveApiClientError as bc_exception:
return {}, bc_exception.message

self.api_client.api_key = client_id
self.api_client.api_secret = client_secret
self.xblock.metadata['client_id'] = client_id
self.xblock.metadata['client_secret'] = client_secret
if error_message:
return {}, error_message
auth_data = {
'client_secret': client_secret,
'client_id': client_id,
Expand Down
4 changes: 2 additions & 2 deletions video_xblock/backends/vimeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get(self, url, headers=None, can_retry=False):
Response in python native data format.
"""
headers_ = {
'Authorization': 'Bearer {}'.format(self.access_token),
'Authorization': 'Bearer {}'.format(self.access_token.encode(encoding='utf-8')),
'Accept': 'application/json'
}
if headers is not None:
Expand Down Expand Up @@ -218,7 +218,7 @@ def get_default_transcripts(self, **kwargs):
try:
json_data = self.api_client.get(url)
except VimeoApiClientError:
message = _('No timed transcript may be fetched from a video platform.')
message = _('No timed transcript may be fetched from a video platform.<br>')
return default_transcripts, message

if not json_data:
Expand Down
18 changes: 16 additions & 2 deletions video_xblock/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@
Lists of constants that can be used in the video xblock.
"""

from enum import Enum

DEFAULT_LANG = 'en'


class Status(Enum):
"""
Status flags enumeration.
"""

success = 'success'
error = 'error'
warning = 'warning'


class PlayerName(object):
"""
Contains Player names for each backends.
Expand Down Expand Up @@ -288,9 +300,11 @@ def __init__(self, language_id):

:param language_id : int (from API response list of available transcript translations).
"""
if language_id not in self.TPM_LANGUAGES.keys():
try:
language_id = int(language_id)
language_info = self.TPM_LANGUAGES[language_id]
except (ValueError, KeyError):
raise ValueError("Language ID: {} does not exist!".format(language_id))
language_info = self.TPM_LANGUAGES[language_id]
self.language_id = language_id
self.ietf_code = language_info.get("ietf_code")
self.iso_639_1_code = language_info.get("iso_639_1_code")
Expand Down
Loading