@ormoshe/js-video-url-parser 0.5.24 → 0.5.26

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.
@@ -1,1990 +1,1654 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
- typeof define === 'function' && define.amd ? define(factory) :
4
- (global = global || self, global.urlParser = factory());
5
- }(this, (function () { 'use strict';
6
-
7
- function _typeof(obj) {
8
- "@babel/helpers - typeof";
9
-
10
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
11
- _typeof = function (obj) {
12
- return typeof obj;
13
- };
14
- } else {
15
- _typeof = function (obj) {
16
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
17
- };
18
- }
19
-
20
- return _typeof(obj);
21
- }
22
-
23
- var getQueryParams = function getQueryParams(qs) {
24
- if (typeof qs !== 'string') {
25
- return {};
26
- }
27
-
28
- qs = qs.split('+').join(' ');
29
- var params = {};
30
- var match = qs.match(/(?:[?](?:[^=]+)=(?:[^&#]*)(?:[&](?:[^=]+)=(?:[^&#]*))*(?:[#].*)?)|(?:[#].*)/);
31
- var split;
32
-
33
- if (match === null) {
34
- return {};
35
- }
36
-
37
- split = match[0].substr(1).split(/[&#=]/);
38
-
39
- for (var i = 0; i < split.length; i += 2) {
40
- params[decodeURIComponent(split[i])] = decodeURIComponent(split[i + 1] || '');
41
- }
42
-
43
- return params;
44
- };
45
-
46
- var combineParams = function combineParams(params, hasParams) {
47
- if (_typeof(params) !== 'object') {
48
- return '';
49
- }
50
-
51
- var combined = '';
52
- var i = 0;
53
- var keys = Object.keys(params);
54
-
55
- if (keys.length === 0) {
56
- return '';
57
- } //always have parameters in the same order
58
-
59
-
60
- keys.sort();
61
-
62
- if (!hasParams) {
63
- combined += '?' + keys[0] + '=' + params[keys[0]];
64
- i += 1;
65
- }
66
-
67
- for (; i < keys.length; i += 1) {
68
- combined += '&' + keys[i] + '=' + params[keys[i]];
69
- }
70
-
71
- return combined;
72
- }; //parses strings like 1h30m20s to seconds
73
-
74
-
75
- function getLetterTime(timeString) {
76
- var totalSeconds = 0;
77
- var timeValues = {
78
- 's': 1,
79
- 'm': 1 * 60,
80
- 'h': 1 * 60 * 60,
81
- 'd': 1 * 60 * 60 * 24,
82
- 'w': 1 * 60 * 60 * 24 * 7
83
- };
84
- var timePairs; //expand to "1 h 30 m 20 s" and split
85
-
86
- timeString = timeString.replace(/([smhdw])/g, ' $1 ').trim();
87
- timePairs = timeString.split(' ');
88
-
89
- for (var i = 0; i < timePairs.length; i += 2) {
90
- totalSeconds += parseInt(timePairs[i], 10) * timeValues[timePairs[i + 1] || 's'];
91
- }
92
-
93
- return totalSeconds;
94
- } //parses strings like 1:30:20 to seconds
95
-
96
-
97
- function getColonTime(timeString) {
98
- var totalSeconds = 0;
99
- var timeValues = [1, 1 * 60, 1 * 60 * 60, 1 * 60 * 60 * 24, 1 * 60 * 60 * 24 * 7];
100
- var timePairs = timeString.split(':');
101
-
102
- for (var i = 0; i < timePairs.length; i++) {
103
- totalSeconds += parseInt(timePairs[i], 10) * timeValues[timePairs.length - i - 1];
104
- }
105
-
106
- return totalSeconds;
107
- }
108
-
109
- var getTime = function getTime(timeString) {
110
- if (typeof timeString === 'undefined') {
111
- return 0;
112
- }
113
-
114
- if (timeString.match(/^(\d+[smhdw]?)+$/)) {
115
- return getLetterTime(timeString);
116
- }
117
-
118
- if (timeString.match(/^(\d+:?)+$/)) {
119
- return getColonTime(timeString);
120
- }
121
-
122
- return 0;
123
- };
124
-
125
- var util = {
126
- getQueryParams: getQueryParams,
127
- combineParams: combineParams,
128
- getTime: getTime
129
- };
130
-
131
- var getQueryParams$1 = util.getQueryParams;
132
-
133
- function UrlParser() {
134
- for (var _i = 0, _arr = ['parseProvider', 'parse', 'bind', 'create']; _i < _arr.length; _i++) {
135
- var key = _arr[_i];
136
- this[key] = this[key].bind(this);
137
- }
138
-
139
- this.plugins = {};
140
- }
141
-
142
- var urlParser = UrlParser;
143
-
144
- UrlParser.prototype.parseProvider = function (url) {
145
- var match = url.match(/(?:(?:https?:)?\/\/)?(?:[^.]+\.)?(\w+)\./i);
146
- return match ? match[1] : undefined;
147
- };
148
-
149
- UrlParser.prototype.parse = function (url) {
150
- if (typeof url === 'undefined') {
151
- return undefined;
152
- }
153
-
154
- var provider = this.parseProvider(url);
155
- var result;
156
- var plugin = this.plugins[provider];
157
-
158
- if (!provider || !plugin || !plugin.parse) {
159
- return undefined;
160
- }
161
-
162
- result = plugin.parse.call(plugin, url, getQueryParams$1(url));
163
-
164
- if (result) {
165
- result = removeEmptyParameters(result);
166
- result.provider = plugin.provider;
167
- }
168
-
169
- return result;
170
- };
171
-
172
- UrlParser.prototype.bind = function (plugin) {
173
- this.plugins[plugin.provider] = plugin;
174
-
175
- if (plugin.alternatives) {
176
- for (var i = 0; i < plugin.alternatives.length; i += 1) {
177
- this.plugins[plugin.alternatives[i]] = plugin;
178
- }
179
- }
180
- };
181
-
182
- UrlParser.prototype.create = function (op) {
183
- if (_typeof(op) !== 'object' || _typeof(op.videoInfo) !== 'object') {
184
- return undefined;
185
- }
186
-
187
- var vi = op.videoInfo;
188
- var params = op.params;
189
- var plugin = this.plugins[vi.provider];
190
- params = params === 'internal' ? vi.params : params || {};
191
-
192
- if (plugin) {
193
- op.format = op.format || plugin.defaultFormat; // eslint-disable-next-line no-prototype-builtins
194
-
195
- if (plugin.formats.hasOwnProperty(op.format)) {
196
- return plugin.formats[op.format].apply(plugin, [vi, Object.assign({}, params)]);
197
- }
198
- }
199
-
200
- return undefined;
201
- };
202
-
203
- function removeEmptyParameters(result) {
204
- if (result.params && Object.keys(result.params).length === 0) {
205
- delete result.params;
206
- }
207
-
208
- return result;
209
- }
210
-
211
- var parser = new urlParser();
212
- var base = parser;
213
-
214
- function Allocine() {
215
- this.provider = 'allocine';
216
- this.alternatives = [];
217
- this.defaultFormat = 'embed';
218
- this.formats = {
219
- embed: this.createEmbedUrl
220
- };
221
- this.mediaTypes = {
222
- VIDEO: 'video'
223
- };
224
- }
225
-
226
- Allocine.prototype.parseUrl = function (url) {
227
- var match = url.match(/(?:\/video\/player_gen_cmedia=)([A-Za-z0-9]+)/i);
228
- return match ? match[1] : undefined;
229
- };
230
-
231
- Allocine.prototype.parse = function (url) {
232
- var result = {
233
- mediaType: this.mediaTypes.VIDEO,
234
- id: this.parseUrl(url)
235
- };
236
- return result.id ? result : undefined;
237
- };
238
-
239
- Allocine.prototype.createEmbedUrl = function (vi) {
240
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
241
- return undefined;
242
- }
243
-
244
- return 'https://player.allocine.fr/' + vi.id + '.html';
245
- };
246
-
247
- base.bind(new Allocine());
248
-
249
- var combineParams$1 = util.combineParams;
250
-
251
- function CanalPlus() {
252
- this.provider = 'canalplus';
253
- this.defaultFormat = 'embed';
254
- this.formats = {
255
- embed: this.createEmbedUrl
256
- };
257
- this.mediaTypes = {
258
- VIDEO: 'video'
259
- };
260
- }
261
-
262
- CanalPlus.prototype.parseParameters = function (params) {
263
- delete params.vid;
264
- return params;
265
- };
266
-
267
- CanalPlus.prototype.parse = function (url, params) {
268
- var _this = this;
269
-
270
- var result = {
271
- mediaType: this.mediaTypes.VIDEO,
272
- id: params.vid
273
- };
274
- result.params = _this.parseParameters(params);
275
-
276
- if (!result.id) {
277
- return undefined;
278
- }
279
-
280
- return result;
281
- };
282
-
283
- CanalPlus.prototype.createEmbedUrl = function (vi, params) {
284
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
285
- return undefined;
286
- }
287
-
288
- var url = 'http://player.canalplus.fr/embed/';
289
- params.vid = vi.id;
290
- url += combineParams$1(params);
291
- return url;
292
- };
293
-
294
- base.bind(new CanalPlus());
295
-
296
- var combineParams$2 = util.combineParams;
297
-
298
- function Coub() {
299
- this.provider = 'coub';
300
- this.defaultFormat = 'long';
301
- this.formats = {
302
- "long": this.createLongUrl,
303
- embed: this.createEmbedUrl
304
- };
305
- this.mediaTypes = {
306
- VIDEO: 'video'
307
- };
308
- }
309
-
310
- Coub.prototype.parseUrl = function (url) {
311
- var match = url.match(/(?:embed|view)\/([a-zA-Z\d]+)/i);
312
- return match ? match[1] : undefined;
313
- };
314
-
315
- Coub.prototype.parse = function (url, params) {
316
- var result = {
317
- mediaType: this.mediaTypes.VIDEO,
318
- params: params,
319
- id: this.parseUrl(url)
320
- };
321
-
322
- if (!result.id) {
323
- return undefined;
324
- }
325
-
326
- return result;
327
- };
328
-
329
- Coub.prototype.createUrl = function (baseUrl, vi, params) {
330
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
331
- return undefined;
332
- }
333
-
334
- var url = baseUrl + vi.id;
335
- url += combineParams$2(params);
336
- return url;
337
- };
338
-
339
- Coub.prototype.createLongUrl = function (vi, params) {
340
- return this.createUrl('https://coub.com/view/', vi, params);
341
- };
342
-
343
- Coub.prototype.createEmbedUrl = function (vi, params) {
344
- return this.createUrl('//coub.com/embed/', vi, params);
345
- };
346
-
347
- base.bind(new Coub());
348
-
349
- var combineParams$3 = util.combineParams,
350
- getTime$1 = util.getTime;
351
-
352
- function Dailymotion() {
353
- this.provider = 'dailymotion';
354
- this.alternatives = ['dai'];
355
- this.defaultFormat = 'long';
356
- this.formats = {
357
- "short": this.createShortUrl,
358
- "long": this.createLongUrl,
359
- embed: this.createEmbedUrl,
360
- image: this.createImageUrl
361
- };
362
- this.mediaTypes = {
363
- VIDEO: 'video'
364
- };
365
- }
366
-
367
- Dailymotion.prototype.parseParameters = function (params) {
368
- return this.parseTime(params);
369
- };
370
-
371
- Dailymotion.prototype.parseTime = function (params) {
372
- if (params.start) {
373
- params.start = getTime$1(params.start);
374
- }
375
-
376
- return params;
377
- };
378
-
379
- Dailymotion.prototype.parseUrl = function (url) {
380
- var match = url.match(/(?:\/video|ly)\/([A-Za-z0-9]+)/i);
381
- return match ? match[1] : undefined;
382
- };
383
-
384
- Dailymotion.prototype.parse = function (url, params) {
385
- var _this = this;
386
-
387
- var result = {
388
- mediaType: this.mediaTypes.VIDEO,
389
- params: _this.parseParameters(params),
390
- id: _this.parseUrl(url)
391
- };
392
- return result.id ? result : undefined;
393
- };
394
-
395
- Dailymotion.prototype.createUrl = function (base, vi, params) {
396
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
397
- return undefined;
398
- }
399
-
400
- return base + vi.id + combineParams$3(params);
401
- };
402
-
403
- Dailymotion.prototype.createShortUrl = function (vi, params) {
404
- return this.createUrl('https://dai.ly/', vi, params);
405
- };
406
-
407
- Dailymotion.prototype.createLongUrl = function (vi, params) {
408
- return this.createUrl('https://dailymotion.com/video/', vi, params);
409
- };
410
-
411
- Dailymotion.prototype.createEmbedUrl = function (vi, params) {
412
- return this.createUrl('https://www.dailymotion.com/embed/video/', vi, params);
413
- };
414
-
415
- Dailymotion.prototype.createImageUrl = function (vi, params) {
416
- delete params.start;
417
- return this.createUrl('https://www.dailymotion.com/thumbnail/video/', vi, params);
418
- };
419
-
420
- base.bind(new Dailymotion());
421
-
422
- var combineParams$4 = util.combineParams;
423
-
424
- function Loom() {
425
- this.provider = 'loom';
426
- this.defaultFormat = 'long';
427
- this.formats = {
428
- "long": this.createLongUrl,
429
- embed: this.createEmbedUrl
430
- };
431
- this.mediaTypes = {
432
- VIDEO: 'video'
433
- };
434
- }
435
-
436
- Loom.prototype.parseUrl = function (url) {
437
- var match = url.match(/(?:share|embed)\/([a-zA-Z\d]+)/i);
438
- return match ? match[1] : undefined;
439
- };
440
-
441
- Loom.prototype.parse = function (url, params) {
442
- var result = {
443
- mediaType: this.mediaTypes.VIDEO,
444
- params: params,
445
- id: this.parseUrl(url)
446
- };
447
- return result.id ? result : undefined;
448
- };
449
-
450
- Loom.prototype.createUrl = function (baseUrl, vi, params) {
451
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
452
- return undefined;
453
- }
454
-
455
- var url = baseUrl + vi.id;
456
- url += combineParams$4(params);
457
- return url;
458
- };
459
-
460
- Loom.prototype.createLongUrl = function (vi, params) {
461
- return this.createUrl('https://loom.com/share/', vi, params);
462
- };
463
-
464
- Loom.prototype.createEmbedUrl = function (vi, params) {
465
- return this.createUrl('//loom.com/embed/', vi, params);
466
- };
467
-
468
- base.bind(new Loom());
469
-
470
- var combineParams$5 = util.combineParams,
471
- getTime$2 = util.getTime;
472
-
473
- function Twitch() {
474
- this.provider = 'twitch';
475
- this.defaultFormat = 'long';
476
- this.formats = {
477
- "long": this.createLongUrl,
478
- embed: this.createEmbedUrl
479
- };
480
- this.mediaTypes = {
481
- VIDEO: 'video',
482
- STREAM: 'stream',
483
- CLIP: 'clip'
484
- };
485
- }
486
-
487
- Twitch.prototype.seperateId = function (id) {
488
- return {
489
- pre: id[0],
490
- id: id.substr(1)
491
- };
492
- };
493
-
494
- Twitch.prototype.parseChannel = function (result, params) {
495
- var channel = params.channel || params.utm_content || result.channel;
496
- delete params.utm_content;
497
- delete params.channel;
498
- return channel;
499
- };
500
-
501
- Twitch.prototype.parseUrl = function (url, result, params) {
502
- var match;
503
- match = url.match(/(clips\.)?twitch\.tv\/(?:(?:videos\/(\d+))|(\w+(?:-[\w\d-]+)?)(?:\/clip\/(\w+))?)/i);
504
-
505
- if (match && match[2]) {
506
- //video
507
- result.id = 'v' + match[2];
508
- } else if (params.video) {
509
- //video embed
510
- result.id = params.video;
511
- delete params.video;
512
- } else if (params.clip) {
513
- //clips embed
514
- result.id = params.clip;
515
- result.isClip = true;
516
- delete params.clip;
517
- } else if (match && match[1] && match[3]) {
518
- //clips.twitch.tv/id
519
- result.id = match[3];
520
- result.isClip = true;
521
- } else if (match && match[3] && match[4]) {
522
- //twitch.tv/channel/clip/id
523
- result.channel = match[3];
524
- result.id = match[4];
525
- result.isClip = true;
526
- } else if (match && match[3]) {
527
- result.channel = match[3];
528
- }
529
-
530
- return result;
531
- };
532
-
533
- Twitch.prototype.parseMediaType = function (result) {
534
- var mediaType;
535
-
536
- if (result.id) {
537
- if (result.isClip) {
538
- mediaType = this.mediaTypes.CLIP;
539
- delete result.isClip;
540
- } else {
541
- mediaType = this.mediaTypes.VIDEO;
542
- }
543
- } else if (result.channel) {
544
- mediaType = this.mediaTypes.STREAM;
545
- }
546
-
547
- return mediaType;
548
- };
549
-
550
- Twitch.prototype.parseParameters = function (params) {
551
- if (params.t) {
552
- params.start = getTime$2(params.t);
553
- delete params.t;
554
- }
555
-
556
- return params;
557
- };
558
-
559
- Twitch.prototype.parse = function (url, params) {
560
- var _this = this;
561
-
562
- var result = {};
563
- result = _this.parseUrl(url, result, params);
564
- result.channel = _this.parseChannel(result, params);
565
- result.mediaType = _this.parseMediaType(result);
566
- result.params = _this.parseParameters(params);
567
- return result.channel || result.id ? result : undefined;
568
- };
569
-
570
- Twitch.prototype.createLongUrl = function (vi, params) {
571
- var url = '';
572
-
573
- if (vi.mediaType === this.mediaTypes.STREAM && vi.channel) {
574
- url = 'https://twitch.tv/' + vi.channel;
575
- } else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
576
- var sep = this.seperateId(vi.id);
577
- url = 'https://twitch.tv/videos/' + sep.id;
578
-
579
- if (params.start) {
580
- params.t = params.start + 's';
581
- delete params.start;
582
- }
583
- } else if (vi.mediaType === this.mediaTypes.CLIP && vi.id) {
584
- if (vi.channel) {
585
- url = 'https://www.twitch.tv/' + vi.channel + '/clip/' + vi.id;
586
- } else {
587
- url = 'https://clips.twitch.tv/' + vi.id;
588
- }
589
- } else {
590
- return undefined;
591
- }
592
-
593
- url += combineParams$5(params);
594
- return url;
595
- };
596
-
597
- Twitch.prototype.createEmbedUrl = function (vi, params) {
598
- var url = 'https://player.twitch.tv/';
599
-
600
- if (vi.mediaType === this.mediaTypes.STREAM && vi.channel) {
601
- params.channel = vi.channel;
602
- } else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
603
- params.video = vi.id;
604
-
605
- if (params.start) {
606
- params.t = params.start + 's';
607
- delete params.start;
608
- }
609
- } else if (vi.mediaType === this.mediaTypes.CLIP && vi.id) {
610
- url = 'https://clips.twitch.tv/embed';
611
- params.clip = vi.id;
612
- } else {
613
- return undefined;
614
- }
615
-
616
- url += combineParams$5(params);
617
- return url;
618
- };
619
-
620
- base.bind(new Twitch());
621
-
622
- var combineParams$6 = util.combineParams,
623
- getTime$3 = util.getTime;
624
-
625
- function Vimeo() {
626
- this.provider = 'vimeo';
627
- this.alternatives = ['vimeopro'];
628
- this.defaultFormat = 'long';
629
- this.formats = {
630
- "long": this.createLongUrl,
631
- embed: this.createEmbedUrl
632
- };
633
- this.mediaTypes = {
634
- VIDEO: 'video'
635
- };
636
- }
637
-
638
- Vimeo.prototype.parseUrl = function (url) {
639
- var match = url.match(/(?:\/showcase\/\d+)?(?:\/(?:channels\/[\w]+|(?:(?:album\/\d+|groups\/[\w]+)\/)?videos?))?\/(\d+)/i);
640
- return match ? match[1] : undefined;
641
- };
642
-
643
- Vimeo.prototype.parseHash = function (url) {
644
- var match = url.match(/\/\d+\/(\w+)$/i);
645
- return match ? match[1] : undefined;
646
- };
647
-
648
- Vimeo.prototype.parseParameters = function (params) {
649
- if (params.t) {
650
- params.start = getTime$3(params.t);
651
- delete params.t;
652
- }
653
-
654
- if (params.h) {
655
- params.hash = params.h;
656
- delete params.h;
657
- }
658
-
659
- return params;
660
- };
661
-
662
- Vimeo.prototype.parse = function (url, params) {
663
- var result = {
664
- mediaType: this.mediaTypes.VIDEO,
665
- params: this.parseParameters(params),
666
- id: this.parseUrl(url)
667
- };
668
- var hash = this.parseHash(url, params);
669
-
670
- if (hash) {
671
- result.params.hash = hash;
672
- }
673
-
674
- return result.id ? result : undefined;
675
- };
676
-
677
- Vimeo.prototype.createUrl = function (baseUrl, vi, params, type) {
678
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
679
- return undefined;
680
- }
681
-
682
- var url = baseUrl + vi.id;
683
- var startTime = params.start;
684
- delete params.start;
685
-
686
- if (params.hash) {
687
- if (type === 'embed') {
688
- params.h = params.hash;
689
- } else if (type === 'long') {
690
- url += '/' + params.hash;
691
- }
692
-
693
- delete params.hash;
694
- }
695
-
696
- url += combineParams$6(params);
697
-
698
- if (startTime) {
699
- url += '#t=' + startTime;
700
- }
701
-
702
- return url;
703
- };
704
-
705
- Vimeo.prototype.createLongUrl = function (vi, params) {
706
- return this.createUrl('https://vimeo.com/', vi, params, 'long');
707
- };
708
-
709
- Vimeo.prototype.createEmbedUrl = function (vi, params) {
710
- return this.createUrl('//player.vimeo.com/video/', vi, params, 'embed');
711
- };
712
-
713
- base.bind(new Vimeo());
714
-
715
- var combineParams$7 = util.combineParams,
716
- getTime$4 = util.getTime;
717
-
718
- function Wistia() {
719
- this.provider = 'wistia';
720
- this.alternatives = [];
721
- this.defaultFormat = 'long';
722
- this.formats = {
723
- "long": this.createLongUrl,
724
- embed: this.createEmbedUrl,
725
- embedjsonp: this.createEmbedJsonpUrl
726
- };
727
- this.mediaTypes = {
728
- VIDEO: 'video',
729
- EMBEDVIDEO: 'embedvideo'
730
- };
731
- }
732
-
733
- Wistia.prototype.parseUrl = function (url) {
734
- var match = url.match(/(?:(?:medias|iframe)\/|wvideo=)([\w-]+)/);
735
- return match ? match[1] : undefined;
736
- };
737
-
738
- Wistia.prototype.parseChannel = function (url) {
739
- var match = url.match(/(?:(?:https?:)?\/\/)?([^.]*)\.wistia\./);
740
- var channel = match ? match[1] : undefined;
741
-
742
- if (channel === 'fast' || channel === 'content') {
743
- return undefined;
744
- }
745
-
746
- return channel;
747
- };
748
-
749
- Wistia.prototype.parseParameters = function (params, result) {
750
- if (params.wtime) {
751
- params.start = getTime$4(params.wtime);
752
- delete params.wtime;
753
- }
754
-
755
- if (params.wvideo === result.id) {
756
- delete params.wvideo;
757
- }
758
-
759
- return params;
760
- };
761
-
762
- Wistia.prototype.parseMediaType = function (result) {
763
- if (result.id && result.channel) {
764
- return this.mediaTypes.VIDEO;
765
- } else if (result.id) {
766
- delete result.channel;
767
- return this.mediaTypes.EMBEDVIDEO;
768
- } else {
769
- return undefined;
770
- }
771
- };
772
-
773
- Wistia.prototype.parse = function (url, params) {
774
- var result = {
775
- id: this.parseUrl(url),
776
- channel: this.parseChannel(url)
777
- };
778
- result.params = this.parseParameters(params, result);
779
- result.mediaType = this.parseMediaType(result);
780
-
781
- if (!result.id) {
782
- return undefined;
783
- }
784
-
785
- return result;
786
- };
787
-
788
- Wistia.prototype.createUrl = function (vi, params, url) {
789
- if (params.start) {
790
- params.wtime = params.start;
791
- delete params.start;
792
- }
793
-
794
- url += combineParams$7(params);
795
- return url;
796
- };
797
-
798
- Wistia.prototype.createLongUrl = function (vi, params) {
799
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
800
- return undefined;
801
- }
802
-
803
- var url = 'https://' + vi.channel + '.wistia.com/medias/' + vi.id;
804
- return this.createUrl(vi, params, url);
805
- };
806
-
807
- Wistia.prototype.createEmbedUrl = function (vi, params) {
808
- if (!vi.id || !(vi.mediaType === this.mediaTypes.VIDEO || vi.mediaType === this.mediaTypes.EMBEDVIDEO)) {
809
- return undefined;
810
- }
811
-
812
- var url = 'https://fast.wistia.com/embed/iframe/' + vi.id;
813
- return this.createUrl(vi, params, url);
814
- };
815
-
816
- Wistia.prototype.createEmbedJsonpUrl = function (vi) {
817
- if (!vi.id || !(vi.mediaType === this.mediaTypes.VIDEO || vi.mediaType === this.mediaTypes.EMBEDVIDEO)) {
818
- return undefined;
819
- }
820
-
821
- return 'https://fast.wistia.com/embed/medias/' + vi.id + '.jsonp';
822
- };
823
-
824
- base.bind(new Wistia());
825
-
826
- var combineParams$8 = util.combineParams;
827
-
828
- function Youku() {
829
- this.provider = 'youku';
830
- this.defaultFormat = 'long';
831
- this.formats = {
832
- embed: this.createEmbedUrl,
833
- "long": this.createLongUrl,
834
- flash: this.createFlashUrl,
835
- "static": this.createStaticUrl
836
- };
837
- this.mediaTypes = {
838
- VIDEO: 'video'
839
- };
840
- }
841
-
842
- Youku.prototype.parseUrl = function (url) {
843
- var match = url.match(/(?:(?:embed|sid)\/|v_show\/id_|VideoIDS=)([a-zA-Z0-9]+)/);
844
- return match ? match[1] : undefined;
845
- };
846
-
847
- Youku.prototype.parseParameters = function (params) {
848
- if (params.VideoIDS) {
849
- delete params.VideoIDS;
850
- }
851
-
852
- return params;
853
- };
854
-
855
- Youku.prototype.parse = function (url, params) {
856
- var _this = this;
857
-
858
- var result = {
859
- mediaType: this.mediaTypes.VIDEO,
860
- id: _this.parseUrl(url),
861
- params: _this.parseParameters(params)
862
- };
863
-
864
- if (!result.id) {
865
- return undefined;
866
- }
867
-
868
- return result;
869
- };
870
-
871
- Youku.prototype.createUrl = function (baseUrl, vi, params) {
872
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
873
- return undefined;
874
- }
875
-
876
- var url = baseUrl + vi.id;
877
- url += combineParams$8(params);
878
- return url;
879
- };
880
-
881
- Youku.prototype.createEmbedUrl = function (vi, params) {
882
- return this.createUrl('http://player.youku.com/embed/', vi, params);
883
- };
884
-
885
- Youku.prototype.createLongUrl = function (vi, params) {
886
- return this.createUrl('http://v.youku.com/v_show/id_', vi, params);
887
- };
888
-
889
- Youku.prototype.createStaticUrl = function (vi, params) {
890
- return this.createUrl('http://static.youku.com/v1.0.0638/v/swf/loader.swf?VideoIDS=', vi, params);
891
- };
892
-
893
- Youku.prototype.createFlashUrl = function (vi, params) {
894
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
895
- return undefined;
896
- }
897
-
898
- var url = 'http://player.youku.com/player.php/sid/' + vi.id + '/v.swf';
899
- url += combineParams$8(params);
900
- return url;
901
- };
902
-
903
- base.bind(new Youku());
904
-
905
- var combineParams$9 = util.combineParams,
906
- getTime$5 = util.getTime;
907
-
908
- function YouTube() {
909
- this.provider = 'youtube';
910
- this.alternatives = ['youtu', 'ytimg'];
911
- this.defaultFormat = 'long';
912
- this.formats = {
913
- "short": this.createShortUrl,
914
- "long": this.createLongUrl,
915
- embed: this.createEmbedUrl,
916
- shortImage: this.createShortImageUrl,
917
- longImage: this.createLongImageUrl
918
- };
919
- this.imageQualities = {
920
- '0': '0',
921
- '1': '1',
922
- '2': '2',
923
- '3': '3',
924
- DEFAULT: 'default',
925
- HQDEFAULT: 'hqdefault',
926
- SDDEFAULT: 'sddefault',
927
- MQDEFAULT: 'mqdefault',
928
- MAXRESDEFAULT: 'maxresdefault'
929
- };
930
- this.defaultImageQuality = this.imageQualities.HQDEFAULT;
931
- this.mediaTypes = {
932
- VIDEO: 'video',
933
- PLAYLIST: 'playlist',
934
- SHARE: 'share',
935
- CHANNEL: 'channel'
936
- };
937
- }
938
-
939
- YouTube.prototype.parseVideoUrl = function (url) {
940
- var match = url.match(/(?:(?:v|vi|be|videos|shorts|embed|live)\/(?!videoseries)|(?:v|ci)=)([\w-]{11})/i);
941
- return match ? match[1] : undefined;
942
- };
943
-
944
- YouTube.prototype.parseChannelUrl = function (url) {
945
- // Match an opaque channel ID
946
- var match = url.match(/\/channel\/([\w-]+)/);
947
-
948
- if (match) {
949
- return {
950
- id: match[1],
951
- mediaType: this.mediaTypes.CHANNEL
952
- };
953
- } // Match a vanity channel name or a user name. User urls are deprecated and
954
- // currently redirect to the channel of that same name.
955
-
956
-
957
- match = url.match(/\/(?:c|user)\/([\w-]+)/);
958
-
959
- if (match) {
960
- return {
961
- name: match[1],
962
- mediaType: this.mediaTypes.CHANNEL
963
- };
964
- }
965
- };
966
-
967
- YouTube.prototype.parseParameters = function (params, result) {
968
- if (params.start || params.t) {
969
- params.start = getTime$5(params.start || params.t);
970
- delete params.t;
971
- }
972
-
973
- if (params.v === result.id) {
974
- delete params.v;
975
- }
976
-
977
- if (params.list === result.id) {
978
- delete params.list;
979
- }
980
-
981
- return params;
982
- };
983
-
984
- YouTube.prototype.parseMediaType = function (result) {
985
- if (result.params.list) {
986
- result.list = result.params.list;
987
- delete result.params.list;
988
- }
989
-
990
- if (result.id && !result.params.ci) {
991
- result.mediaType = this.mediaTypes.VIDEO;
992
- } else if (result.list) {
993
- delete result.id;
994
- result.mediaType = this.mediaTypes.PLAYLIST;
995
- } else if (result.params.ci) {
996
- delete result.params.ci;
997
- result.mediaType = this.mediaTypes.SHARE;
998
- } else {
999
- return undefined;
1000
- }
1001
-
1002
- return result;
1003
- };
1004
-
1005
- YouTube.prototype.parse = function (url, params) {
1006
- var channelResult = this.parseChannelUrl(url);
1007
-
1008
- if (channelResult) {
1009
- return channelResult;
1010
- } else {
1011
- var result = {
1012
- params: params,
1013
- id: this.parseVideoUrl(url)
1014
- };
1015
- result.params = this.parseParameters(params, result);
1016
- result = this.parseMediaType(result);
1017
- return result;
1018
- }
1019
- };
1020
-
1021
- YouTube.prototype.createShortUrl = function (vi, params) {
1022
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1023
- return undefined;
1024
- }
1025
-
1026
- var url = 'https://youtu.be/' + vi.id;
1027
-
1028
- if (params.start) {
1029
- url += '#t=' + params.start;
1030
- }
1031
-
1032
- return url;
1033
- };
1034
-
1035
- YouTube.prototype.createLongUrl = function (vi, params) {
1036
- var url = '';
1037
- var startTime = params.start;
1038
- delete params.start;
1039
-
1040
- if (vi.mediaType === this.mediaTypes.CHANNEL) {
1041
- if (vi.id) {
1042
- url += 'https://www.youtube.com/channel/' + vi.id;
1043
- } else if (vi.name) {
1044
- url += 'https://www.youtube.com/c/' + vi.name;
1045
- } else {
1046
- return undefined;
1047
- }
1048
- } else if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.list) {
1049
- params.feature = 'share';
1050
- url += 'https://www.youtube.com/playlist';
1051
- } else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
1052
- params.v = vi.id;
1053
- url += 'https://www.youtube.com/watch';
1054
- } else if (vi.mediaType === this.mediaTypes.SHARE && vi.id) {
1055
- params.ci = vi.id;
1056
- url += 'https://www.youtube.com/shared';
1057
- } else {
1058
- return undefined;
1059
- }
1060
-
1061
- if (vi.list) {
1062
- params.list = vi.list;
1063
- }
1064
-
1065
- url += combineParams$9(params);
1066
-
1067
- if (vi.mediaType !== this.mediaTypes.PLAYLIST && startTime) {
1068
- url += '#t=' + startTime;
1069
- }
1070
-
1071
- return url;
1072
- };
1073
-
1074
- YouTube.prototype.createEmbedUrl = function (vi, params) {
1075
- var url = 'https://www.youtube.com/embed';
1076
-
1077
- if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.list) {
1078
- params.listType = 'playlist';
1079
- } else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
1080
- url += '/' + vi.id; //loop hack
1081
-
1082
- if (params.loop === '1') {
1083
- params.playlist = vi.id;
1084
- }
1085
- } else {
1086
- return undefined;
1087
- }
1088
-
1089
- if (vi.list) {
1090
- params.list = vi.list;
1091
- }
1092
-
1093
- url += combineParams$9(params);
1094
- return url;
1095
- };
1096
-
1097
- YouTube.prototype.createImageUrl = function (baseUrl, vi, params) {
1098
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1099
- return undefined;
1100
- }
1101
-
1102
- var url = baseUrl + vi.id + '/';
1103
- var quality = params.imageQuality || this.defaultImageQuality;
1104
- return url + quality + '.jpg';
1105
- };
1106
-
1107
- YouTube.prototype.createShortImageUrl = function (vi, params) {
1108
- return this.createImageUrl('https://i.ytimg.com/vi/', vi, params);
1109
- };
1110
-
1111
- YouTube.prototype.createLongImageUrl = function (vi, params) {
1112
- return this.createImageUrl('https://img.youtube.com/vi/', vi, params);
1113
- };
1114
-
1115
- base.bind(new YouTube());
1116
-
1117
- var combineParams$a = util.combineParams,
1118
- getTime$6 = util.getTime;
1119
-
1120
- function SoundCloud() {
1121
- this.provider = 'soundcloud';
1122
- this.defaultFormat = 'long';
1123
- this.formats = {
1124
- "long": this.createLongUrl,
1125
- embed: this.createEmbedUrl
1126
- };
1127
- this.mediaTypes = {
1128
- TRACK: 'track',
1129
- PLAYLIST: 'playlist',
1130
- APITRACK: 'apitrack',
1131
- APIPLAYLIST: 'apiplaylist'
1132
- };
1133
- }
1134
-
1135
- SoundCloud.prototype.parseUrl = function (url, result) {
1136
- var match = url.match(/(?:m\.)?soundcloud\.com\/(?:([\w-]+)\/(sets\/)?)([\w-]+)/i);
1137
-
1138
- if (!match) {
1139
- return result;
1140
- }
1141
-
1142
- result.channel = match[1];
1143
-
1144
- if (match[1] === 'playlists' || match[2]) {
1145
- //playlist
1146
- result.list = match[3];
1147
- } else {
1148
- //track
1149
- result.id = match[3];
1150
- }
1151
-
1152
- return result;
1153
- };
1154
-
1155
- SoundCloud.prototype.parseParameters = function (params) {
1156
- if (params.t) {
1157
- params.start = getTime$6(params.t);
1158
- delete params.t;
1159
- }
1160
-
1161
- return params;
1162
- };
1163
-
1164
- SoundCloud.prototype.parseMediaType = function (result) {
1165
- if (result.id) {
1166
- if (result.channel === 'tracks') {
1167
- delete result.channel;
1168
- delete result.params.url;
1169
- result.mediaType = this.mediaTypes.APITRACK;
1170
- } else {
1171
- result.mediaType = this.mediaTypes.TRACK;
1172
- }
1173
- }
1174
-
1175
- if (result.list) {
1176
- if (result.channel === 'playlists') {
1177
- delete result.channel;
1178
- delete result.params.url;
1179
- result.mediaType = this.mediaTypes.APIPLAYLIST;
1180
- } else {
1181
- result.mediaType = this.mediaTypes.PLAYLIST;
1182
- }
1183
- }
1184
-
1185
- return result;
1186
- };
1187
-
1188
- SoundCloud.prototype.parse = function (url, params) {
1189
- var result = {};
1190
- result = this.parseUrl(url, result);
1191
- result.params = this.parseParameters(params);
1192
- result = this.parseMediaType(result);
1193
-
1194
- if (!result.id && !result.list) {
1195
- return undefined;
1196
- }
1197
-
1198
- return result;
1199
- };
1200
-
1201
- SoundCloud.prototype.createLongUrl = function (vi, params) {
1202
- var url = '';
1203
- var startTime = params.start;
1204
- delete params.start;
1205
-
1206
- if (vi.mediaType === this.mediaTypes.TRACK && vi.id && vi.channel) {
1207
- url = 'https://soundcloud.com/' + vi.channel + '/' + vi.id;
1208
- } else if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.list && vi.channel) {
1209
- url = 'https://soundcloud.com/' + vi.channel + '/sets/' + vi.list;
1210
- } else if (vi.mediaType === this.mediaTypes.APITRACK && vi.id) {
1211
- url = 'https://api.soundcloud.com/tracks/' + vi.id;
1212
- } else if (vi.mediaType === this.mediaTypes.APIPLAYLIST && vi.list) {
1213
- url = 'https://api.soundcloud.com/playlists/' + vi.list;
1214
- } else {
1215
- return undefined;
1216
- }
1217
-
1218
- url += combineParams$a(params);
1219
-
1220
- if (startTime) {
1221
- url += '#t=' + startTime;
1222
- }
1223
-
1224
- return url;
1225
- };
1226
-
1227
- SoundCloud.prototype.createEmbedUrl = function (vi, params) {
1228
- var url = 'https://w.soundcloud.com/player/';
1229
- delete params.start;
1230
-
1231
- if (vi.mediaType === this.mediaTypes.APITRACK && vi.id) {
1232
- params.url = 'https%3A//api.soundcloud.com/tracks/' + vi.id;
1233
- } else if (vi.mediaType === this.mediaTypes.APIPLAYLIST && vi.list) {
1234
- params.url = 'https%3A//api.soundcloud.com/playlists/' + vi.list;
1235
- } else {
1236
- return undefined;
1237
- }
1238
-
1239
- url += combineParams$a(params);
1240
- return url;
1241
- };
1242
-
1243
- base.bind(new SoundCloud());
1244
-
1245
- var combineParams$b = util.combineParams;
1246
-
1247
- function TeacherTube() {
1248
- this.provider = 'teachertube';
1249
- this.alternatives = [];
1250
- this.defaultFormat = 'long';
1251
- this.formats = {
1252
- "long": this.createLongUrl,
1253
- embed: this.createEmbedUrl
1254
- };
1255
- this.mediaTypes = {
1256
- VIDEO: 'video',
1257
- AUDIO: 'audio',
1258
- DOCUMENT: 'document',
1259
- CHANNEL: 'channel',
1260
- COLLECTION: 'collection',
1261
- GROUP: 'group'
1262
- };
1263
- }
1264
-
1265
- TeacherTube.prototype.parse = function (url, params) {
1266
- var result = {};
1267
- result.list = this.parsePlaylist(params);
1268
- result.params = params;
1269
- var match = url.match(/\/(audio|video|document|user\/channel|collection|group)\/(?:[\w-]+-)?(\w+)/);
1270
-
1271
- if (!match) {
1272
- return undefined;
1273
- }
1274
-
1275
- result.mediaType = this.parseMediaType(match[1]);
1276
- result.id = match[2];
1277
- return result;
1278
- };
1279
-
1280
- TeacherTube.prototype.parsePlaylist = function (params) {
1281
- if (params['playlist-id']) {
1282
- var list = params['playlist-id'];
1283
- delete params['playlist-id'];
1284
- return list;
1285
- }
1286
-
1287
- return undefined;
1288
- };
1289
-
1290
- TeacherTube.prototype.parseMediaType = function (mediaTypeMatch) {
1291
- switch (mediaTypeMatch) {
1292
- case 'audio':
1293
- return this.mediaTypes.AUDIO;
1294
-
1295
- case 'video':
1296
- return this.mediaTypes.VIDEO;
1297
-
1298
- case 'document':
1299
- return this.mediaTypes.DOCUMENT;
1300
-
1301
- case 'user/channel':
1302
- return this.mediaTypes.CHANNEL;
1303
-
1304
- case 'collection':
1305
- return this.mediaTypes.COLLECTION;
1306
-
1307
- case 'group':
1308
- return this.mediaTypes.GROUP;
1309
- }
1310
- };
1311
-
1312
- TeacherTube.prototype.createLongUrl = function (vi, params) {
1313
- if (!vi.id) {
1314
- return undefined;
1315
- }
1316
-
1317
- var url = 'https://www.teachertube.com/';
1318
-
1319
- if (vi.list) {
1320
- params['playlist-id'] = vi.list;
1321
- }
1322
-
1323
- if (vi.mediaType === this.mediaTypes.CHANNEL) {
1324
- url += 'user/channel/';
1325
- } else {
1326
- url += vi.mediaType + '/';
1327
- }
1328
-
1329
- url += vi.id;
1330
- url += combineParams$b(params);
1331
- return url;
1332
- };
1333
-
1334
- TeacherTube.prototype.createEmbedUrl = function (vi, params) {
1335
- if (!vi.id) {
1336
- return undefined;
1337
- }
1338
-
1339
- var url = 'https://www.teachertube.com/embed/';
1340
-
1341
- if (vi.mediaType === this.mediaTypes.VIDEO || vi.mediaType === this.mediaTypes.AUDIO) {
1342
- url += vi.mediaType + '/' + vi.id;
1343
- } else {
1344
- return undefined;
1345
- }
1346
-
1347
- url += combineParams$b(params);
1348
- return url;
1349
- };
1350
-
1351
- base.bind(new TeacherTube());
1352
-
1353
- var combineParams$c = util.combineParams;
1354
-
1355
- function TikTok() {
1356
- this.provider = 'tiktok';
1357
- this.defaultFormat = 'long';
1358
- this.formats = {
1359
- "long": this.createLongUrl
1360
- };
1361
- this.mediaTypes = {
1362
- VIDEO: 'video'
1363
- };
1364
- }
1365
-
1366
- TikTok.prototype.parse = function (url, params) {
1367
- var result = {
1368
- params: params,
1369
- mediaType: this.mediaTypes.VIDEO
1370
- };
1371
- var match = url.match(/@([^/]+)\/video\/(\d{19})/);
1372
-
1373
- if (!match) {
1374
- return;
1375
- }
1376
-
1377
- result.channel = match[1];
1378
- result.id = match[2];
1379
- return result;
1380
- };
1381
-
1382
- TikTok.prototype.createLongUrl = function (vi, params) {
1383
- var url = '';
1384
-
1385
- if (vi.mediaType === this.mediaTypes.VIDEO && vi.id && vi.channel) {
1386
- url += "https://www.tiktok.com/@".concat(vi.channel, "/video/").concat(vi.id);
1387
- } else {
1388
- return undefined;
1389
- }
1390
-
1391
- url += combineParams$c(params);
1392
- return url;
1393
- };
1394
-
1395
- base.bind(new TikTok());
1396
-
1397
- var combineParams$d = util.combineParams;
1398
-
1399
- function Ted() {
1400
- this.provider = 'ted';
1401
- this.formats = {
1402
- "long": this.createLongUrl,
1403
- embed: this.createEmbedUrl
1404
- };
1405
- this.mediaTypes = {
1406
- VIDEO: 'video',
1407
- PLAYLIST: 'playlist'
1408
- };
1409
- }
1410
-
1411
- Ted.prototype.parseUrl = function (url, result) {
1412
- var match = url.match(/\/(talks|playlists\/(\d+))\/([\w-]+)/i);
1413
- var channel = match ? match[1] : undefined;
1414
-
1415
- if (!channel) {
1416
- return result;
1417
- }
1418
-
1419
- result.channel = channel.split('/')[0];
1420
- result.id = match[3];
1421
-
1422
- if (result.channel === 'playlists') {
1423
- result.list = match[2];
1424
- }
1425
-
1426
- return result;
1427
- };
1428
-
1429
- Ted.prototype.parseMediaType = function (result) {
1430
- if (result.id && result.channel === 'playlists') {
1431
- delete result.channel;
1432
- result.mediaType = this.mediaTypes.PLAYLIST;
1433
- }
1434
-
1435
- if (result.id && result.channel === 'talks') {
1436
- delete result.channel;
1437
- result.mediaType = this.mediaTypes.VIDEO;
1438
- }
1439
-
1440
- return result;
1441
- };
1442
-
1443
- Ted.prototype.parse = function (url, params) {
1444
- var result = {
1445
- params: params
1446
- };
1447
- result = this.parseUrl(url, result);
1448
- result = this.parseMediaType(result);
1449
-
1450
- if (!result.id) {
1451
- return undefined;
1452
- }
1453
-
1454
- return result;
1455
- };
1456
-
1457
- Ted.prototype.createLongUrl = function (vi, params) {
1458
- var url = '';
1459
-
1460
- if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
1461
- url += 'https://ted.com/talks/' + vi.id;
1462
- } else if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.id) {
1463
- url += 'https://ted.com/playlists/' + vi.list + '/' + vi.id;
1464
- } else {
1465
- return undefined;
1466
- }
1467
-
1468
- url += combineParams$d(params);
1469
- return url;
1470
- };
1471
-
1472
- Ted.prototype.createEmbedUrl = function (vi, params) {
1473
- var url = 'https://embed.ted.com/';
1474
-
1475
- if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.id) {
1476
- url += 'playlists/' + vi.list + '/' + vi.id;
1477
- } else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
1478
- url += 'talks/' + vi.id;
1479
- } else {
1480
- return undefined;
1481
- }
1482
-
1483
- url += combineParams$d(params);
1484
- return url;
1485
- };
1486
-
1487
- base.bind(new Ted());
1488
-
1489
- var combineParams$e = util.combineParams;
1490
-
1491
- function Facebook() {
1492
- this.provider = 'facebook';
1493
- this.alternatives = [];
1494
- this.defaultFormat = 'long';
1495
- this.formats = {
1496
- "long": this.createLongUrl,
1497
- watch: this.createWatchUrl
1498
- };
1499
- this.mediaTypes = {
1500
- VIDEO: 'video'
1501
- };
1502
- }
1503
-
1504
- Facebook.prototype.parse = function (url, params) {
1505
- var result = {
1506
- params: params,
1507
- mediaType: this.mediaTypes.VIDEO
1508
- };
1509
- var match = url.match(/(?:\/(\d+))?\/videos(?:\/.*?)?\/(\d+)/i);
1510
-
1511
- if (match) {
1512
- if (match[1]) {
1513
- result.pageId = match[1];
1514
- }
1515
-
1516
- result.id = match[2];
1517
- }
1518
-
1519
- if (params.v && !result.id) {
1520
- result.id = params.v;
1521
- delete params.v;
1522
- result.params = params;
1523
- }
1524
-
1525
- if (!result.id) {
1526
- return undefined;
1527
- }
1528
-
1529
- return result;
1530
- };
1531
-
1532
- Facebook.prototype.createWatchUrl = function (vi, params) {
1533
- var url = 'https://facebook.com/watch/';
1534
-
1535
- if (vi.mediaType !== this.mediaTypes.VIDEO || !vi.id) {
1536
- return undefined;
1537
- }
1538
-
1539
- params = {
1540
- v: vi.id
1541
- };
1542
- url += combineParams$e(params);
1543
- return url;
1544
- };
1545
-
1546
- Facebook.prototype.createLongUrl = function (vi, params) {
1547
- var url = 'https://facebook.com/';
1548
-
1549
- if (vi.pageId) {
1550
- url += vi.pageId;
1551
- } else {
1552
- return undefined;
1553
- }
1554
-
1555
- if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
1556
- url += '/videos/' + vi.id;
1557
- } else {
1558
- return undefined;
1559
- }
1560
-
1561
- url += combineParams$e(params);
1562
- return url;
1563
- };
1564
-
1565
- base.bind(new Facebook());
1566
-
1567
- var combineParams$f = util.combineParams;
1568
-
1569
- function Voomly() {
1570
- this.provider = 'voomly';
1571
- this.defaultFormat = 'long';
1572
- this.formats = {
1573
- long: this.createLongUrl,
1574
- };
1575
- this.mediaTypes = {
1576
- VIDEO: 'video',
1577
- };
1578
- }
1579
-
1580
- Voomly.prototype.parseUrl = function(url) {
1581
- var match = url.match(
1582
- /(?:v|embed)\/([\w-]+)/i
1583
- );
1584
- return match ? match[1] : undefined;
1585
- };
1586
-
1587
- Voomly.prototype.parse = function(url, params) {
1588
- var result = {
1589
- mediaType: this.mediaTypes.VIDEO,
1590
- params: params,
1591
- id: this.parseUrl(url)
1592
- };
1593
- return result.id ? result : undefined;
1594
- };
1595
-
1596
- Voomly.prototype.createUrl = function(baseUrl, vi, params) {
1597
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1598
- return undefined;
1599
- }
1600
-
1601
- var url = baseUrl + vi.id;
1602
- url += combineParams$f(params);
1603
- return url;
1604
- };
1605
-
1606
- Voomly.prototype.createLongUrl = function(vi, params) {
1607
- return this.createUrl('https://share.voomly.com/v/', vi, params);
1608
- };
1609
-
1610
- base.bind(new Voomly());
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
- //var match = url.match(/(?:\/(\d+))?\/watch(?:\/.*?)?\/(\d+)/i);
1630
- return match ? match[1] : undefined;
1631
- };
1632
-
1633
- Spotlightr.prototype.parse = function(url, params) {
1634
- var result = {
1635
- mediaType: this.mediaTypes.VIDEO,
1636
- params: params,
1637
- id: this.parseUrl(url)
1638
- };
1639
- return result.id ? result : undefined;
1640
- };
1641
-
1642
- Spotlightr.prototype.createUrl = function(baseUrl, vi, params) {
1643
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1644
- return undefined;
1645
- }
1646
-
1647
- var url = baseUrl + vi.id;
1648
- url += combineParams$g(params);
1649
- return url;
1650
- };
1651
-
1652
- Spotlightr.prototype.createLongUrl = function(vi, params) {
1653
- return this.createUrl('https://videos.cdn.spotlightr.com/watch/', vi, params);
1654
- };
1655
-
1656
- base.bind(new Spotlightr());
1657
-
1658
- var combineParams$h = util.combineParams;
1659
-
1660
- function Bunny() {
1661
- this.provider = 'bunnycdn';
1662
- this.alternatives = ['mediadelivery'];
1663
- this.defaultFormat = 'long';
1664
- this.formats = {
1665
- long: this.createLongUrl,
1666
- };
1667
- this.mediaTypes = {
1668
- VIDEO: 'video',
1669
- };
1670
- }
1671
-
1672
- Bunny.prototype.parse = function(url, params) {
1673
- var match = url.match(
1674
- /(?:play|embed)\/([a-zA-Z\d]+)\/([\w-]+)/i
1675
- );
1676
- var result = {
1677
- mediaType: this.mediaTypes.VIDEO,
1678
- params: params,
1679
- library: match[1],
1680
- id: match[2]
1681
- };
1682
- return result.id ? result : undefined;
1683
- };
1684
-
1685
- Bunny.prototype.createUrl = function(baseUrl, vi, params) {
1686
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1687
- return undefined;
1688
- }
1689
-
1690
- var url = baseUrl + vi.library + '/' + vi.id;
1691
- url += combineParams$h(params);
1692
- return url;
1693
- };
1694
-
1695
- Bunny.prototype.createLongUrl = function(vi, params) {
1696
- return this.createUrl('https://video.bunnycdn.com/play/', vi, params);
1697
- };
1698
-
1699
- base.bind(new Bunny());
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(/\/design\/(.+)\/watch/);
1716
- var result = {
1717
- mediaType: this.mediaTypes.VIDEO,
1718
- params: params,
1719
- id: match[1]
1720
- };
1721
- return result.id ? result : undefined;
1722
- };
1723
-
1724
- Canva.prototype.createUrl = function(baseUrl, vi, params) {
1725
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1726
- return undefined;
1727
- }
1728
-
1729
- var url = baseUrl + vi.id + '/watch?embed';
1730
- url += combineParams$i(params);
1731
- return url;
1732
- };
1733
-
1734
- Canva.prototype.createLongUrl = function(vi, params) {
1735
- return this.createUrl('https://www.canva.com/design/', vi, params);
1736
- };
1737
-
1738
- base.bind(new Canva());
1739
-
1740
- var combineParams$j = util.combineParams;
1741
-
1742
- function Google() {
1743
- this.provider = 'google';
1744
- this.defaultFormat = 'long';
1745
- this.formats = {
1746
- long: this.createLongUrl,
1747
- };
1748
- this.mediaTypes = {
1749
- VIDEO: 'video',
1750
- };
1751
- }
1752
-
1753
- Google.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
- Google.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
- Google.prototype.createLongUrl = function(vi, params) {
1774
- return this.createUrl('https://drive.google.com/file/d/', vi, params);
1775
- };
1776
-
1777
- base.bind(new Google());
1778
-
1779
- var combineParams$k = util.combineParams;
1780
-
1781
- function Groove() {
1782
- this.provider = 'groove';
1783
- this.defaultFormat = 'long';
1784
- this.formats = {
1785
- long: this.createLongUrl,
1786
- };
1787
- this.mediaTypes = {
1788
- VIDEO: 'video',
1789
- };
1790
- }
1791
-
1792
- Groove.prototype.parse = function(url, params) {
1793
- var match = url.match(
1794
- /(?:videopage)\/([\w-]+)\/([\w-]+)/i
1795
- );
1796
- var result = {
1797
- mediaType: this.mediaTypes.VIDEO,
1798
- params: params,
1799
- library: match[1],
1800
- id: match[2]
1801
- };
1802
- return result.id ? result : undefined;
1803
- };
1804
-
1805
- Groove.prototype.createUrl = function(baseUrl, vi, params) {
1806
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1807
- return undefined;
1808
- }
1809
-
1810
- var url = baseUrl + vi.library + '/' + vi.id;
1811
- url += combineParams$k(params);
1812
- return url;
1813
- };
1814
-
1815
- Groove.prototype.createLongUrl = function(vi, params) {
1816
- return this.createUrl('https://app.groove.cm/groovevideo/videopage/', vi, params);
1817
- };
1818
-
1819
- base.bind(new Groove());
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 Streamable());
1861
-
1862
- var combineParams$m = util.combineParams;
1863
-
1864
- function Bigcommand() {
1865
- this.provider = 'bigcommand';
1866
- this.defaultFormat = 'long';
1867
- this.formats = {
1868
- long: this.createLongUrl,
1869
- };
1870
- this.mediaTypes = {
1871
- VIDEO: 'video',
1872
- };
1873
- }
1874
-
1875
- Bigcommand.prototype.parse = function(url, params) {
1876
- var match = url.match(
1877
- /(?:watch)\/([\w-]+)/i
1878
- );
1879
- var result = {
1880
- mediaType: this.mediaTypes.VIDEO,
1881
- params: params,
1882
- id: match[1]
1883
- };
1884
- return result.id ? result : undefined;
1885
- };
1886
-
1887
- Bigcommand.prototype.createUrl = function(baseUrl, vi, params) {
1888
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1889
- return undefined;
1890
- }
1891
-
1892
- var url = baseUrl + vi.library + '/' + vi.id;
1893
- url += combineParams$m(params);
1894
- return url;
1895
- };
1896
-
1897
- Bigcommand.prototype.createLongUrl = function(vi, params) {
1898
- return this.createUrl('https://adilo.bigcommand.com/watch/', vi, params);
1899
- };
1900
-
1901
- base.bind(new Bigcommand());
1902
-
1903
- var combineParams$n = util.combineParams;
1904
-
1905
- function Searchie() {
1906
- this.provider = 'searchie';
1907
- this.defaultFormat = 'long';
1908
- this.formats = {
1909
- long: this.createLongUrl,
1910
- };
1911
- this.mediaTypes = {
1912
- VIDEO: 'video',
1913
- };
1914
- }
1915
-
1916
- Searchie.prototype.parse = function(url, params) {
1917
- var match = url.match(
1918
- /(?:watch)\/([\w-]+)/i
1919
- );
1920
- var result = {
1921
- mediaType: this.mediaTypes.VIDEO,
1922
- params: params,
1923
- id: match[1]
1924
- };
1925
- return result.id ? result : undefined;
1926
- };
1927
-
1928
- Searchie.prototype.createUrl = function(baseUrl, vi, params) {
1929
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1930
- return undefined;
1931
- }
1932
-
1933
- var url = baseUrl + vi.library + '/' + vi.id;
1934
- url += combineParams$n(params);
1935
- return url;
1936
- };
1937
-
1938
- Searchie.prototype.createLongUrl = function(vi, params) {
1939
- return this.createUrl('https://app.searchie.io/watch/', vi, params);
1940
- };
1941
-
1942
- base.bind(new Searchie());
1943
-
1944
- var combineParams$o = util.combineParams;
1945
-
1946
- function Tevello() {
1947
- this.provider = 'tevello';
1948
- this.defaultFormat = 'long';
1949
- this.formats = {
1950
- long: this.createLongUrl,
1951
- };
1952
- this.mediaTypes = {
1953
- VIDEO: 'video',
1954
- };
1955
- }
1956
-
1957
- Tevello.prototype.parse = function(url, params) {
1958
- var match = url.match(
1959
- /(?:play|embed)\/([a-zA-Z\d]+)\/([\w-]+)/i
1960
- );
1961
- var result = {
1962
- mediaType: this.mediaTypes.VIDEO,
1963
- params: params,
1964
- library: match[1],
1965
- id: match[2]
1966
- };
1967
- return result.id ? result : undefined;
1968
- };
1969
-
1970
- Tevello.prototype.createUrl = function(baseUrl, vi, params) {
1971
- if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1972
- return undefined;
1973
- }
1974
-
1975
- var url = baseUrl + vi.library + '/' + vi.id;
1976
- url += combineParams$o(params);
1977
- return url;
1978
- };
1979
-
1980
- Tevello.prototype.createLongUrl = function(vi, params) {
1981
- return this.createUrl('https://video.tevello.com/play/', vi, params);
1982
- };
1983
-
1984
- base.bind(new Tevello());
1985
-
1986
- var lib = base;
1987
-
1988
- return lib;
1989
-
1990
- })));
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.urlParser = factory());
5
+ })(this, (function () { 'use strict';
6
+
7
+ function getDefaultExportFromCjs (x) {
8
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
9
+ }
10
+
11
+ function _typeof(o) {
12
+ "@babel/helpers - typeof";
13
+
14
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
15
+ return typeof o;
16
+ } : function (o) {
17
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
18
+ }, _typeof(o);
19
+ }
20
+
21
+ var util = {};
22
+
23
+ util.getQueryParams = function getQueryParams(qs) {
24
+ if (typeof qs !== 'string') {
25
+ return {};
26
+ }
27
+ qs = qs.split('+').join(' ');
28
+ var params = {};
29
+ var match = qs.match(/(?:[?](?:[^=]+)=(?:[^&#]*)(?:[&](?:[^=]+)=(?:[^&#]*))*(?:[#].*)?)|(?:[#].*)/);
30
+ var split;
31
+ if (match === null) {
32
+ return {};
33
+ }
34
+ split = match[0].substr(1).split(/[&#=]/);
35
+ for (var i = 0; i < split.length; i += 2) {
36
+ params[decodeURIComponent(split[i])] = decodeURIComponent(split[i + 1] || '');
37
+ }
38
+ return params;
39
+ };
40
+ util.combineParams = function combineParams(params, hasParams) {
41
+ if (_typeof(params) !== 'object') {
42
+ return '';
43
+ }
44
+ var combined = '';
45
+ var i = 0;
46
+ var keys = Object.keys(params);
47
+ if (keys.length === 0) {
48
+ return '';
49
+ }
50
+
51
+ //always have parameters in the same order
52
+ keys.sort();
53
+ if (!hasParams) {
54
+ combined += '?' + keys[0] + '=' + params[keys[0]];
55
+ i += 1;
56
+ }
57
+ for (; i < keys.length; i += 1) {
58
+ combined += '&' + keys[i] + '=' + params[keys[i]];
59
+ }
60
+ return combined;
61
+ };
62
+
63
+ //parses strings like 1h30m20s to seconds
64
+ function getLetterTime(timeString) {
65
+ var totalSeconds = 0;
66
+ var timeValues = {
67
+ 's': 1,
68
+ 'm': 1 * 60,
69
+ 'h': 1 * 60 * 60,
70
+ 'd': 1 * 60 * 60 * 24,
71
+ 'w': 1 * 60 * 60 * 24 * 7
72
+ };
73
+ var timePairs;
74
+
75
+ //expand to "1 h 30 m 20 s" and split
76
+ timeString = timeString.replace(/([smhdw])/g, ' $1 ').trim();
77
+ timePairs = timeString.split(' ');
78
+ for (var i = 0; i < timePairs.length; i += 2) {
79
+ totalSeconds += parseInt(timePairs[i], 10) * timeValues[timePairs[i + 1] || 's'];
80
+ }
81
+ return totalSeconds;
82
+ }
83
+
84
+ //parses strings like 1:30:20 to seconds
85
+ function getColonTime(timeString) {
86
+ var totalSeconds = 0;
87
+ var timeValues = [1, 1 * 60, 1 * 60 * 60, 1 * 60 * 60 * 24, 1 * 60 * 60 * 24 * 7];
88
+ var timePairs = timeString.split(':');
89
+ for (var i = 0; i < timePairs.length; i++) {
90
+ totalSeconds += parseInt(timePairs[i], 10) * timeValues[timePairs.length - i - 1];
91
+ }
92
+ return totalSeconds;
93
+ }
94
+ util.getTime = function getTime(timeString) {
95
+ if (typeof timeString === 'undefined') {
96
+ return 0;
97
+ }
98
+ if (timeString.match(/^(\d+[smhdw]?)+$/)) {
99
+ return getLetterTime(timeString);
100
+ }
101
+ if (timeString.match(/^(\d+:?)+$/)) {
102
+ return getColonTime(timeString);
103
+ }
104
+ return 0;
105
+ };
106
+
107
+ var getQueryParams = util.getQueryParams;
108
+ function UrlParser$1() {
109
+ for (var _i = 0, _arr = ['parseProvider', 'parse', 'bind', 'create']; _i < _arr.length; _i++) {
110
+ var key = _arr[_i];
111
+ this[key] = this[key].bind(this);
112
+ }
113
+ this.plugins = {};
114
+ }
115
+ var urlParser = UrlParser$1;
116
+ UrlParser$1.prototype.parseProvider = function (url) {
117
+ var match = url.match(/(?:(?:https?:)?\/\/)?(?:[^.]+\.)?(\w+)\./i);
118
+ return match ? match[1] : undefined;
119
+ };
120
+ UrlParser$1.prototype.parse = function (url) {
121
+ if (typeof url === 'undefined') {
122
+ return undefined;
123
+ }
124
+ var provider = this.parseProvider(url);
125
+ var result;
126
+ var plugin = this.plugins[provider];
127
+ if (!provider || !plugin || !plugin.parse) {
128
+ return undefined;
129
+ }
130
+ result = plugin.parse.call(plugin, url, getQueryParams(url));
131
+ if (result) {
132
+ result = removeEmptyParameters(result);
133
+ result.provider = plugin.provider;
134
+ }
135
+ return result;
136
+ };
137
+ UrlParser$1.prototype.bind = function (plugin) {
138
+ this.plugins[plugin.provider] = plugin;
139
+ if (plugin.alternatives) {
140
+ for (var i = 0; i < plugin.alternatives.length; i += 1) {
141
+ this.plugins[plugin.alternatives[i]] = plugin;
142
+ }
143
+ }
144
+ };
145
+ UrlParser$1.prototype.create = function (op) {
146
+ if (_typeof(op) !== 'object' || _typeof(op.videoInfo) !== 'object') {
147
+ return undefined;
148
+ }
149
+ var vi = op.videoInfo;
150
+ var params = op.params;
151
+ var plugin = this.plugins[vi.provider];
152
+ params = params === 'internal' ? vi.params : params || {};
153
+ if (plugin) {
154
+ op.format = op.format || plugin.defaultFormat;
155
+ // eslint-disable-next-line no-prototype-builtins
156
+ if (plugin.formats.hasOwnProperty(op.format)) {
157
+ return plugin.formats[op.format].apply(plugin, [vi, Object.assign({}, params)]);
158
+ }
159
+ }
160
+ return undefined;
161
+ };
162
+ function removeEmptyParameters(result) {
163
+ if (result.params && Object.keys(result.params).length === 0) {
164
+ delete result.params;
165
+ }
166
+ return result;
167
+ }
168
+
169
+ var UrlParser = urlParser;
170
+ var parser$1 = new UrlParser();
171
+ var base = parser$1;
172
+
173
+ function Allocine() {
174
+ this.provider = 'allocine';
175
+ this.alternatives = [];
176
+ this.defaultFormat = 'embed';
177
+ this.formats = {
178
+ embed: this.createEmbedUrl
179
+ };
180
+ this.mediaTypes = {
181
+ VIDEO: 'video'
182
+ };
183
+ }
184
+ Allocine.prototype.parseUrl = function (url) {
185
+ var match = url.match(/(?:\/video\/player_gen_cmedia=)([A-Za-z0-9]+)/i);
186
+ return match ? match[1] : undefined;
187
+ };
188
+ Allocine.prototype.parse = function (url) {
189
+ var result = {
190
+ mediaType: this.mediaTypes.VIDEO,
191
+ id: this.parseUrl(url)
192
+ };
193
+ return result.id ? result : undefined;
194
+ };
195
+ Allocine.prototype.createEmbedUrl = function (vi) {
196
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
197
+ return undefined;
198
+ }
199
+ return 'https://player.allocine.fr/' + vi.id + '.html';
200
+ };
201
+ base.bind(new Allocine());
202
+
203
+ var combineParams$n = util.combineParams;
204
+ function CanalPlus() {
205
+ this.provider = 'canalplus';
206
+ this.defaultFormat = 'embed';
207
+ this.formats = {
208
+ embed: this.createEmbedUrl
209
+ };
210
+ this.mediaTypes = {
211
+ VIDEO: 'video'
212
+ };
213
+ }
214
+ CanalPlus.prototype.parseParameters = function (params) {
215
+ delete params.vid;
216
+ return params;
217
+ };
218
+ CanalPlus.prototype.parse = function (url, params) {
219
+ var _this = this;
220
+ var result = {
221
+ mediaType: this.mediaTypes.VIDEO,
222
+ id: params.vid
223
+ };
224
+ result.params = _this.parseParameters(params);
225
+ if (!result.id) {
226
+ return undefined;
227
+ }
228
+ return result;
229
+ };
230
+ CanalPlus.prototype.createEmbedUrl = function (vi, params) {
231
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
232
+ return undefined;
233
+ }
234
+ var url = 'http://player.canalplus.fr/embed/';
235
+ params.vid = vi.id;
236
+ url += combineParams$n(params);
237
+ return url;
238
+ };
239
+ base.bind(new CanalPlus());
240
+
241
+ var combineParams$m = util.combineParams;
242
+ function Coub() {
243
+ this.provider = 'coub';
244
+ this.defaultFormat = 'long';
245
+ this.formats = {
246
+ "long": this.createLongUrl,
247
+ embed: this.createEmbedUrl
248
+ };
249
+ this.mediaTypes = {
250
+ VIDEO: 'video'
251
+ };
252
+ }
253
+ Coub.prototype.parseUrl = function (url) {
254
+ var match = url.match(/(?:embed|view)\/([a-zA-Z\d]+)/i);
255
+ return match ? match[1] : undefined;
256
+ };
257
+ Coub.prototype.parse = function (url, params) {
258
+ var result = {
259
+ mediaType: this.mediaTypes.VIDEO,
260
+ params: params,
261
+ id: this.parseUrl(url)
262
+ };
263
+ if (!result.id) {
264
+ return undefined;
265
+ }
266
+ return result;
267
+ };
268
+ Coub.prototype.createUrl = function (baseUrl, vi, params) {
269
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
270
+ return undefined;
271
+ }
272
+ var url = baseUrl + vi.id;
273
+ url += combineParams$m(params);
274
+ return url;
275
+ };
276
+ Coub.prototype.createLongUrl = function (vi, params) {
277
+ return this.createUrl('https://coub.com/view/', vi, params);
278
+ };
279
+ Coub.prototype.createEmbedUrl = function (vi, params) {
280
+ return this.createUrl('//coub.com/embed/', vi, params);
281
+ };
282
+ base.bind(new Coub());
283
+
284
+ var combineParams$l = util.combineParams,
285
+ getTime$5 = util.getTime;
286
+ function Dailymotion() {
287
+ this.provider = 'dailymotion';
288
+ this.alternatives = ['dai'];
289
+ this.defaultFormat = 'long';
290
+ this.formats = {
291
+ "short": this.createShortUrl,
292
+ "long": this.createLongUrl,
293
+ embed: this.createEmbedUrl,
294
+ image: this.createImageUrl
295
+ };
296
+ this.mediaTypes = {
297
+ VIDEO: 'video'
298
+ };
299
+ }
300
+ Dailymotion.prototype.parseParameters = function (params) {
301
+ return this.parseTime(params);
302
+ };
303
+ Dailymotion.prototype.parseTime = function (params) {
304
+ if (params.start) {
305
+ params.start = getTime$5(params.start);
306
+ }
307
+ return params;
308
+ };
309
+ Dailymotion.prototype.parseUrl = function (url) {
310
+ var match = url.match(/(?:\/video|ly)\/([A-Za-z0-9]+)/i);
311
+ return match ? match[1] : undefined;
312
+ };
313
+ Dailymotion.prototype.parse = function (url, params) {
314
+ var _this = this;
315
+ var result = {
316
+ mediaType: this.mediaTypes.VIDEO,
317
+ params: _this.parseParameters(params),
318
+ id: _this.parseUrl(url)
319
+ };
320
+ return result.id ? result : undefined;
321
+ };
322
+ Dailymotion.prototype.createUrl = function (base, vi, params) {
323
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
324
+ return undefined;
325
+ }
326
+ return base + vi.id + combineParams$l(params);
327
+ };
328
+ Dailymotion.prototype.createShortUrl = function (vi, params) {
329
+ return this.createUrl('https://dai.ly/', vi, params);
330
+ };
331
+ Dailymotion.prototype.createLongUrl = function (vi, params) {
332
+ return this.createUrl('https://dailymotion.com/video/', vi, params);
333
+ };
334
+ Dailymotion.prototype.createEmbedUrl = function (vi, params) {
335
+ return this.createUrl('https://www.dailymotion.com/embed/video/', vi, params);
336
+ };
337
+ Dailymotion.prototype.createImageUrl = function (vi, params) {
338
+ delete params.start;
339
+ return this.createUrl('https://www.dailymotion.com/thumbnail/video/', vi, params);
340
+ };
341
+ base.bind(new Dailymotion());
342
+
343
+ var combineParams$k = util.combineParams;
344
+ function Loom() {
345
+ this.provider = 'loom';
346
+ this.defaultFormat = 'long';
347
+ this.formats = {
348
+ "long": this.createLongUrl,
349
+ embed: this.createEmbedUrl
350
+ };
351
+ this.mediaTypes = {
352
+ VIDEO: 'video'
353
+ };
354
+ }
355
+ Loom.prototype.parseUrl = function (url) {
356
+ var match = url.match(/(?:share|embed)\/([a-zA-Z\d]+)/i);
357
+ return match ? match[1] : undefined;
358
+ };
359
+ Loom.prototype.parse = function (url, params) {
360
+ var result = {
361
+ mediaType: this.mediaTypes.VIDEO,
362
+ params: params,
363
+ id: this.parseUrl(url)
364
+ };
365
+ return result.id ? result : undefined;
366
+ };
367
+ Loom.prototype.createUrl = function (baseUrl, vi, params) {
368
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
369
+ return undefined;
370
+ }
371
+ var url = baseUrl + vi.id;
372
+ url += combineParams$k(params);
373
+ return url;
374
+ };
375
+ Loom.prototype.createLongUrl = function (vi, params) {
376
+ return this.createUrl('https://loom.com/share/', vi, params);
377
+ };
378
+ Loom.prototype.createEmbedUrl = function (vi, params) {
379
+ return this.createUrl('//loom.com/embed/', vi, params);
380
+ };
381
+ base.bind(new Loom());
382
+
383
+ var combineParams$j = util.combineParams,
384
+ getTime$4 = util.getTime;
385
+ function Twitch() {
386
+ this.provider = 'twitch';
387
+ this.defaultFormat = 'long';
388
+ this.formats = {
389
+ "long": this.createLongUrl,
390
+ embed: this.createEmbedUrl
391
+ };
392
+ this.mediaTypes = {
393
+ VIDEO: 'video',
394
+ STREAM: 'stream',
395
+ CLIP: 'clip'
396
+ };
397
+ }
398
+ Twitch.prototype.seperateId = function (id) {
399
+ return {
400
+ pre: id[0],
401
+ id: id.substr(1)
402
+ };
403
+ };
404
+ Twitch.prototype.parseChannel = function (result, params) {
405
+ var channel = params.channel || params.utm_content || result.channel;
406
+ delete params.utm_content;
407
+ delete params.channel;
408
+ return channel;
409
+ };
410
+ Twitch.prototype.parseUrl = function (url, result, params) {
411
+ var match;
412
+ match = url.match(/(clips\.)?twitch\.tv\/(?:(?:videos\/(\d+))|(\w+(?:-[\w\d-]+)?)(?:\/clip\/(\w+))?)/i);
413
+ if (match && match[2]) {
414
+ //video
415
+ result.id = 'v' + match[2];
416
+ } else if (params.video) {
417
+ //video embed
418
+ result.id = params.video;
419
+ delete params.video;
420
+ } else if (params.clip) {
421
+ //clips embed
422
+ result.id = params.clip;
423
+ result.isClip = true;
424
+ delete params.clip;
425
+ } else if (match && match[1] && match[3]) {
426
+ //clips.twitch.tv/id
427
+ result.id = match[3];
428
+ result.isClip = true;
429
+ } else if (match && match[3] && match[4]) {
430
+ //twitch.tv/channel/clip/id
431
+ result.channel = match[3];
432
+ result.id = match[4];
433
+ result.isClip = true;
434
+ } else if (match && match[3]) {
435
+ result.channel = match[3];
436
+ }
437
+ return result;
438
+ };
439
+ Twitch.prototype.parseMediaType = function (result) {
440
+ var mediaType;
441
+ if (result.id) {
442
+ if (result.isClip) {
443
+ mediaType = this.mediaTypes.CLIP;
444
+ delete result.isClip;
445
+ } else {
446
+ mediaType = this.mediaTypes.VIDEO;
447
+ }
448
+ } else if (result.channel) {
449
+ mediaType = this.mediaTypes.STREAM;
450
+ }
451
+ return mediaType;
452
+ };
453
+ Twitch.prototype.parseParameters = function (params) {
454
+ if (params.t) {
455
+ params.start = getTime$4(params.t);
456
+ delete params.t;
457
+ }
458
+ return params;
459
+ };
460
+ Twitch.prototype.parse = function (url, params) {
461
+ var _this = this;
462
+ var result = {};
463
+ result = _this.parseUrl(url, result, params);
464
+ result.channel = _this.parseChannel(result, params);
465
+ result.mediaType = _this.parseMediaType(result);
466
+ result.params = _this.parseParameters(params);
467
+ return result.channel || result.id ? result : undefined;
468
+ };
469
+ Twitch.prototype.createLongUrl = function (vi, params) {
470
+ var url = '';
471
+ if (vi.mediaType === this.mediaTypes.STREAM && vi.channel) {
472
+ url = 'https://twitch.tv/' + vi.channel;
473
+ } else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
474
+ var sep = this.seperateId(vi.id);
475
+ url = 'https://twitch.tv/videos/' + sep.id;
476
+ if (params.start) {
477
+ params.t = params.start + 's';
478
+ delete params.start;
479
+ }
480
+ } else if (vi.mediaType === this.mediaTypes.CLIP && vi.id) {
481
+ if (vi.channel) {
482
+ url = 'https://www.twitch.tv/' + vi.channel + '/clip/' + vi.id;
483
+ } else {
484
+ url = 'https://clips.twitch.tv/' + vi.id;
485
+ }
486
+ } else {
487
+ return undefined;
488
+ }
489
+ url += combineParams$j(params);
490
+ return url;
491
+ };
492
+ Twitch.prototype.createEmbedUrl = function (vi, params) {
493
+ var url = 'https://player.twitch.tv/';
494
+ if (vi.mediaType === this.mediaTypes.STREAM && vi.channel) {
495
+ params.channel = vi.channel;
496
+ } else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
497
+ params.video = vi.id;
498
+ if (params.start) {
499
+ params.t = params.start + 's';
500
+ delete params.start;
501
+ }
502
+ } else if (vi.mediaType === this.mediaTypes.CLIP && vi.id) {
503
+ url = 'https://clips.twitch.tv/embed';
504
+ params.clip = vi.id;
505
+ } else {
506
+ return undefined;
507
+ }
508
+ url += combineParams$j(params);
509
+ return url;
510
+ };
511
+ base.bind(new Twitch());
512
+
513
+ var combineParams$i = util.combineParams,
514
+ getTime$3 = util.getTime;
515
+ function Vimeo() {
516
+ this.provider = 'vimeo';
517
+ this.alternatives = ['vimeopro'];
518
+ this.defaultFormat = 'long';
519
+ this.formats = {
520
+ "long": this.createLongUrl,
521
+ embed: this.createEmbedUrl
522
+ };
523
+ this.mediaTypes = {
524
+ VIDEO: 'video'
525
+ };
526
+ }
527
+ Vimeo.prototype.parseUrl = function (url) {
528
+ var match = url.match(/(?:\/showcase\/\d+)?(?:\/(?:channels\/[\w]+|(?:(?:album\/\d+|groups\/[\w]+)\/)?videos?))?\/(\d+)/i);
529
+ return match ? match[1] : undefined;
530
+ };
531
+ Vimeo.prototype.parseHash = function (url) {
532
+ var match = url.match(/\/\d+\/(\w+)$/i);
533
+ return match ? match[1] : undefined;
534
+ };
535
+ Vimeo.prototype.parseParameters = function (params) {
536
+ if (params.t) {
537
+ params.start = getTime$3(params.t);
538
+ delete params.t;
539
+ }
540
+ if (params.h) {
541
+ params.hash = params.h;
542
+ delete params.h;
543
+ }
544
+ return params;
545
+ };
546
+ Vimeo.prototype.parse = function (url, params) {
547
+ var result = {
548
+ mediaType: this.mediaTypes.VIDEO,
549
+ params: this.parseParameters(params),
550
+ id: this.parseUrl(url)
551
+ };
552
+ var hash = this.parseHash(url, params);
553
+ if (hash) {
554
+ result.params.hash = hash;
555
+ }
556
+ return result.id ? result : undefined;
557
+ };
558
+ Vimeo.prototype.createUrl = function (baseUrl, vi, params, type) {
559
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
560
+ return undefined;
561
+ }
562
+ var url = baseUrl + vi.id;
563
+ var startTime = params.start;
564
+ delete params.start;
565
+ if (params.hash) {
566
+ if (type === 'embed') {
567
+ params.h = params.hash;
568
+ } else if (type === 'long') {
569
+ url += '/' + params.hash;
570
+ }
571
+ delete params.hash;
572
+ }
573
+ url += combineParams$i(params);
574
+ if (startTime) {
575
+ url += '#t=' + startTime;
576
+ }
577
+ return url;
578
+ };
579
+ Vimeo.prototype.createLongUrl = function (vi, params) {
580
+ return this.createUrl('https://vimeo.com/', vi, params, 'long');
581
+ };
582
+ Vimeo.prototype.createEmbedUrl = function (vi, params) {
583
+ return this.createUrl('//player.vimeo.com/video/', vi, params, 'embed');
584
+ };
585
+ base.bind(new Vimeo());
586
+
587
+ var combineParams$h = util.combineParams,
588
+ getTime$2 = util.getTime;
589
+ function Wistia() {
590
+ this.provider = 'wistia';
591
+ this.alternatives = [];
592
+ this.defaultFormat = 'long';
593
+ this.formats = {
594
+ "long": this.createLongUrl,
595
+ embed: this.createEmbedUrl,
596
+ embedjsonp: this.createEmbedJsonpUrl
597
+ };
598
+ this.mediaTypes = {
599
+ VIDEO: 'video',
600
+ EMBEDVIDEO: 'embedvideo'
601
+ };
602
+ }
603
+ Wistia.prototype.parseUrl = function (url) {
604
+ var match = url.match(/(?:(?:medias|iframe)\/|wvideo=)([\w-]+)/);
605
+ return match ? match[1] : undefined;
606
+ };
607
+ Wistia.prototype.parseChannel = function (url) {
608
+ var match = url.match(/(?:(?:https?:)?\/\/)?([^.]*)\.wistia\./);
609
+ var channel = match ? match[1] : undefined;
610
+ if (channel === 'fast' || channel === 'content') {
611
+ return undefined;
612
+ }
613
+ return channel;
614
+ };
615
+ Wistia.prototype.parseParameters = function (params, result) {
616
+ if (params.wtime) {
617
+ params.start = getTime$2(params.wtime);
618
+ delete params.wtime;
619
+ }
620
+ if (params.wvideo === result.id) {
621
+ delete params.wvideo;
622
+ }
623
+ return params;
624
+ };
625
+ Wistia.prototype.parseMediaType = function (result) {
626
+ if (result.id && result.channel) {
627
+ return this.mediaTypes.VIDEO;
628
+ } else if (result.id) {
629
+ delete result.channel;
630
+ return this.mediaTypes.EMBEDVIDEO;
631
+ } else {
632
+ return undefined;
633
+ }
634
+ };
635
+ Wistia.prototype.parse = function (url, params) {
636
+ var result = {
637
+ id: this.parseUrl(url),
638
+ channel: this.parseChannel(url)
639
+ };
640
+ result.params = this.parseParameters(params, result);
641
+ result.mediaType = this.parseMediaType(result);
642
+ if (!result.id) {
643
+ return undefined;
644
+ }
645
+ return result;
646
+ };
647
+ Wistia.prototype.createUrl = function (vi, params, url) {
648
+ if (params.start) {
649
+ params.wtime = params.start;
650
+ delete params.start;
651
+ }
652
+ url += combineParams$h(params);
653
+ return url;
654
+ };
655
+ Wistia.prototype.createLongUrl = function (vi, params) {
656
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
657
+ return undefined;
658
+ }
659
+ var url = 'https://' + vi.channel + '.wistia.com/medias/' + vi.id;
660
+ return this.createUrl(vi, params, url);
661
+ };
662
+ Wistia.prototype.createEmbedUrl = function (vi, params) {
663
+ if (!vi.id || !(vi.mediaType === this.mediaTypes.VIDEO || vi.mediaType === this.mediaTypes.EMBEDVIDEO)) {
664
+ return undefined;
665
+ }
666
+ var url = 'https://fast.wistia.com/embed/iframe/' + vi.id;
667
+ return this.createUrl(vi, params, url);
668
+ };
669
+ Wistia.prototype.createEmbedJsonpUrl = function (vi) {
670
+ if (!vi.id || !(vi.mediaType === this.mediaTypes.VIDEO || vi.mediaType === this.mediaTypes.EMBEDVIDEO)) {
671
+ return undefined;
672
+ }
673
+ return 'https://fast.wistia.com/embed/medias/' + vi.id + '.jsonp';
674
+ };
675
+ base.bind(new Wistia());
676
+
677
+ var combineParams$g = util.combineParams;
678
+ function Youku() {
679
+ this.provider = 'youku';
680
+ this.defaultFormat = 'long';
681
+ this.formats = {
682
+ embed: this.createEmbedUrl,
683
+ "long": this.createLongUrl,
684
+ flash: this.createFlashUrl,
685
+ "static": this.createStaticUrl
686
+ };
687
+ this.mediaTypes = {
688
+ VIDEO: 'video'
689
+ };
690
+ }
691
+ Youku.prototype.parseUrl = function (url) {
692
+ var match = url.match(/(?:(?:embed|sid)\/|v_show\/id_|VideoIDS=)([a-zA-Z0-9]+)/);
693
+ return match ? match[1] : undefined;
694
+ };
695
+ Youku.prototype.parseParameters = function (params) {
696
+ if (params.VideoIDS) {
697
+ delete params.VideoIDS;
698
+ }
699
+ return params;
700
+ };
701
+ Youku.prototype.parse = function (url, params) {
702
+ var _this = this;
703
+ var result = {
704
+ mediaType: this.mediaTypes.VIDEO,
705
+ id: _this.parseUrl(url),
706
+ params: _this.parseParameters(params)
707
+ };
708
+ if (!result.id) {
709
+ return undefined;
710
+ }
711
+ return result;
712
+ };
713
+ Youku.prototype.createUrl = function (baseUrl, vi, params) {
714
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
715
+ return undefined;
716
+ }
717
+ var url = baseUrl + vi.id;
718
+ url += combineParams$g(params);
719
+ return url;
720
+ };
721
+ Youku.prototype.createEmbedUrl = function (vi, params) {
722
+ return this.createUrl('http://player.youku.com/embed/', vi, params);
723
+ };
724
+ Youku.prototype.createLongUrl = function (vi, params) {
725
+ return this.createUrl('http://v.youku.com/v_show/id_', vi, params);
726
+ };
727
+ Youku.prototype.createStaticUrl = function (vi, params) {
728
+ return this.createUrl('http://static.youku.com/v1.0.0638/v/swf/loader.swf?VideoIDS=', vi, params);
729
+ };
730
+ Youku.prototype.createFlashUrl = function (vi, params) {
731
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
732
+ return undefined;
733
+ }
734
+ var url = 'http://player.youku.com/player.php/sid/' + vi.id + '/v.swf';
735
+ url += combineParams$g(params);
736
+ return url;
737
+ };
738
+ base.bind(new Youku());
739
+
740
+ var combineParams$f = util.combineParams,
741
+ getTime$1 = util.getTime;
742
+ function YouTube() {
743
+ this.provider = 'youtube';
744
+ this.alternatives = ['youtu', 'ytimg'];
745
+ this.defaultFormat = 'long';
746
+ this.formats = {
747
+ "short": this.createShortUrl,
748
+ "long": this.createLongUrl,
749
+ embed: this.createEmbedUrl,
750
+ shortImage: this.createShortImageUrl,
751
+ longImage: this.createLongImageUrl
752
+ };
753
+ this.imageQualities = {
754
+ '0': '0',
755
+ '1': '1',
756
+ '2': '2',
757
+ '3': '3',
758
+ DEFAULT: 'default',
759
+ HQDEFAULT: 'hqdefault',
760
+ SDDEFAULT: 'sddefault',
761
+ MQDEFAULT: 'mqdefault',
762
+ MAXRESDEFAULT: 'maxresdefault'
763
+ };
764
+ this.defaultImageQuality = this.imageQualities.HQDEFAULT;
765
+ this.mediaTypes = {
766
+ VIDEO: 'video',
767
+ PLAYLIST: 'playlist',
768
+ SHARE: 'share',
769
+ CHANNEL: 'channel'
770
+ };
771
+ }
772
+ YouTube.prototype.parseVideoUrl = function (url) {
773
+ var match = url.match(/(?:(?:v|vi|be|videos|shorts|embed|live)\/(?!videoseries)|(?:v|ci)=)([\w-]{11})/i);
774
+ return match ? match[1] : undefined;
775
+ };
776
+ YouTube.prototype.parseChannelUrl = function (url) {
777
+ // Match an opaque channel ID
778
+ var match = url.match(/\/channel\/([\w-]+)/);
779
+ if (match) {
780
+ return {
781
+ id: match[1],
782
+ mediaType: this.mediaTypes.CHANNEL
783
+ };
784
+ }
785
+
786
+ // Match a vanity channel name or a user name. User urls are deprecated and
787
+ // currently redirect to the channel of that same name.
788
+ match = url.match(/\/(?:c|user)\/([\w-]+)/);
789
+ if (match) {
790
+ return {
791
+ name: match[1],
792
+ mediaType: this.mediaTypes.CHANNEL
793
+ };
794
+ }
795
+ };
796
+ YouTube.prototype.parseParameters = function (params, result) {
797
+ if (params.start || params.t) {
798
+ params.start = getTime$1(params.start || params.t);
799
+ delete params.t;
800
+ }
801
+ if (params.v === result.id) {
802
+ delete params.v;
803
+ }
804
+ if (params.list === result.id) {
805
+ delete params.list;
806
+ }
807
+ return params;
808
+ };
809
+ YouTube.prototype.parseMediaType = function (result) {
810
+ if (result.params.list) {
811
+ result.list = result.params.list;
812
+ delete result.params.list;
813
+ }
814
+ if (result.id && !result.params.ci) {
815
+ result.mediaType = this.mediaTypes.VIDEO;
816
+ } else if (result.list) {
817
+ delete result.id;
818
+ result.mediaType = this.mediaTypes.PLAYLIST;
819
+ } else if (result.params.ci) {
820
+ delete result.params.ci;
821
+ result.mediaType = this.mediaTypes.SHARE;
822
+ } else {
823
+ return undefined;
824
+ }
825
+ return result;
826
+ };
827
+ YouTube.prototype.parse = function (url, params) {
828
+ var channelResult = this.parseChannelUrl(url);
829
+ if (channelResult) {
830
+ return channelResult;
831
+ } else {
832
+ var result = {
833
+ params: params,
834
+ id: this.parseVideoUrl(url)
835
+ };
836
+ result.params = this.parseParameters(params, result);
837
+ result = this.parseMediaType(result);
838
+ return result;
839
+ }
840
+ };
841
+ YouTube.prototype.createShortUrl = function (vi, params) {
842
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
843
+ return undefined;
844
+ }
845
+ var url = 'https://youtu.be/' + vi.id;
846
+ if (params.start) {
847
+ url += '#t=' + params.start;
848
+ }
849
+ return url;
850
+ };
851
+ YouTube.prototype.createLongUrl = function (vi, params) {
852
+ var url = '';
853
+ var startTime = params.start;
854
+ delete params.start;
855
+ if (vi.mediaType === this.mediaTypes.CHANNEL) {
856
+ if (vi.id) {
857
+ url += 'https://www.youtube.com/channel/' + vi.id;
858
+ } else if (vi.name) {
859
+ url += 'https://www.youtube.com/c/' + vi.name;
860
+ } else {
861
+ return undefined;
862
+ }
863
+ } else if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.list) {
864
+ params.feature = 'share';
865
+ url += 'https://www.youtube.com/playlist';
866
+ } else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
867
+ params.v = vi.id;
868
+ url += 'https://www.youtube.com/watch';
869
+ } else if (vi.mediaType === this.mediaTypes.SHARE && vi.id) {
870
+ params.ci = vi.id;
871
+ url += 'https://www.youtube.com/shared';
872
+ } else {
873
+ return undefined;
874
+ }
875
+ if (vi.list) {
876
+ params.list = vi.list;
877
+ }
878
+ url += combineParams$f(params);
879
+ if (vi.mediaType !== this.mediaTypes.PLAYLIST && startTime) {
880
+ url += '#t=' + startTime;
881
+ }
882
+ return url;
883
+ };
884
+ YouTube.prototype.createEmbedUrl = function (vi, params) {
885
+ var url = 'https://www.youtube.com/embed';
886
+ if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.list) {
887
+ params.listType = 'playlist';
888
+ } else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
889
+ url += '/' + vi.id;
890
+ //loop hack
891
+ if (params.loop === '1') {
892
+ params.playlist = vi.id;
893
+ }
894
+ } else {
895
+ return undefined;
896
+ }
897
+ if (vi.list) {
898
+ params.list = vi.list;
899
+ }
900
+ url += combineParams$f(params);
901
+ return url;
902
+ };
903
+ YouTube.prototype.createImageUrl = function (baseUrl, vi, params) {
904
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
905
+ return undefined;
906
+ }
907
+ var url = baseUrl + vi.id + '/';
908
+ var quality = params.imageQuality || this.defaultImageQuality;
909
+ return url + quality + '.jpg';
910
+ };
911
+ YouTube.prototype.createShortImageUrl = function (vi, params) {
912
+ return this.createImageUrl('https://i.ytimg.com/vi/', vi, params);
913
+ };
914
+ YouTube.prototype.createLongImageUrl = function (vi, params) {
915
+ return this.createImageUrl('https://img.youtube.com/vi/', vi, params);
916
+ };
917
+ base.bind(new YouTube());
918
+
919
+ var combineParams$e = util.combineParams,
920
+ getTime = util.getTime;
921
+ function SoundCloud() {
922
+ this.provider = 'soundcloud';
923
+ this.defaultFormat = 'long';
924
+ this.formats = {
925
+ "long": this.createLongUrl,
926
+ embed: this.createEmbedUrl
927
+ };
928
+ this.mediaTypes = {
929
+ TRACK: 'track',
930
+ PLAYLIST: 'playlist',
931
+ APITRACK: 'apitrack',
932
+ APIPLAYLIST: 'apiplaylist'
933
+ };
934
+ }
935
+ SoundCloud.prototype.parseUrl = function (url, result) {
936
+ var match = url.match(/(?:m\.)?soundcloud\.com\/(?:([\w-]+)\/(sets\/)?)([\w-]+)/i);
937
+ if (!match) {
938
+ return result;
939
+ }
940
+ result.channel = match[1];
941
+ if (match[1] === 'playlists' || match[2]) {
942
+ //playlist
943
+ result.list = match[3];
944
+ } else {
945
+ //track
946
+ result.id = match[3];
947
+ }
948
+ return result;
949
+ };
950
+ SoundCloud.prototype.parseParameters = function (params) {
951
+ if (params.t) {
952
+ params.start = getTime(params.t);
953
+ delete params.t;
954
+ }
955
+ return params;
956
+ };
957
+ SoundCloud.prototype.parseMediaType = function (result) {
958
+ if (result.id) {
959
+ if (result.channel === 'tracks') {
960
+ delete result.channel;
961
+ delete result.params.url;
962
+ result.mediaType = this.mediaTypes.APITRACK;
963
+ } else {
964
+ result.mediaType = this.mediaTypes.TRACK;
965
+ }
966
+ }
967
+ if (result.list) {
968
+ if (result.channel === 'playlists') {
969
+ delete result.channel;
970
+ delete result.params.url;
971
+ result.mediaType = this.mediaTypes.APIPLAYLIST;
972
+ } else {
973
+ result.mediaType = this.mediaTypes.PLAYLIST;
974
+ }
975
+ }
976
+ return result;
977
+ };
978
+ SoundCloud.prototype.parse = function (url, params) {
979
+ var result = {};
980
+ result = this.parseUrl(url, result);
981
+ result.params = this.parseParameters(params);
982
+ result = this.parseMediaType(result);
983
+ if (!result.id && !result.list) {
984
+ return undefined;
985
+ }
986
+ return result;
987
+ };
988
+ SoundCloud.prototype.createLongUrl = function (vi, params) {
989
+ var url = '';
990
+ var startTime = params.start;
991
+ delete params.start;
992
+ if (vi.mediaType === this.mediaTypes.TRACK && vi.id && vi.channel) {
993
+ url = 'https://soundcloud.com/' + vi.channel + '/' + vi.id;
994
+ } else if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.list && vi.channel) {
995
+ url = 'https://soundcloud.com/' + vi.channel + '/sets/' + vi.list;
996
+ } else if (vi.mediaType === this.mediaTypes.APITRACK && vi.id) {
997
+ url = 'https://api.soundcloud.com/tracks/' + vi.id;
998
+ } else if (vi.mediaType === this.mediaTypes.APIPLAYLIST && vi.list) {
999
+ url = 'https://api.soundcloud.com/playlists/' + vi.list;
1000
+ } else {
1001
+ return undefined;
1002
+ }
1003
+ url += combineParams$e(params);
1004
+ if (startTime) {
1005
+ url += '#t=' + startTime;
1006
+ }
1007
+ return url;
1008
+ };
1009
+ SoundCloud.prototype.createEmbedUrl = function (vi, params) {
1010
+ var url = 'https://w.soundcloud.com/player/';
1011
+ delete params.start;
1012
+ if (vi.mediaType === this.mediaTypes.APITRACK && vi.id) {
1013
+ params.url = 'https%3A//api.soundcloud.com/tracks/' + vi.id;
1014
+ } else if (vi.mediaType === this.mediaTypes.APIPLAYLIST && vi.list) {
1015
+ params.url = 'https%3A//api.soundcloud.com/playlists/' + vi.list;
1016
+ } else {
1017
+ return undefined;
1018
+ }
1019
+ url += combineParams$e(params);
1020
+ return url;
1021
+ };
1022
+ base.bind(new SoundCloud());
1023
+
1024
+ var combineParams$d = util.combineParams;
1025
+ function TeacherTube() {
1026
+ this.provider = 'teachertube';
1027
+ this.alternatives = [];
1028
+ this.defaultFormat = 'long';
1029
+ this.formats = {
1030
+ "long": this.createLongUrl,
1031
+ embed: this.createEmbedUrl
1032
+ };
1033
+ this.mediaTypes = {
1034
+ VIDEO: 'video',
1035
+ AUDIO: 'audio',
1036
+ DOCUMENT: 'document',
1037
+ CHANNEL: 'channel',
1038
+ COLLECTION: 'collection',
1039
+ GROUP: 'group'
1040
+ };
1041
+ }
1042
+ TeacherTube.prototype.parse = function (url, params) {
1043
+ var result = {};
1044
+ result.list = this.parsePlaylist(params);
1045
+ result.params = params;
1046
+ var match = url.match(/\/(audio|video|document|user\/channel|collection|group)\/(?:[\w-]+-)?(\w+)/);
1047
+ if (!match) {
1048
+ return undefined;
1049
+ }
1050
+ result.mediaType = this.parseMediaType(match[1]);
1051
+ result.id = match[2];
1052
+ return result;
1053
+ };
1054
+ TeacherTube.prototype.parsePlaylist = function (params) {
1055
+ if (params['playlist-id']) {
1056
+ var list = params['playlist-id'];
1057
+ delete params['playlist-id'];
1058
+ return list;
1059
+ }
1060
+ return undefined;
1061
+ };
1062
+ TeacherTube.prototype.parseMediaType = function (mediaTypeMatch) {
1063
+ switch (mediaTypeMatch) {
1064
+ case 'audio':
1065
+ return this.mediaTypes.AUDIO;
1066
+ case 'video':
1067
+ return this.mediaTypes.VIDEO;
1068
+ case 'document':
1069
+ return this.mediaTypes.DOCUMENT;
1070
+ case 'user/channel':
1071
+ return this.mediaTypes.CHANNEL;
1072
+ case 'collection':
1073
+ return this.mediaTypes.COLLECTION;
1074
+ case 'group':
1075
+ return this.mediaTypes.GROUP;
1076
+ }
1077
+ };
1078
+ TeacherTube.prototype.createLongUrl = function (vi, params) {
1079
+ if (!vi.id) {
1080
+ return undefined;
1081
+ }
1082
+ var url = 'https://www.teachertube.com/';
1083
+ if (vi.list) {
1084
+ params['playlist-id'] = vi.list;
1085
+ }
1086
+ if (vi.mediaType === this.mediaTypes.CHANNEL) {
1087
+ url += 'user/channel/';
1088
+ } else {
1089
+ url += vi.mediaType + '/';
1090
+ }
1091
+ url += vi.id;
1092
+ url += combineParams$d(params);
1093
+ return url;
1094
+ };
1095
+ TeacherTube.prototype.createEmbedUrl = function (vi, params) {
1096
+ if (!vi.id) {
1097
+ return undefined;
1098
+ }
1099
+ var url = 'https://www.teachertube.com/embed/';
1100
+ if (vi.mediaType === this.mediaTypes.VIDEO || vi.mediaType === this.mediaTypes.AUDIO) {
1101
+ url += vi.mediaType + '/' + vi.id;
1102
+ } else {
1103
+ return undefined;
1104
+ }
1105
+ url += combineParams$d(params);
1106
+ return url;
1107
+ };
1108
+ base.bind(new TeacherTube());
1109
+
1110
+ var combineParams$c = util.combineParams;
1111
+ function TikTok() {
1112
+ this.provider = 'tiktok';
1113
+ this.defaultFormat = 'long';
1114
+ this.formats = {
1115
+ "long": this.createLongUrl
1116
+ };
1117
+ this.mediaTypes = {
1118
+ VIDEO: 'video'
1119
+ };
1120
+ }
1121
+ TikTok.prototype.parse = function (url, params) {
1122
+ var result = {
1123
+ params: params,
1124
+ mediaType: this.mediaTypes.VIDEO
1125
+ };
1126
+ var match = url.match(/@([^/]+)\/video\/(\d{19})/);
1127
+ if (!match) {
1128
+ return;
1129
+ }
1130
+ result.channel = match[1];
1131
+ result.id = match[2];
1132
+ return result;
1133
+ };
1134
+ TikTok.prototype.createLongUrl = function (vi, params) {
1135
+ var url = '';
1136
+ if (vi.mediaType === this.mediaTypes.VIDEO && vi.id && vi.channel) {
1137
+ url += "https://www.tiktok.com/@".concat(vi.channel, "/video/").concat(vi.id);
1138
+ } else {
1139
+ return undefined;
1140
+ }
1141
+ url += combineParams$c(params);
1142
+ return url;
1143
+ };
1144
+ base.bind(new TikTok());
1145
+
1146
+ var combineParams$b = util.combineParams;
1147
+ function Voomly() {
1148
+ this.provider = 'voomly';
1149
+ this.defaultFormat = 'long';
1150
+ this.formats = {
1151
+ "long": this.createLongUrl
1152
+ };
1153
+ this.mediaTypes = {
1154
+ VIDEO: 'video'
1155
+ };
1156
+ }
1157
+ Voomly.prototype.parseUrl = function (url) {
1158
+ var match = url.match(/(?:v|embed)\/([\w-]+)/i);
1159
+ return match ? match[1] : undefined;
1160
+ };
1161
+ Voomly.prototype.parse = function (url, params) {
1162
+ var result = {
1163
+ mediaType: this.mediaTypes.VIDEO,
1164
+ params: params,
1165
+ id: this.parseUrl(url)
1166
+ };
1167
+ return result.id ? result : undefined;
1168
+ };
1169
+ Voomly.prototype.createUrl = function (baseUrl, vi, params) {
1170
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1171
+ return undefined;
1172
+ }
1173
+ var url = baseUrl + vi.id;
1174
+ url += combineParams$b(params);
1175
+ return url;
1176
+ };
1177
+ Voomly.prototype.createLongUrl = function (vi, params) {
1178
+ return this.createUrl('https://share.voomly.com/v/', vi, params);
1179
+ };
1180
+ base.bind(new Voomly());
1181
+
1182
+ var combineParams$a = util.combineParams;
1183
+ function Spotlightr() {
1184
+ this.provider = 'spotlightr';
1185
+ this.defaultFormat = 'long';
1186
+ this.formats = {
1187
+ "long": this.createLongUrl
1188
+ };
1189
+ this.mediaTypes = {
1190
+ VIDEO: 'video'
1191
+ };
1192
+ }
1193
+ Spotlightr.prototype.parseUrl = function (url) {
1194
+ var match = url.match(/(?:watch|embed)\/([a-zA-Z\d]+)/i);
1195
+ //var match = url.match(/(?:\/(\d+))?\/watch(?:\/.*?)?\/(\d+)/i);
1196
+ return match ? match[1] : undefined;
1197
+ };
1198
+ Spotlightr.prototype.parse = function (url, params) {
1199
+ var result = {
1200
+ mediaType: this.mediaTypes.VIDEO,
1201
+ params: params,
1202
+ id: this.parseUrl(url)
1203
+ };
1204
+ return result.id ? result : undefined;
1205
+ };
1206
+ Spotlightr.prototype.createUrl = function (baseUrl, vi, params) {
1207
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1208
+ return undefined;
1209
+ }
1210
+ var url = baseUrl + vi.id;
1211
+ url += combineParams$a(params);
1212
+ return url;
1213
+ };
1214
+ Spotlightr.prototype.createLongUrl = function (vi, params) {
1215
+ return this.createUrl('https://videos.spotlightr.com/watch/', vi, params);
1216
+ };
1217
+ base.bind(new Spotlightr());
1218
+
1219
+ var combineParams$9 = util.combineParams;
1220
+ function Bunny() {
1221
+ this.provider = 'bunny';
1222
+ this.alternatives = ['bunnycdn', 'mediadelivery'];
1223
+ this.defaultFormat = 'long';
1224
+ this.formats = {
1225
+ "long": this.createLongUrl
1226
+ };
1227
+ this.mediaTypes = {
1228
+ VIDEO: 'video'
1229
+ };
1230
+ }
1231
+ Bunny.prototype.parse = function (url, params) {
1232
+ var match = url.match(/(?:play|embed)\/([a-zA-Z\d]+)\/([\w-]+)/i);
1233
+ if (!match) {
1234
+ return undefined;
1235
+ }
1236
+ var result = {
1237
+ mediaType: this.mediaTypes.VIDEO,
1238
+ params: params,
1239
+ library: match[1],
1240
+ id: match[2]
1241
+ };
1242
+ return result.id ? result : undefined;
1243
+ };
1244
+ Bunny.prototype.createUrl = function (baseUrl, vi, params) {
1245
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1246
+ return undefined;
1247
+ }
1248
+ var url = baseUrl + vi.library + '/' + vi.id;
1249
+ url += combineParams$9(params);
1250
+ return url;
1251
+ };
1252
+ Bunny.prototype.createLongUrl = function (vi, params) {
1253
+ return this.createUrl('https://iframe.mediadelivery.net/embed/', vi, params);
1254
+ };
1255
+ base.bind(new Bunny());
1256
+
1257
+ var combineParams$8 = util.combineParams;
1258
+ function Canva() {
1259
+ this.provider = 'canva';
1260
+ this.defaultFormat = 'long';
1261
+ this.formats = {
1262
+ "long": this.createLongUrl
1263
+ };
1264
+ this.mediaTypes = {
1265
+ VIDEO: 'video'
1266
+ };
1267
+ }
1268
+ Canva.prototype.parse = function (url, params) {
1269
+ var match = url.match(/\/design\/(.+)\/watch/);
1270
+ if (!match) {
1271
+ return undefined;
1272
+ }
1273
+ var result = {
1274
+ mediaType: this.mediaTypes.VIDEO,
1275
+ params: params,
1276
+ id: match[1]
1277
+ };
1278
+ return result.id ? result : undefined;
1279
+ };
1280
+ Canva.prototype.createUrl = function (baseUrl, vi, params) {
1281
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1282
+ return undefined;
1283
+ }
1284
+ var url = baseUrl + vi.id + '/watch';
1285
+ url += combineParams$8(params);
1286
+ return url;
1287
+ };
1288
+ Canva.prototype.createLongUrl = function (vi, params) {
1289
+ return this.createUrl('https://www.canva.com/design/', vi, params);
1290
+ };
1291
+ base.bind(new Canva());
1292
+
1293
+ var combineParams$7 = util.combineParams;
1294
+ function Ted() {
1295
+ this.provider = 'ted';
1296
+ this.formats = {
1297
+ "long": this.createLongUrl,
1298
+ embed: this.createEmbedUrl
1299
+ };
1300
+ this.mediaTypes = {
1301
+ VIDEO: 'video',
1302
+ PLAYLIST: 'playlist'
1303
+ };
1304
+ }
1305
+ Ted.prototype.parseUrl = function (url, result) {
1306
+ var match = url.match(/\/(talks|playlists\/(\d+))\/([\w-]+)/i);
1307
+ var channel = match ? match[1] : undefined;
1308
+ if (!channel) {
1309
+ return result;
1310
+ }
1311
+ result.channel = channel.split('/')[0];
1312
+ result.id = match[3];
1313
+ if (result.channel === 'playlists') {
1314
+ result.list = match[2];
1315
+ }
1316
+ return result;
1317
+ };
1318
+ Ted.prototype.parseMediaType = function (result) {
1319
+ if (result.id && result.channel === 'playlists') {
1320
+ delete result.channel;
1321
+ result.mediaType = this.mediaTypes.PLAYLIST;
1322
+ }
1323
+ if (result.id && result.channel === 'talks') {
1324
+ delete result.channel;
1325
+ result.mediaType = this.mediaTypes.VIDEO;
1326
+ }
1327
+ return result;
1328
+ };
1329
+ Ted.prototype.parse = function (url, params) {
1330
+ var result = {
1331
+ params: params
1332
+ };
1333
+ result = this.parseUrl(url, result);
1334
+ result = this.parseMediaType(result);
1335
+ if (!result.id) {
1336
+ return undefined;
1337
+ }
1338
+ return result;
1339
+ };
1340
+ Ted.prototype.createLongUrl = function (vi, params) {
1341
+ var url = '';
1342
+ if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
1343
+ url += 'https://ted.com/talks/' + vi.id;
1344
+ } else if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.id) {
1345
+ url += 'https://ted.com/playlists/' + vi.list + '/' + vi.id;
1346
+ } else {
1347
+ return undefined;
1348
+ }
1349
+ url += combineParams$7(params);
1350
+ return url;
1351
+ };
1352
+ Ted.prototype.createEmbedUrl = function (vi, params) {
1353
+ var url = 'https://embed.ted.com/';
1354
+ if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.id) {
1355
+ url += 'playlists/' + vi.list + '/' + vi.id;
1356
+ } else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
1357
+ url += 'talks/' + vi.id;
1358
+ } else {
1359
+ return undefined;
1360
+ }
1361
+ url += combineParams$7(params);
1362
+ return url;
1363
+ };
1364
+ base.bind(new Ted());
1365
+
1366
+ var combineParams$6 = util.combineParams;
1367
+ function Facebook() {
1368
+ this.provider = 'facebook';
1369
+ this.alternatives = [];
1370
+ this.defaultFormat = 'long';
1371
+ this.formats = {
1372
+ "long": this.createLongUrl,
1373
+ watch: this.createWatchUrl
1374
+ };
1375
+ this.mediaTypes = {
1376
+ VIDEO: 'video'
1377
+ };
1378
+ }
1379
+ Facebook.prototype.parse = function (url, params) {
1380
+ var result = {
1381
+ params: params,
1382
+ mediaType: this.mediaTypes.VIDEO
1383
+ };
1384
+ var match = url.match(/(?:\/(\d+))?\/videos(?:\/.*?)?\/(\d+)/i);
1385
+ if (match) {
1386
+ if (match[1]) {
1387
+ result.pageId = match[1];
1388
+ }
1389
+ result.id = match[2];
1390
+ }
1391
+ if (params.v && !result.id) {
1392
+ result.id = params.v;
1393
+ delete params.v;
1394
+ result.params = params;
1395
+ }
1396
+ if (!result.id) {
1397
+ return undefined;
1398
+ }
1399
+ return result;
1400
+ };
1401
+ Facebook.prototype.createWatchUrl = function (vi, params) {
1402
+ var url = 'https://facebook.com/watch/';
1403
+ if (vi.mediaType !== this.mediaTypes.VIDEO || !vi.id) {
1404
+ return undefined;
1405
+ }
1406
+ params = {
1407
+ v: vi.id
1408
+ };
1409
+ url += combineParams$6(params);
1410
+ return url;
1411
+ };
1412
+ Facebook.prototype.createLongUrl = function (vi, params) {
1413
+ var url = 'https://facebook.com/';
1414
+ if (vi.pageId) {
1415
+ url += vi.pageId;
1416
+ } else {
1417
+ return undefined;
1418
+ }
1419
+ if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
1420
+ url += '/videos/' + vi.id;
1421
+ } else {
1422
+ return undefined;
1423
+ }
1424
+ url += combineParams$6(params);
1425
+ return url;
1426
+ };
1427
+ base.bind(new Facebook());
1428
+
1429
+ var combineParams$5 = util.combineParams;
1430
+ function Bigcommand() {
1431
+ this.provider = 'bigcommand';
1432
+ this.defaultFormat = 'long';
1433
+ this.formats = {
1434
+ "long": this.createLongUrl
1435
+ };
1436
+ this.mediaTypes = {
1437
+ VIDEO: 'video'
1438
+ };
1439
+ }
1440
+ Bigcommand.prototype.parse = function (url, params) {
1441
+ var match = url.match(/(?:watch)\/([\w-]+)/i);
1442
+ if (!match) {
1443
+ return undefined;
1444
+ }
1445
+ var result = {
1446
+ mediaType: this.mediaTypes.VIDEO,
1447
+ params: params,
1448
+ id: match[1]
1449
+ };
1450
+ return result.id ? result : undefined;
1451
+ };
1452
+ Bigcommand.prototype.createUrl = function (baseUrl, vi, params) {
1453
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1454
+ return undefined;
1455
+ }
1456
+ var url = baseUrl + vi.id;
1457
+ url += combineParams$5(params);
1458
+ return url;
1459
+ };
1460
+ Bigcommand.prototype.createLongUrl = function (vi, params) {
1461
+ return this.createUrl('https://adilo.bigcommand.com/watch/', vi, params);
1462
+ };
1463
+ base.bind(new Bigcommand());
1464
+
1465
+ var combineParams$4 = util.combineParams;
1466
+ function GoogleDrive() {
1467
+ this.provider = 'google';
1468
+ this.defaultFormat = 'long';
1469
+ this.formats = {
1470
+ "long": this.createLongUrl
1471
+ };
1472
+ this.mediaTypes = {
1473
+ VIDEO: 'video'
1474
+ };
1475
+ }
1476
+ GoogleDrive.prototype.parseUrl = function (url) {
1477
+ var match = url.match(/\/d\/([\w-]+)/);
1478
+ return match ? match[1] : undefined;
1479
+ };
1480
+ GoogleDrive.prototype.parse = function (url, params) {
1481
+ var result = {
1482
+ mediaType: this.mediaTypes.VIDEO,
1483
+ params: params,
1484
+ id: this.parseUrl(url)
1485
+ };
1486
+ return result.id ? result : undefined;
1487
+ };
1488
+ GoogleDrive.prototype.createUrl = function (baseUrl, vi, params) {
1489
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1490
+ return undefined;
1491
+ }
1492
+ var url = baseUrl + vi.id + '/preview';
1493
+ url += combineParams$4(params);
1494
+ return url;
1495
+ };
1496
+ GoogleDrive.prototype.createLongUrl = function (vi, params) {
1497
+ return this.createUrl('https://drive.google.com/file/d/', vi, params);
1498
+ };
1499
+ base.bind(new GoogleDrive());
1500
+
1501
+ var combineParams$3 = util.combineParams;
1502
+ function Groove() {
1503
+ this.provider = 'groove';
1504
+ this.defaultFormat = 'long';
1505
+ this.formats = {
1506
+ "long": this.createLongUrl
1507
+ };
1508
+ this.mediaTypes = {
1509
+ VIDEO: 'video'
1510
+ };
1511
+ }
1512
+ Groove.prototype.parse = function (url, params) {
1513
+ var match = url.match(/(?:videopage)\/([\w-]+)\/([\w-]+)/i);
1514
+ if (!match) {
1515
+ return undefined;
1516
+ }
1517
+ var result = {
1518
+ mediaType: this.mediaTypes.VIDEO,
1519
+ params: params,
1520
+ library: match[1],
1521
+ id: match[2]
1522
+ };
1523
+ return result.id ? result : undefined;
1524
+ };
1525
+ Groove.prototype.createUrl = function (baseUrl, vi, params) {
1526
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1527
+ return undefined;
1528
+ }
1529
+ var url = baseUrl + vi.library + '/' + vi.id;
1530
+ url += combineParams$3(params);
1531
+ return url;
1532
+ };
1533
+ Groove.prototype.createLongUrl = function (vi, params) {
1534
+ return this.createUrl('https://app.groove.cm/groovevideo/videopage/', vi, params);
1535
+ };
1536
+ base.bind(new Groove());
1537
+
1538
+ var combineParams$2 = util.combineParams;
1539
+ function Streamable() {
1540
+ this.provider = 'streamable';
1541
+ this.defaultFormat = 'long';
1542
+ this.formats = {
1543
+ "long": this.createLongUrl
1544
+ };
1545
+ this.mediaTypes = {
1546
+ VIDEO: 'video'
1547
+ };
1548
+ }
1549
+ Streamable.prototype.parseUrl = function (url) {
1550
+ var match = url.match(/com\/(?:streamable\/)?([\w-]+)/);
1551
+ //var match = url.match(/(?:\/(\d+))?\/watch(?:\/.*?)?\/(\d+)/i);
1552
+ return match ? match[1] : undefined;
1553
+ };
1554
+ Streamable.prototype.parse = function (url, params) {
1555
+ var result = {
1556
+ mediaType: this.mediaTypes.VIDEO,
1557
+ params: params,
1558
+ id: this.parseUrl(url)
1559
+ };
1560
+ return result.id ? result : undefined;
1561
+ };
1562
+ Streamable.prototype.createUrl = function (baseUrl, vi, params) {
1563
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1564
+ return undefined;
1565
+ }
1566
+ var url = baseUrl + vi.id;
1567
+ url += combineParams$2(params);
1568
+ return url;
1569
+ };
1570
+ Streamable.prototype.createLongUrl = function (vi, params) {
1571
+ return this.createUrl('https://streamable.com/', vi, params);
1572
+ };
1573
+ base.bind(new Streamable());
1574
+
1575
+ var combineParams$1 = util.combineParams;
1576
+ function Searchie() {
1577
+ this.provider = 'searchie';
1578
+ this.defaultFormat = 'long';
1579
+ this.formats = {
1580
+ "long": this.createLongUrl
1581
+ };
1582
+ this.mediaTypes = {
1583
+ VIDEO: 'video'
1584
+ };
1585
+ }
1586
+ Searchie.prototype.parseUrl = function (url) {
1587
+ var match = url.match(/(?:watch)\/([\w-]+)/i);
1588
+ return match ? match[1] : undefined;
1589
+ };
1590
+ Searchie.prototype.parse = function (url, params) {
1591
+ var result = {
1592
+ mediaType: this.mediaTypes.VIDEO,
1593
+ params: params,
1594
+ id: this.parseUrl(url)
1595
+ };
1596
+ return result.id ? result : undefined;
1597
+ };
1598
+ Searchie.prototype.createUrl = function (baseUrl, vi, params) {
1599
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1600
+ return undefined;
1601
+ }
1602
+ var url = baseUrl + vi.id;
1603
+ url += combineParams$1(params);
1604
+ return url;
1605
+ };
1606
+ Searchie.prototype.createLongUrl = function (vi, params) {
1607
+ return this.createUrl('https://app.searchie.io/watch/', vi, params);
1608
+ };
1609
+ base.bind(new Searchie());
1610
+
1611
+ var combineParams = util.combineParams;
1612
+ function Tevello() {
1613
+ this.provider = 'tevello';
1614
+ this.defaultFormat = 'long';
1615
+ this.formats = {
1616
+ "long": this.createLongUrl
1617
+ };
1618
+ this.mediaTypes = {
1619
+ VIDEO: 'video'
1620
+ };
1621
+ }
1622
+ Tevello.prototype.parse = function (url, params) {
1623
+ var match = url.match(/\/([a-zA-Z\d]+)\/([\w-]+)/i);
1624
+ if (!match) {
1625
+ return undefined;
1626
+ }
1627
+ var result = {
1628
+ mediaType: this.mediaTypes.VIDEO,
1629
+ params: params,
1630
+ library: match[1],
1631
+ id: match[2]
1632
+ };
1633
+ return result.id ? result : undefined;
1634
+ };
1635
+ Tevello.prototype.createUrl = function (baseUrl, vi, params) {
1636
+ if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
1637
+ return undefined;
1638
+ }
1639
+ var url = baseUrl + vi.library + '/' + vi.id;
1640
+ url += combineParams(params);
1641
+ return url;
1642
+ };
1643
+ Tevello.prototype.createLongUrl = function (vi, params) {
1644
+ return this.createUrl('https://video.tevello.com/', vi, params);
1645
+ };
1646
+ base.bind(new Tevello());
1647
+
1648
+ var parser = base;
1649
+ var lib = parser;
1650
+ var index = /*@__PURE__*/getDefaultExportFromCjs(lib);
1651
+
1652
+ return index;
1653
+
1654
+ }));