@ormoshe/js-video-url-parser 0.5.10 → 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.
package/dist/jsVideoUrlParser.js
CHANGED
|
@@ -1737,6 +1737,45 @@
|
|
|
1737
1737
|
|
|
1738
1738
|
base.bind(new Canva());
|
|
1739
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
|
+
|
|
1740
1779
|
var lib = base;
|
|
1741
1780
|
|
|
1742
1781
|
return lib;
|
|
@@ -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