@ormoshe/js-video-url-parser 0.5.3 → 0.5.5

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.
@@ -1609,6 +1609,51 @@
1609
1609
 
1610
1610
  base.bind(new Voomly());
1611
1611
 
1612
+ var combineParams$g = util.combineParams;
1613
+
1614
+ function Spotlightr() {
1615
+ this.provider = 'spotlightr';
1616
+ this.defaultFormat = 'long';
1617
+ this.formats = {
1618
+ long: this.createLongUrl,
1619
+ };
1620
+ this.mediaTypes = {
1621
+ VIDEO: 'video',
1622
+ };
1623
+ }
1624
+
1625
+ Spotlightr.prototype.parseUrl = function(url) {
1626
+ var match = url.match(
1627
+ /(?:watch|embed)\/([a-zA-Z\d]+)/i
1628
+ );
1629
+ return match ? match[1] : undefined;
1630
+ };
1631
+
1632
+ Spotlightr.prototype.parse = function(url, params) {
1633
+ var result = {
1634
+ mediaType: this.mediaTypes.VIDEO,
1635
+ params: params,
1636
+ id: this.parseUrl(url)
1637
+ };
1638
+ return result.id ? result : undefined;
1639
+ };
1640
+
1641
+ Spotlightr.prototype.createUrl = function(baseUrl, vi, params) {
1642
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1643
+ return undefined;
1644
+ }
1645
+
1646
+ var url = baseUrl + vi.id;
1647
+ url += combineParams$g(params);
1648
+ return url;
1649
+ };
1650
+
1651
+ Spotlightr.prototype.createLongUrl = function(vi, params) {
1652
+ return this.createUrl('https://videos.cdn.spotlightr.com/watch/', vi, params);
1653
+ };
1654
+
1655
+ base.bind(new Spotlightr());
1656
+
1612
1657
  var lib = base;
1613
1658
 
1614
1659
  return lib;
package/lib/index.d.ts CHANGED
@@ -15,4 +15,5 @@ export * from './provider/youku';
15
15
  export * from './provider/youtube';
16
16
  export * from './provider/ted';
17
17
  export * from './provider/tiktok';
18
- export * from './provider/voomly';
18
+ export * from './provider/voomly';
19
+ export * from './provider/spotlightr';
package/lib/index.js CHANGED
@@ -13,6 +13,7 @@ require('./provider/soundcloud');
13
13
  require('./provider/teachertube');
14
14
  require('./provider/tiktok');
15
15
  require('./provider/voomly');
16
+ require('./provider/spotlightr');
16
17
  require('./provider/ted');
17
18
  require('./provider/facebook');
18
19
  module.exports = parser;
@@ -0,0 +1,14 @@
1
+ import { VideoInfo } from '../urlParser';
2
+
3
+ export interface SpotlightrUrlParameters {
4
+ [key: string]: any;
5
+ }
6
+
7
+ export type SpotlightrMediaTypes = 'video';
8
+
9
+ export interface SpotlightrVideoInfo extends VideoInfo<SpotlightrUrlParameters, SpotlightrMediaTypes> {
10
+ provider: 'spotlightr';
11
+ channel: string;
12
+ }
13
+
14
+ export type SpotlightrParseResult = SpotlightrVideoInfo | undefined;
@@ -0,0 +1,47 @@
1
+ const { combineParams } = require('../util');
2
+
3
+ function Spotlightr() {
4
+ this.provider = 'spotlightr';
5
+ this.defaultFormat = 'long';
6
+ this.formats = {
7
+ long: this.createLongUrl,
8
+ };
9
+ this.mediaTypes = {
10
+ VIDEO: 'video',
11
+ };
12
+ }
13
+
14
+ module.exports = Spotlightr;
15
+
16
+ Spotlightr.prototype.parseUrl = function(url) {
17
+ var match = url.match(
18
+ /(?:watch|embed)\/([a-zA-Z\d]+)/i
19
+ );
20
+ //var match = url.match(/(?:\/(\d+))?\/watch(?:\/.*?)?\/(\d+)/i);
21
+ return match ? match[1] : undefined;
22
+ };
23
+
24
+ Spotlightr.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
+ Spotlightr.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
+ Spotlightr.prototype.createLongUrl = function(vi, params) {
44
+ return this.createUrl('https://videos.cdn.spotlightr.com/watch/', vi, params);
45
+ };
46
+
47
+ require('../base').bind(new Spotlightr());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ormoshe/js-video-url-parser",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
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",