Skip to content

Commit

Permalink
0.10.0: Add ability to perform search within text tracks (#297)
Browse files Browse the repository at this point in the history
* Bump __version__ to 0.9.4

* Make transcripts indexable for LMS search (#294)

* Fix javascript unit tests

* Fixed `fullscreen` button overlapping (#295)

* Fix for issue #292: languages selected differ between transcript and caption buttons (#296)

* Update xblock dependecies due to Ginkgo release

* Remove from captions/transcripts control's menu active language highlighting

* Prepare CHANGELOG.md for a new release

* Bump __version__ to 0.10.0
  • Loading branch information
wowkalucky authored Jan 24, 2018
1 parent ea48719 commit b859c69
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 17 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [0.10.0] - 2018-01-24

## Added

- Ability to perform search within text tracks (subtitles/transcripts);

### Fixed

- Player controls alignment;
- Active languages highlighting inconsistency between transcript and caption menus;

## [0.9.4] - 2018-01-18

### Fixed
Expand Down Expand Up @@ -270,4 +281,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
[0.9.2]: https://github.com/raccoongang/xblock-video/compare/v0.9.1...v0.9.2
[0.9.3]: https://github.com/raccoongang/xblock-video/compare/v0.9.2...v0.9.3
[0.9.4]: https://github.com/raccoongang/xblock-video/compare/v0.9.3...v0.9.4
[Unreleased]: https://github.com/raccoongang/xblock-video/compare/v0.9.4...HEAD
[0.10.0]: https://github.com/raccoongang/xblock-video/compare/v0.9.4...v0.10.0
[Unreleased]: https://github.com/raccoongang/xblock-video/compare/v0.10.0...HEAD
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ def package_data(pkg, roots):
dependency_links=[
# At the moment of writing PyPI hosts outdated version of xblock-utils, hence git
# Replace dependency links with numbered versions when it's released on PyPI
'git+https://github.com/edx/[email protected]#egg=xblock-utils-1.0.2',
'git+https://github.com/edx/[email protected]#egg=xblock-utils-1.0.3',
'git+https://github.com/edx/[email protected]#egg=xblock-utils-1.0.5',
],
install_requires=[
'XBlock>=0.4.10,<2.0.0',
'xblock-utils>=1.0.2,<=1.0.3',
'xblock-utils>=1.0.2,<=1.0.5',
'pycaption>=0.7.1,<1.0', # The latest Python 2.7 compatible version
'requests>=2.9.1,<3.0.0',
'babelfish>=0.5.5,<0.6.0',
Expand Down
2 changes: 1 addition & 1 deletion video_xblock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Video xblock module.
"""

__version__ = '0.9.4'
__version__ = '0.10.0'

# pylint: disable=wildcard-import
from .video_xblock import * # nopep8
12 changes: 12 additions & 0 deletions video_xblock/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ def convert_caps_to_vtt(caps):
return WebVTTWriter().write(reader().read(caps))
return u''

@staticmethod
def vtt_to_text(vtt_content):
"""
Utility method to extract text from WebVTT format transcript.
"""
text_lines = []
for line in vtt_content.splitlines():
if '-->' in line or line == '':
continue
text_lines.append(line)
return ' '.join(text_lines)

def route_transcripts(self):
"""
Re-route transcripts to appropriate handler.
Expand Down
8 changes: 4 additions & 4 deletions video_xblock/static/css/brightcove.css
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ body {
font-size: 13px !important;
}
.vjs-playback-rate .vjs-playback-rate-value {
top: 3px !important;
top: 1px !important;
padding: 2px 0 0 76px;
color: #e7ecee;
text-align: left;
Expand Down Expand Up @@ -530,7 +530,7 @@ body .video-js .vjs-menu-button-popup .vjs-menu .vjs-menu-item:hover {
display: none !important;
}
.vjs-v6 .vjs-fullscreen-control.vjs-button > .vjs-icon-placeholder:before {
line-height: 1.8 !important;
line-height: 1.6 !important;
font-size: 24px;
}

Expand All @@ -544,7 +544,7 @@ body .video-js .vjs-menu-button-popup .vjs-menu .vjs-menu-item:hover {
}

.video-js.vjs-v6 .vjs-play-control.vjs-button > .vjs-icon-placeholder:before {
line-height: 1.8 !important;
line-height: 1.6 !important;
font-size: 24px;
}

Expand Down Expand Up @@ -579,7 +579,7 @@ body .video-js .vjs-menu-button-popup .vjs-menu .vjs-menu-item:hover {
display: none;
}
.vjs-v6.video-js .vjs-fullscreen-control {
right: 125px !important;
right: 80px !important;
}
.vjs-v6 .fa-quote-left:before,
.vjs-v6 .vjs-menu-button.vjs-menu-button-popup.vjs-control.vjs-button.icon.fa.fa-caret-left.vjs-singleton:before,
Expand Down
5 changes: 0 additions & 5 deletions video_xblock/static/js/videojs/toggle-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@ domReady(function() {
return el;
},
onClick: function onClick(event) {
var menuItem = this.$$('.vjs-menu-item', this.el_.parentNode);
var el = event.currentTarget;
var self = this;
var tracks = this.player_.textTracks();
Array.from(menuItem).forEach(function(caption) {
caption.classList.remove('vjs-selected');
});
el.classList.add('vjs-selected');

tracks.tracks_.forEach(function(track) {
if (track.kind === 'captions') {
Expand Down
4 changes: 4 additions & 0 deletions video_xblock/static/vendor/js/jquery.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions video_xblock/static/video-xblock-karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ module.exports = function (config) {

// list of files / patterns to load in the browser
files: [
'https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js',
'vendor/js/jquery.min.js',
'vendor/js/video.min.js',
'js/spec/test-context.js',
'js/base.js',
'js/runtime-handlers.js',
'js/studio-edit/utils.js',
'js/studio-edit/transcripts-manual-upload.js',
'js/spec/*spec.js',
'js/spec/studio-edit/*spec.js'
'js/spec/studio-edit/*spec.js',
'js/studio-edit/transcripts-manual-upload.js'
],
plugins: [
'karma-chrome-launcher',
Expand Down
45 changes: 45 additions & 0 deletions video_xblock/video_xblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,3 +834,48 @@ def get_enabled_managed_transcripts(self):
except ValueError:
log.exception("JSON parser can't handle 'self.transcripts' field value: {}".format(self.transcripts))
return []

def index_dictionary(self):
"""
Part of edx-platform search index API.
Is invoked during course [re]index operation.
Takes enabled transcripts' content and puts it to search index.
"""
xblock_body = super(VideoXBlock, self).index_dictionary()
video_body = {"display_name": self.display_name}

content = None
enabled_transcripts = self.route_transcripts()
for transcript in enabled_transcripts:
asset_file_name = transcript[u'url'].split('@')[-1]
try:
if transcript['source'] in [TranscriptSource.MANUAL, TranscriptSource.DEFAULT]:
asset_location = self.static_content.compute_location(self.course_key, asset_file_name)
asset = self.contentstore().find(asset_location) # pylint: disable=not-callable
content = asset.data
elif transcript['source'] == TranscriptSource.THREE_PLAY_MEDIA:
external_transcript = self.fetch_single_3pm_translation({
'id': transcript['id'], 'language_id': transcript['lang_id']
})
content = external_transcript and external_transcript.content
except IOError:
log.exception("Transcript indexing failure: can't fetch external transcript[{}]".format(transcript))
except (ValueError, KeyError, TypeError, AttributeError):
log.exception(
"Transcript indexing failure: can't parse transcript for indexing: [{}]".format(transcript)
)
else:
if content:
content_ = self.vtt_to_text(content)
video_body.update({transcript[u'lang']: content_})
finally:
content = None

if "content" in xblock_body:
xblock_body["content"].update(video_body)
else:
xblock_body["content"] = video_body
xblock_body["content_type"] = "Video"

return xblock_body

0 comments on commit b859c69

Please sign in to comment.