@ormoshe/js-video-url-parser 0.5.9 → 0.5.11

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.
@@ -1712,9 +1712,7 @@
1712
1712
  }
1713
1713
 
1714
1714
  Canva.prototype.parse = function(url, params) {
1715
- var match = url.match(
1716
- /(?:watch|design)\/([a-zA-Z\d]+)/i
1717
- );
1715
+ var match = url.match(/\/design\/([\w-]+)/);
1718
1716
  var result = {
1719
1717
  mediaType: this.mediaTypes.VIDEO,
1720
1718
  params: params,
@@ -1739,6 +1737,45 @@
1739
1737
 
1740
1738
  base.bind(new Canva());
1741
1739
 
1740
+ var combineParams$j = util.combineParams;
1741
+
1742
+ function Canva() {
1743
+ this.provider = 'drive.google';
1744
+ this.defaultFormat = 'long';
1745
+ this.formats = {
1746
+ long: this.createLongUrl,
1747
+ };
1748
+ this.mediaTypes = {
1749
+ VIDEO: 'video',
1750
+ };
1751
+ }
1752
+
1753
+ Canva.prototype.parse = function(url, params) {
1754
+ var match = url.match(/\/d\/([\w-]+)/);
1755
+ var result = {
1756
+ mediaType: this.mediaTypes.VIDEO,
1757
+ params: params,
1758
+ id: match[1]
1759
+ };
1760
+ return result.id ? result : undefined;
1761
+ };
1762
+
1763
+ Canva.prototype.createUrl = function(baseUrl, vi, params) {
1764
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1765
+ return undefined;
1766
+ }
1767
+
1768
+ var url = baseUrl + vi.id + '/preview';
1769
+ url += combineParams$j(params);
1770
+ return url;
1771
+ };
1772
+
1773
+ Canva.prototype.createLongUrl = function(vi, params) {
1774
+ return this.createUrl('https://drive.google.com/file/d/', vi, params);
1775
+ };
1776
+
1777
+ base.bind(new Canva());
1778
+
1742
1779
  var lib = base;
1743
1780
 
1744
1781
  return lib;
@@ -14,9 +14,7 @@ function Canva() {
14
14
  module.exports = Canva;
15
15
 
16
16
  Canva.prototype.parse = function(url, params) {
17
- var match = url.match(
18
- /(?:watch|design)\/([a-zA-Z\d]+)/i
19
- );
17
+ var match = url.match(/\/design\/([\w-]+)/);
20
18
  var result = {
21
19
  mediaType: this.mediaTypes.VIDEO,
22
20
  params: params,
@@ -0,0 +1,44 @@
1
+ const { combineParams } = require('../util');
2
+
3
+ function GoogleDrive() {
4
+ this.provider = 'drive.google';
5
+ this.defaultFormat = 'long';
6
+ this.formats = {
7
+ long: this.createLongUrl,
8
+ };
9
+ this.mediaTypes = {
10
+ VIDEO: 'video',
11
+ };
12
+ }
13
+
14
+ module.exports = GoogleDrive;
15
+
16
+ GoogleDrive.prototype.parseUrl = function(url) {
17
+ var match = url.match(/\/d\/([\w-]+)/);
18
+ return match ? match[1] : undefined;
19
+ };
20
+
21
+ GoogleDrive.prototype.parse = function(url, params) {
22
+ var result = {
23
+ mediaType: this.mediaTypes.VIDEO,
24
+ params: params,
25
+ id: this.parseUrl(url)
26
+ };
27
+ return result.id ? result : undefined;
28
+ };
29
+
30
+ GoogleDrive.prototype.createUrl = function(baseUrl, vi, params) {
31
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
32
+ return undefined;
33
+ }
34
+
35
+ var url = baseUrl + vi.id;
36
+ url += combineParams(params);
37
+ return url;
38
+ };
39
+
40
+ GoogleDrive.prototype.createLongUrl = function(vi, params) {
41
+ return this.createUrl('https://drive.google.com/file/d/', vi, params);
42
+ };
43
+
44
+ require('../base').bind(new GoogleDrive());
@@ -0,0 +1,14 @@
1
+ import { VideoInfo } from '../urlParser';
2
+
3
+ export interface GoogleDriveUrlParameters {
4
+ [key: string]: any;
5
+ }
6
+
7
+ export type GoogleDriveMediaTypes = 'video';
8
+
9
+ export interface GoogleDriveVideoInfo extends VideoInfo<GoogleDriveUrlParameters, GoogleDriveMediaTypes> {
10
+ provider: 'drive.google';
11
+ channel: string;
12
+ }
13
+
14
+ export type VoomlyParseResult = GoogleDriveVideoInfo | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ormoshe/js-video-url-parser",
3
- "version": "0.5.9",
3
+ "version": "0.5.11",
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",