@ormoshe/js-video-url-parser 0.5.14 → 0.5.16

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.
@@ -1791,7 +1791,7 @@
1791
1791
 
1792
1792
  Groove.prototype.parse = function(url, params) {
1793
1793
  var match = url.match(
1794
- /(?:play|embed)\/([\w-]+)\/([\w-]+)/i
1794
+ /(?:videopage)\/([\w-]+)\/([\w-]+)/i
1795
1795
  );
1796
1796
  var result = {
1797
1797
  mediaType: this.mediaTypes.VIDEO,
@@ -1808,7 +1808,7 @@
1808
1808
  }
1809
1809
 
1810
1810
  var url = baseUrl + vi.library + '/' + vi.id;
1811
- url += combineParams(params);
1811
+ url += combineParams$k(params);
1812
1812
  return url;
1813
1813
  };
1814
1814
 
@@ -1818,6 +1818,47 @@
1818
1818
 
1819
1819
  base.bind(new Groove());
1820
1820
 
1821
+ var combineParams$l = util.combineParams;
1822
+
1823
+ function Streamable() {
1824
+ this.provider = 'streamable';
1825
+ this.defaultFormat = 'long';
1826
+ this.formats = {
1827
+ long: this.createLongUrl,
1828
+ };
1829
+ this.mediaTypes = {
1830
+ VIDEO: 'video',
1831
+ };
1832
+ }
1833
+
1834
+ Streamable.prototype.parse = function(url, params) {
1835
+ var match = url.match(
1836
+ /com\/(?:streamable\/)?([\w-]+)/
1837
+ );
1838
+ var result = {
1839
+ mediaType: this.mediaTypes.VIDEO,
1840
+ params: params,
1841
+ id: match[1]
1842
+ };
1843
+ return result.id ? result : undefined;
1844
+ };
1845
+
1846
+ Streamable.prototype.createUrl = function(baseUrl, vi, params) {
1847
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1848
+ return undefined;
1849
+ }
1850
+
1851
+ var url = baseUrl + vi.library + '/' + vi.id;
1852
+ url += combineParams$l(params);
1853
+ return url;
1854
+ };
1855
+
1856
+ Streamable.prototype.createLongUrl = function(vi, params) {
1857
+ return this.createUrl('https://streamable.com/', vi, params);
1858
+ };
1859
+
1860
+ base.bind(new Groove());
1861
+
1821
1862
  var lib = base;
1822
1863
 
1823
1864
  return lib;
@@ -15,7 +15,7 @@ module.exports = Groove;
15
15
 
16
16
  Groove.prototype.parse = function(url, params) {
17
17
  var match = url.match(
18
- /(?:play|embed)\/([\w-]+)\/([\w-]+)/i
18
+ /(?:videopage)\/([\w-]+)\/([\w-]+)/i
19
19
  );
20
20
  var result = {
21
21
  mediaType: this.mediaTypes.VIDEO,
@@ -0,0 +1,14 @@
1
+ import { VideoInfo } from '../urlParser';
2
+
3
+ export interface StreamableUrlParameters {
4
+ [key: string]: any;
5
+ }
6
+
7
+ export type StreamableMediaTypes = 'video';
8
+
9
+ export interface StreamableVideoInfo extends VideoInfo<StreamableUrlParameters, StreamableMediaTypes> {
10
+ provider: 'streamable';
11
+ channel: string;
12
+ }
13
+
14
+ export type StreamableParseResult = StreamableVideoInfo | undefined;
@@ -0,0 +1,47 @@
1
+ const { combineParams } = require('../util');
2
+
3
+ function Streamable() {
4
+ this.provider = 'streamable';
5
+ this.defaultFormat = 'long';
6
+ this.formats = {
7
+ long: this.createLongUrl,
8
+ };
9
+ this.mediaTypes = {
10
+ VIDEO: 'video',
11
+ };
12
+ }
13
+
14
+ module.exports = Streamable;
15
+
16
+ Streamable.prototype.parseUrl = function(url) {
17
+ var match = url.match(
18
+ /com\/(?:streamable\/)?([\w-]+)/
19
+ );
20
+ //var match = url.match(/(?:\/(\d+))?\/watch(?:\/.*?)?\/(\d+)/i);
21
+ return match ? match[1] : undefined;
22
+ };
23
+
24
+ Streamable.prototype.parse = function(url, params) {
25
+ var result = {
26
+ mediaType: this.mediaTypes.VIDEO,
27
+ params: params,
28
+ id: this.parseUrl(url)
29
+ };
30
+ return result.id ? result : undefined;
31
+ };
32
+
33
+ Streamable.prototype.createUrl = function(baseUrl, vi, params) {
34
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
35
+ return undefined;
36
+ }
37
+
38
+ var url = baseUrl + vi.id;
39
+ url += combineParams(params);
40
+ return url;
41
+ };
42
+
43
+ Streamable.prototype.createLongUrl = function(vi, params) {
44
+ return this.createUrl('https://streamable.com/e/', vi, params);
45
+ };
46
+
47
+ require('../base').bind(new Streamable());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ormoshe/js-video-url-parser",
3
- "version": "0.5.14",
3
+ "version": "0.5.16",
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",