@ndla/video-search 4.1.43 → 4.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/PreviewVideo.js +12 -16
- package/es/VideoLoadMoreButton.js +15 -16
- package/es/VideoSearch.js +201 -230
- package/es/VideoSearchForm.js +46 -73
- package/es/VideoSearchList.js +32 -37
- package/es/VideoSearchResultBrightcove.js +39 -40
- package/es/VideoSearchResultYouTube.js +32 -37
- package/es/VideoTabs.js +8 -15
- package/es/index.js +8 -0
- package/es/shapes.js +3 -3
- package/es/videoHelpers.js +14 -15
- package/lib/PreviewVideo.js +20 -22
- package/lib/VideoLoadMoreButton.js +24 -24
- package/lib/VideoSearch.js +210 -238
- package/lib/VideoSearchForm.js +55 -81
- package/lib/VideoSearchList.js +41 -45
- package/lib/VideoSearchResultBrightcove.js +47 -46
- package/lib/VideoSearchResultYouTube.js +40 -43
- package/lib/VideoTabs.js +17 -23
- package/lib/index.js +8 -2
- package/lib/shapes.js +4 -7
- package/lib/videoHelpers.js +14 -15
- package/package.json +8 -8
package/lib/index.js
CHANGED
|
@@ -6,5 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _VideoSearch = _interopRequireDefault(require("./VideoSearch"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Copyright (c) 2017-present, NDLA.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
var _default = exports.default = _VideoSearch.default;
|
package/lib/shapes.js
CHANGED
|
@@ -14,15 +14,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
const LicenseShape = exports.LicenseShape = _propTypes.default.shape({
|
|
18
18
|
short: _propTypes.default.string.isRequired,
|
|
19
19
|
title: _propTypes.default.string.isRequired,
|
|
20
20
|
userFriendlyTitle: _propTypes.default.string.isRequired,
|
|
21
21
|
description: _propTypes.default.string.isRequired,
|
|
22
22
|
rights: _propTypes.default.arrayOf(_propTypes.default.string).isRequired
|
|
23
23
|
});
|
|
24
|
-
exports.
|
|
25
|
-
var BrightcoveShape = _propTypes.default.shape({
|
|
24
|
+
const BrightcoveShape = exports.BrightcoveShape = _propTypes.default.shape({
|
|
26
25
|
id: _propTypes.default.string.isRequired,
|
|
27
26
|
name: _propTypes.default.string.isRequired,
|
|
28
27
|
custom_fields: _propTypes.default.shape({
|
|
@@ -35,8 +34,7 @@ var BrightcoveShape = _propTypes.default.shape({
|
|
|
35
34
|
})
|
|
36
35
|
})
|
|
37
36
|
});
|
|
38
|
-
exports.
|
|
39
|
-
var YouTubeShape = _propTypes.default.shape({
|
|
37
|
+
const YouTubeShape = exports.YouTubeShape = _propTypes.default.shape({
|
|
40
38
|
pagemap: _propTypes.default.shape({
|
|
41
39
|
videoobject: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
42
40
|
name: _propTypes.default.string.isRequired,
|
|
@@ -49,5 +47,4 @@ var YouTubeShape = _propTypes.default.shape({
|
|
|
49
47
|
datepublished: _propTypes.default.string.isRequired
|
|
50
48
|
}))
|
|
51
49
|
})
|
|
52
|
-
});
|
|
53
|
-
exports.YouTubeShape = YouTubeShape;
|
|
50
|
+
});
|
package/lib/videoHelpers.js
CHANGED
|
@@ -12,11 +12,10 @@ exports.youTubeDurationToSeconds = exports.setYouTubeDuration = exports.setLocal
|
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const getLastPage = (search, type) => {
|
|
16
16
|
if (type === 'youtube') {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var request = search.queries.request[0];
|
|
17
|
+
if (search?.queries?.request?.length > 0) {
|
|
18
|
+
const request = search.queries.request[0];
|
|
20
19
|
if (request.totalResults && request.count) {
|
|
21
20
|
return Math.ceil(request.totalResults / request.count);
|
|
22
21
|
}
|
|
@@ -26,17 +25,17 @@ var getLastPage = function getLastPage(search, type) {
|
|
|
26
25
|
return 0;
|
|
27
26
|
};
|
|
28
27
|
exports.getLastPage = getLastPage;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
const youTubeDurationToSeconds = duration => {
|
|
29
|
+
const match = duration.match(/PT(\d+H)?(\d+M)?(\d+S)?/);
|
|
30
|
+
const hours = parseInt(match[1], 10) || 0;
|
|
31
|
+
const minutes = parseInt(match[2], 10) || 0;
|
|
32
|
+
const seconds = parseInt(match[3], 10) || 0;
|
|
34
33
|
return hours * 3600 + minutes * 60 + seconds;
|
|
35
34
|
};
|
|
36
35
|
exports.youTubeDurationToSeconds = youTubeDurationToSeconds;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const setLocaleDate = (date, locale) => {
|
|
37
|
+
const newDate = new Date(Date.parse(date));
|
|
38
|
+
const options = {
|
|
40
39
|
year: 'numeric',
|
|
41
40
|
month: '2-digit',
|
|
42
41
|
day: '2-digit'
|
|
@@ -44,10 +43,10 @@ var setLocaleDate = function setLocaleDate(date, locale) {
|
|
|
44
43
|
return newDate.toLocaleDateString(locale, options);
|
|
45
44
|
};
|
|
46
45
|
exports.setLocaleDate = setLocaleDate;
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
const setYouTubeDuration = duration => {
|
|
47
|
+
const seconds = youTubeDurationToSeconds(duration);
|
|
49
48
|
if (seconds > 86400) {
|
|
50
|
-
return
|
|
49
|
+
return `24h+ ${new Date(seconds * 1000).toISOString().substr(11, 8)}`;
|
|
51
50
|
}
|
|
52
51
|
return new Date(seconds * 1000).toISOString().substr(11, 8);
|
|
53
52
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/video-search",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.46",
|
|
4
4
|
"description": "A simple library for searching NDLA videos",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
"prop-types": "^15.8.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ndla/button": "^12.0.
|
|
35
|
-
"@ndla/icons": "^4.2.
|
|
36
|
-
"@ndla/licenses": "^7.2.
|
|
37
|
-
"@ndla/notion": "^6.0.
|
|
38
|
-
"@ndla/pager": "^2.2.
|
|
39
|
-
"@ndla/tabs": "^3.2.
|
|
34
|
+
"@ndla/button": "^12.0.17",
|
|
35
|
+
"@ndla/icons": "^4.2.4",
|
|
36
|
+
"@ndla/licenses": "^7.2.4",
|
|
37
|
+
"@ndla/notion": "^6.0.18",
|
|
38
|
+
"@ndla/pager": "^2.2.42",
|
|
39
|
+
"@ndla/tabs": "^3.2.5",
|
|
40
40
|
"react-bem-helper": "^1.4.1"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "5c65dfc8de95fb464182f86a40b74868ca30a29e"
|
|
46
46
|
}
|