@ormoshe/js-video-url-parser 0.5.6 → 0.5.8

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.
@@ -937,7 +937,7 @@
937
937
  }
938
938
 
939
939
  YouTube.prototype.parseVideoUrl = function (url) {
940
- var match = url.match(/(?:(?:v|vi|be|videos|embed)\/(?!videoseries)|(?:v|ci)=)([\w-]{11})/i);
940
+ var match = url.match(/(?:(?:v|vi|be|videos|shorts|embed)\/(?!videoseries)|(?:v|ci)=)([\w-]{11})/i);
941
941
  return match ? match[1] : undefined;
942
942
  };
943
943
 
@@ -1698,6 +1698,48 @@
1698
1698
 
1699
1699
  base.bind(new Bunny());
1700
1700
 
1701
+ var combineParams$i = util.combineParams;
1702
+
1703
+ function Canva() {
1704
+ this.provider = 'canva';
1705
+ this.defaultFormat = 'long';
1706
+ this.formats = {
1707
+ long: this.createLongUrl,
1708
+ };
1709
+ this.mediaTypes = {
1710
+ VIDEO: 'video',
1711
+ };
1712
+ }
1713
+
1714
+ Canva.prototype.parse = function(url, params) {
1715
+ var match = url.match(
1716
+ /(?:design)\/([a-zA-Z\d]+)\/([\w-]+)/i
1717
+ );
1718
+ var result = {
1719
+ mediaType: this.mediaTypes.VIDEO,
1720
+ params: params,
1721
+ library: match[1],
1722
+ id: match[2]
1723
+ };
1724
+ return result.id ? result : undefined;
1725
+ };
1726
+
1727
+ Canva.prototype.createUrl = function(baseUrl, vi, params) {
1728
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1729
+ return undefined;
1730
+ }
1731
+
1732
+ var url = baseUrl + vi.library + '/' + vi.id + '/watch?embed';
1733
+ url += combineParams$i(params);
1734
+ return url;
1735
+ };
1736
+
1737
+ Canva.prototype.createLongUrl = function(vi, params) {
1738
+ return this.createUrl('https://www.canva.com/design/', vi, params);
1739
+ };
1740
+
1741
+ base.bind(new Canva());
1742
+
1701
1743
  var lib = base;
1702
1744
 
1703
1745
  return lib;
package/lib/index.d.ts CHANGED
@@ -17,4 +17,5 @@ export * from './provider/ted';
17
17
  export * from './provider/tiktok';
18
18
  export * from './provider/voomly';
19
19
  export * from './provider/spotlightr';
20
- export * from './provider/bunny';
20
+ export * from './provider/bunny';
21
+ export * from './provider/canva';
package/lib/index.js CHANGED
@@ -15,6 +15,7 @@ require('./provider/tiktok');
15
15
  require('./provider/voomly');
16
16
  require('./provider/spotlightr');
17
17
  require('./provider/bunny');
18
+ require('./provider/canva');
18
19
  require('./provider/ted');
19
20
  require('./provider/facebook');
20
21
  module.exports = parser;
@@ -0,0 +1,43 @@
1
+ const { combineParams } = require('../util');
2
+
3
+ function Canva() {
4
+ this.provider = 'canva';
5
+ this.defaultFormat = 'long';
6
+ this.formats = {
7
+ long: this.createLongUrl,
8
+ };
9
+ this.mediaTypes = {
10
+ VIDEO: 'video',
11
+ };
12
+ }
13
+
14
+ module.exports = Canva;
15
+
16
+ Canva.prototype.parse = function(url, params) {
17
+ var match = url.match(
18
+ /(?:design)\/([a-zA-Z\d]+)\/([\w-]+)/i
19
+ );
20
+ var result = {
21
+ mediaType: this.mediaTypes.VIDEO,
22
+ params: params,
23
+ library: match[1],
24
+ id: match[2]
25
+ };
26
+ return result.id ? result : undefined;
27
+ };
28
+
29
+ Canva.prototype.createUrl = function(baseUrl, vi, params) {
30
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
31
+ return undefined;
32
+ }
33
+
34
+ var url = baseUrl + vi.library + '/' + vi.id + '/watch?embed';
35
+ url += combineParams(params);
36
+ return url;
37
+ };
38
+
39
+ Canva.prototype.createLongUrl = function(vi, params) {
40
+ return this.createUrl('https://www.canva.com/design/', vi, params);
41
+ };
42
+
43
+ require('../base').bind(new Canva());
@@ -0,0 +1,14 @@
1
+ import { VideoInfo } from '../urlParser';
2
+
3
+ export interface CanvaUrlParameters {
4
+ [key: string]: any;
5
+ }
6
+
7
+ export type CanvaMediaTypes = 'video';
8
+
9
+ export interface CanvaVideoInfo extends VideoInfo<CanvaUrlParameters, CanvaMediaTypes> {
10
+ provider: 'canva';
11
+ channel: string;
12
+ }
13
+
14
+ export type CanvaParseResult = CanvaVideoInfo | undefined;
@@ -38,7 +38,7 @@ module.exports = YouTube;
38
38
 
39
39
  YouTube.prototype.parseVideoUrl = function(url) {
40
40
  var match = url.match(
41
- /(?:(?:v|vi|be|videos|embed)\/(?!videoseries)|(?:v|ci)=)([\w-]{11})/i
41
+ /(?:(?:v|vi|be|videos|shorts|embed)\/(?!videoseries)|(?:v|ci)=)([\w-]{11})/i
42
42
  );
43
43
  return match ? match[1] : undefined;
44
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ormoshe/js-video-url-parser",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
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",