Skip to content

Commit

Permalink
Add Brightcove content encryption and autoquality via HLS (#104)
Browse files Browse the repository at this point in the history
# Brightcove content protection and auto-quality:

On API authentication uploads two custom Ingest Profiles:

- Creates new API credentials with required permissions
- HLS for auto quality
- HLSe for auto qualify & encryption
- Add new UI controls after a user has authenticated against Brightcove API:

View video tech info
- Send video re-transcode request on a Brightcove side

# Default transcripts upload:
- Allows to fetch transcripts from the platform and store them into XBlock.
- Supports: Brightcove, Youtube & Wistia.
- Brightcove & Wistia require API authentication before default transcripts upload can work.
  • Loading branch information
z4y4ts authored Feb 7, 2017
1 parent d934373 commit 2638902
Show file tree
Hide file tree
Showing 22 changed files with 1,410 additions and 232 deletions.
1 change: 1 addition & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Serves for configuration of CodeClimate (automated code review for test coverage, complexity, duplication, etc.)
engines:
csslint:
enabled: true
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ test-py:
quality: quality-py quality-js

quality-py:
-pep8 . --format=pylint --max-line-length=120
-pylint -f colorized video_xblock
pep8 . --format=pylint --max-line-length=120
pylint -f colorized video_xblock

quality-js:
eslint video_xblock/static/js/
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"videojs-youtube": "raccoongang/videojs-youtube#playback-rate-fix",
"videojs-wistia": "raccoongang/videojs-wistia#playback-toggle-fix",
"videojs-transcript": "0.8.0",
"videojs-resolution-switcher": "85f1e51c8babefca2d670dbd0b21a6307dbb4d21",
"videojs-resolution-switcher": "videojs-resolution-switcher#85f1e51",
"videojs-offset": "raccoongang/videojs-offset#master",
"videojs-contextmenu": "brightcove/videojs-contextmenu",
"videojs-contextmenu-ui": "brightcove/videojs-contextmenu-ui",
Expand Down
6 changes: 6 additions & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Auto-transcripts upload is dependent on xmodule.contentstore
git+https://github.com/edx/edx-platform.git@open-release/eucalyptus.3#egg=xmodule==0.1.1&subdirectory=common/lib/xmodule/
PyContracts==1.7.1 # xmodule dependency
sortedcontainers==0.9.2 # xmodule dependency
Pillow==3.1.1 # xmodule dependency

coveralls==1.1
django==1.8.12
edx-lint==0.5.2
Expand Down
67 changes: 63 additions & 4 deletions video_xblock/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,71 @@
html_parser = HTMLParser() # pylint: disable=invalid-name


class ApiClientError(Exception):
"""
Base API client exception
"""
pass


class BaseApiClient(object):
"""
Low level video platform API client.
Abstracts API interaction details like
requests composition, API credentials handling.
Subclass your platform specific API client from this base class.
"""

@abc.abstractmethod
def get(self, url, headers=None, can_retry=True):
"""
Issue REST GET request to a given URL.
Can throw ApiClientError or it's subclass.
Arguments:
url (str): API url to fetch a resource from.
headers (dict): Headers necessary as per API, e.g. authorization bearer to perform authorised requests.
can_retry (bool): True if this is to retry a call if authentication failed.
Returns:
Response in python native data format.
"""

@abc.abstractmethod
def post(self, url, payload, headers=None, can_retry=True):
"""
Issue REST POST request to a given URL.
Can throw ApiClientError or it's subclass.
Arguments:
url (str): API url to fetch a resource from.
headers (dict): Headers necessary as per API, e.g. authorization bearer to perform authorised requests.
can_retry (bool): True if this is to retry a call if authentication failed.
Returns:
Response in python native data format.
"""


class BaseVideoPlayer(Plugin):
"""
Inherit your video player class from this class
"""
__metaclass__ = abc.ABCMeta

entry_point = 'video_xblock.v1'

def __init__(self, xblock):
self.xblock = xblock

@abc.abstractproperty
def url_re(self):
"""
Expand Down Expand Up @@ -222,14 +279,16 @@ def authenticate_api(self, **kwargs):
return {}, ''

@abc.abstractmethod
def download_default_transcript(self, url): # pylint: disable=unused-argument
def download_default_transcript(self, url, language_code): # pylint: disable=unused-argument
"""
Downloads default transcript from a video platform API and uploads it to the video xblock.
Downloads default transcript from a video platform API and formats it accordingly to the WebVTT standard.
Arguments:
url (str): transcript download url.
url (str): API url to fetch a default transcript from.
language_code (str): Language code of a transcript to be downloaded.
Returns:
unicode: Transcripts in WebVTT or SRT format.
unicode: Transcripts formatted per WebVTT.
"""
return u''

Expand Down
Loading

0 comments on commit 2638902

Please sign in to comment.