@ormoshe/js-video-url-parser 0.5.25 → 0.5.26

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/lib/index.js CHANGED
@@ -16,6 +16,7 @@ require('./provider/voomly');
16
16
  require('./provider/spotlightr');
17
17
  require('./provider/bunny');
18
18
  require('./provider/canva');
19
+ require('./provider/descript');
19
20
  require('./provider/ted');
20
21
  require('./provider/facebook');
21
22
  require('./provider/bigcommand');
@@ -0,0 +1,45 @@
1
+ const { combineParams } = require('../util');
2
+
3
+ function Descript() {
4
+ this.provider = 'descript';
5
+ this.defaultFormat = 'long';
6
+ this.formats = {
7
+ long: this.createLongUrl,
8
+ };
9
+ this.mediaTypes = {
10
+ VIDEO: 'video',
11
+ };
12
+ }
13
+
14
+ module.exports = Descript;
15
+
16
+ Descript.prototype.parse = function(url, params) {
17
+ var match = url.match(
18
+ /(?:view|embed)\/([\w-]+)/i
19
+ );
20
+ if (!match) {
21
+ return undefined;
22
+ }
23
+ var result = {
24
+ mediaType: this.mediaTypes.VIDEO,
25
+ params: params,
26
+ id: match[1]
27
+ };
28
+ return result.id ? result : undefined;
29
+ };
30
+
31
+ Descript.prototype.createUrl = function(baseUrl, vi, params) {
32
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
33
+ return undefined;
34
+ }
35
+
36
+ var url = baseUrl + vi.id;
37
+ url += combineParams(params);
38
+ return url;
39
+ };
40
+
41
+ Descript.prototype.createLongUrl = function(vi, params) {
42
+ return this.createUrl('https://share.descript.com/embed/', vi, params);
43
+ };
44
+
45
+ require('../base').bind(new Descript());
@@ -0,0 +1,14 @@
1
+ import { VideoInfo } from '../urlParser';
2
+
3
+ export interface DescriptUrlParameters {
4
+ [key: string]: any;
5
+ }
6
+
7
+ export type DescriptMediaTypes = 'video';
8
+
9
+ export interface DescriptVideoInfo extends VideoInfo<DescriptUrlParameters, DescriptMediaTypes> {
10
+ provider: 'descript';
11
+ channel: string;
12
+ }
13
+
14
+ export type DescriptParseResult = DescriptVideoInfo | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ormoshe/js-video-url-parser",
3
- "version": "0.5.25",
3
+ "version": "0.5.26",
4
4
  "description": "A parser to extract provider, video id, starttime and others from YouTube, Vimeo, ... urls",
5
5
  "main": "lib/index.js",
6
6
  "browser": "dist/jsVideoUrlParser.js",