Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-video-url-parser

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-video-url-parser - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

1996

dist/jsVideoUrlParser.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.urlParser = factory());
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.urlParser = factory());
}(this, (function () { 'use strict';
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
function _typeof(obj) {
"@babel/helpers - typeof";
return _typeof(obj);
}
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
var getQueryParams = function getQueryParams(qs) {
if (typeof qs !== 'string') {
return {};
return _typeof(obj);
}
qs = qs.split('+').join(' ');
var params = {};
var match = qs.match(/(?:[?](?:[^=]+)=(?:[^&#]*)(?:[&](?:[^=]+)=(?:[^&#]*))*(?:[#].*)?)|(?:[#].*)/);
var split;
var getQueryParams = function getQueryParams(qs) {
if (typeof qs !== 'string') {
return {};
}
if (match === null) {
return {};
}
qs = qs.split('+').join(' ');
var params = {};
var match = qs.match(/(?:[?](?:[^=]+)=(?:[^&#]*)(?:[&](?:[^=]+)=(?:[^&#]*))*(?:[#].*)?)|(?:[#].*)/);
var split;
split = match[0].substr(1).split(/[&#=]/);
if (match === null) {
return {};
}
for (var i = 0; i < split.length; i += 2) {
params[decodeURIComponent(split[i])] = decodeURIComponent(split[i + 1] || '');
}
split = match[0].substr(1).split(/[&#=]/);
return params;
};
for (var i = 0; i < split.length; i += 2) {
params[decodeURIComponent(split[i])] = decodeURIComponent(split[i + 1] || '');
}
var combineParams = function combineParams(params, hasParams) {
if (_typeof(params) !== 'object') {
return '';
}
return params;
};
var combined = '';
var i = 0;
var keys = Object.keys(params);
var combineParams = function combineParams(params, hasParams) {
if (_typeof(params) !== 'object') {
return '';
}
if (keys.length === 0) {
return '';
} //always have parameters in the same order
var combined = '';
var i = 0;
var keys = Object.keys(params);
if (keys.length === 0) {
return '';
} //always have parameters in the same order
keys.sort();
if (!hasParams) {
combined += '?' + keys[0] + '=' + params[keys[0]];
i += 1;
}
keys.sort();
for (; i < keys.length; i += 1) {
combined += '&' + keys[i] + '=' + params[keys[i]];
}
if (!hasParams) {
combined += '?' + keys[0] + '=' + params[keys[0]];
i += 1;
}
return combined;
}; //parses strings like 1h30m20s to seconds
for (; i < keys.length; i += 1) {
combined += '&' + keys[i] + '=' + params[keys[i]];
}
return combined;
}; //parses strings like 1h30m20s to seconds
function getLetterTime(timeString) {
var totalSeconds = 0;
var timeValues = {
's': 1,
'm': 1 * 60,
'h': 1 * 60 * 60,
'd': 1 * 60 * 60 * 24,
'w': 1 * 60 * 60 * 24 * 7
};
var timePairs; //expand to "1 h 30 m 20 s" and split
timeString = timeString.replace(/([smhdw])/g, ' $1 ').trim();
timePairs = timeString.split(' ');
function getLetterTime(timeString) {
var totalSeconds = 0;
var timeValues = {
's': 1,
'm': 1 * 60,
'h': 1 * 60 * 60,
'd': 1 * 60 * 60 * 24,
'w': 1 * 60 * 60 * 24 * 7
};
var timePairs; //expand to "1 h 30 m 20 s" and split
for (var i = 0; i < timePairs.length; i += 2) {
totalSeconds += parseInt(timePairs[i], 10) * timeValues[timePairs[i + 1] || 's'];
}
timeString = timeString.replace(/([smhdw])/g, ' $1 ').trim();
timePairs = timeString.split(' ');
return totalSeconds;
} //parses strings like 1:30:20 to seconds
for (var i = 0; i < timePairs.length; i += 2) {
totalSeconds += parseInt(timePairs[i], 10) * timeValues[timePairs[i + 1] || 's'];
}
return totalSeconds;
} //parses strings like 1:30:20 to seconds
function getColonTime(timeString) {
var totalSeconds = 0;
var timeValues = [1, 1 * 60, 1 * 60 * 60, 1 * 60 * 60 * 24, 1 * 60 * 60 * 24 * 7];
var timePairs = timeString.split(':');
for (var i = 0; i < timePairs.length; i++) {
totalSeconds += parseInt(timePairs[i], 10) * timeValues[timePairs.length - i - 1];
}
function getColonTime(timeString) {
var totalSeconds = 0;
var timeValues = [1, 1 * 60, 1 * 60 * 60, 1 * 60 * 60 * 24, 1 * 60 * 60 * 24 * 7];
var timePairs = timeString.split(':');
return totalSeconds;
}
for (var i = 0; i < timePairs.length; i++) {
totalSeconds += parseInt(timePairs[i], 10) * timeValues[timePairs.length - i - 1];
}
var getTime = function getTime(timeString) {
if (typeof timeString === 'undefined') {
return 0;
return totalSeconds;
}
if (timeString.match(/^(\d+[smhdw]?)+$/)) {
return getLetterTime(timeString);
}
var getTime = function getTime(timeString) {
if (typeof timeString === 'undefined') {
return 0;
}
if (timeString.match(/^(\d+:?)+$/)) {
return getColonTime(timeString);
}
if (timeString.match(/^(\d+[smhdw]?)+$/)) {
return getLetterTime(timeString);
}
return 0;
};
if (timeString.match(/^(\d+:?)+$/)) {
return getColonTime(timeString);
}
var util = {
getQueryParams: getQueryParams,
combineParams: combineParams,
getTime: getTime
};
return 0;
};
var getQueryParams$1 = util.getQueryParams;
var util = {
getQueryParams: getQueryParams,
combineParams: combineParams,
getTime: getTime
};
function UrlParser() {
var _arr = ['parseProvider', 'parse', 'bind', 'create'];
var getQueryParams$1 = util.getQueryParams;
for (var _i = 0; _i < _arr.length; _i++) {
var key = _arr[_i];
this[key] = this[key].bind(this);
function UrlParser() {
for (var _i = 0, _arr = ['parseProvider', 'parse', 'bind', 'create']; _i < _arr.length; _i++) {
var key = _arr[_i];
this[key] = this[key].bind(this);
}
this.plugins = {};
}
this.plugins = {};
}
var urlParser = UrlParser;
var urlParser = UrlParser;
UrlParser.prototype.parseProvider = function (url) {
var match = url.match(/(?:(?:https?:)?\/\/)?(?:[^.]+\.)?(\w+)\./i);
return match ? match[1] : undefined;
};
UrlParser.prototype.parseProvider = function (url) {
var match = url.match(/(?:(?:https?:)?\/\/)?(?:[^.]+\.)?(\w+)\./i);
return match ? match[1] : undefined;
};
UrlParser.prototype.parse = function (url) {
if (typeof url === 'undefined') {
return undefined;
}
UrlParser.prototype.parse = function (url) {
if (typeof url === 'undefined') {
return undefined;
}
var provider = this.parseProvider(url);
var result;
var plugin = this.plugins[provider];
var provider = this.parseProvider(url);
var result;
var plugin = this.plugins[provider];
if (!provider || !plugin || !plugin.parse) {
return undefined;
}
if (!provider || !plugin || !plugin.parse) {
return undefined;
}
result = plugin.parse.call(plugin, url, getQueryParams$1(url));
result = plugin.parse.call(plugin, url, getQueryParams$1(url));
if (result) {
result = removeEmptyParameters(result);
result.provider = plugin.provider;
}
if (result) {
result = removeEmptyParameters(result);
result.provider = plugin.provider;
}
return result;
};
return result;
};
UrlParser.prototype.bind = function (plugin) {
this.plugins[plugin.provider] = plugin;
UrlParser.prototype.bind = function (plugin) {
this.plugins[plugin.provider] = plugin;
if (plugin.alternatives) {
for (var i = 0; i < plugin.alternatives.length; i += 1) {
this.plugins[plugin.alternatives[i]] = plugin;
}
}
};
if (plugin.alternatives) {
for (var i = 0; i < plugin.alternatives.length; i += 1) {
this.plugins[plugin.alternatives[i]] = plugin;
UrlParser.prototype.create = function (op) {
if (_typeof(op) !== 'object' || _typeof(op.videoInfo) !== 'object') {
return undefined;
}
}
};
UrlParser.prototype.create = function (op) {
if (_typeof(op) !== 'object' || _typeof(op.videoInfo) !== 'object') {
return undefined;
}
var vi = op.videoInfo;
var params = op.params;
var plugin = this.plugins[vi.provider];
params = params === 'internal' ? vi.params : params || {};
var vi = op.videoInfo;
var params = op.params;
var plugin = this.plugins[vi.provider];
params = params === 'internal' ? vi.params : params || {};
if (plugin) {
op.format = op.format || plugin.defaultFormat; // eslint-disable-next-line no-prototype-builtins
if (plugin) {
op.format = op.format || plugin.defaultFormat;
if (plugin.formats.hasOwnProperty(op.format)) {
return plugin.formats[op.format].apply(plugin, [vi, Object.assign({}, params)]);
}
}
if (plugin.formats.hasOwnProperty(op.format)) {
return plugin.formats[op.format].apply(plugin, [vi, Object.assign({}, params)]);
return undefined;
};
function removeEmptyParameters(result) {
if (result.params && Object.keys(result.params).length === 0) {
delete result.params;
}
return result;
}
return undefined;
};
var parser = new urlParser();
var base = parser;
function removeEmptyParameters(result) {
if (result.params && Object.keys(result.params).length === 0) {
delete result.params;
var combineParams$1 = util.combineParams;
function CanalPlus() {
this.provider = 'canalplus';
this.defaultFormat = 'embed';
this.formats = {
embed: this.createEmbedUrl
};
this.mediaTypes = {
VIDEO: 'video'
};
}
return result;
}
CanalPlus.prototype.parseParameters = function (params) {
delete params.vid;
return params;
};
var parser = new urlParser();
var base = parser;
CanalPlus.prototype.parse = function (url, params) {
var _this = this;
var combineParams$1 = util.combineParams;
var result = {
mediaType: this.mediaTypes.VIDEO,
id: params.vid
};
result.params = _this.parseParameters(params);
function CanalPlus() {
this.provider = 'canalplus';
this.defaultFormat = 'embed';
this.formats = {
embed: this.createEmbedUrl
if (!result.id) {
return undefined;
}
return result;
};
this.mediaTypes = {
VIDEO: 'video'
};
}
CanalPlus.prototype.parseParameters = function (params) {
delete params.vid;
return params;
};
CanalPlus.prototype.createEmbedUrl = function (vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
CanalPlus.prototype.parse = function (url, params) {
var _this = this;
var result = {
mediaType: this.mediaTypes.VIDEO,
id: params.vid
var url = 'http://player.canalplus.fr/embed/';
params.vid = vi.id;
url += combineParams$1(params);
return url;
};
result.params = _this.parseParameters(params);
if (!result.id) {
return undefined;
}
base.bind(new CanalPlus());
return result;
};
var combineParams$2 = util.combineParams;
CanalPlus.prototype.createEmbedUrl = function (vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
function Coub() {
this.provider = 'coub';
this.defaultFormat = 'long';
this.formats = {
"long": this.createLongUrl,
embed: this.createEmbedUrl
};
this.mediaTypes = {
VIDEO: 'video'
};
}
var url = 'http://player.canalplus.fr/embed/';
params.vid = vi.id;
url += combineParams$1(params);
return url;
};
Coub.prototype.parseUrl = function (url) {
var match = url.match(/(?:embed|view)\/([a-zA-Z\d]+)/i);
return match ? match[1] : undefined;
};
base.bind(new CanalPlus());
Coub.prototype.parse = function (url, params) {
var result = {
mediaType: this.mediaTypes.VIDEO,
params: params,
id: this.parseUrl(url)
};
var combineParams$2 = util.combineParams;
if (!result.id) {
return undefined;
}
function Coub() {
this.provider = 'coub';
this.defaultFormat = 'long';
this.formats = {
long: this.createLongUrl,
embed: this.createEmbedUrl
return result;
};
this.mediaTypes = {
VIDEO: 'video'
Coub.prototype.createUrl = function (baseUrl, vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
var url = baseUrl + vi.id;
url += combineParams$2(params);
return url;
};
}
Coub.prototype.parseUrl = function (url) {
var match = url.match(/(?:embed|view)\/([a-zA-Z\d]+)/i);
return match ? match[1] : undefined;
};
Coub.prototype.createLongUrl = function (vi, params) {
return this.createUrl('https://coub.com/view/', vi, params);
};
Coub.prototype.parse = function (url, params) {
var result = {
mediaType: this.mediaTypes.VIDEO,
params: params,
id: this.parseUrl(url)
Coub.prototype.createEmbedUrl = function (vi, params) {
return this.createUrl('//coub.com/embed/', vi, params);
};
if (!result.id) {
return undefined;
}
base.bind(new Coub());
return result;
};
var combineParams$3 = util.combineParams,
getTime$1 = util.getTime;
Coub.prototype.createUrl = function (baseUrl, vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
function Dailymotion() {
this.provider = 'dailymotion';
this.alternatives = ['dai'];
this.defaultFormat = 'long';
this.formats = {
"short": this.createShortUrl,
"long": this.createLongUrl,
embed: this.createEmbedUrl,
image: this.createImageUrl
};
this.mediaTypes = {
VIDEO: 'video'
};
}
var url = baseUrl + vi.id;
url += combineParams$2(params);
return url;
};
Dailymotion.prototype.parseParameters = function (params) {
return this.parseTime(params);
};
Coub.prototype.createLongUrl = function (vi, params) {
return this.createUrl('https://coub.com/view/', vi, params);
};
Dailymotion.prototype.parseTime = function (params) {
if (params.start) {
params.start = getTime$1(params.start);
}
Coub.prototype.createEmbedUrl = function (vi, params) {
return this.createUrl('//coub.com/embed/', vi, params);
};
return params;
};
base.bind(new Coub());
Dailymotion.prototype.parseUrl = function (url) {
var match = url.match(/(?:\/video|ly)\/([A-Za-z0-9]+)/i);
return match ? match[1] : undefined;
};
var combineParams$3 = util.combineParams;
var getTime$1 = util.getTime;
Dailymotion.prototype.parse = function (url, params) {
var _this = this;
function Dailymotion() {
this.provider = 'dailymotion';
this.alternatives = ['dai'];
this.defaultFormat = 'long';
this.formats = {
short: this.createShortUrl,
long: this.createLongUrl,
embed: this.createEmbedUrl,
image: this.createImageUrl
var result = {
mediaType: this.mediaTypes.VIDEO,
params: _this.parseParameters(params),
id: _this.parseUrl(url)
};
return result.id ? result : undefined;
};
this.mediaTypes = {
VIDEO: 'video'
};
}
Dailymotion.prototype.parseParameters = function (params) {
return this.parseTime(params);
};
Dailymotion.prototype.createUrl = function (base, vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
Dailymotion.prototype.parseTime = function (params) {
if (params.start) {
params.start = getTime$1(params.start);
}
return base + vi.id + combineParams$3(params);
};
return params;
};
Dailymotion.prototype.createShortUrl = function (vi, params) {
return this.createUrl('https://dai.ly/', vi, params);
};
Dailymotion.prototype.parseUrl = function (url) {
var match = url.match(/(?:\/video|ly)\/([A-Za-z0-9]+)/i);
return match ? match[1] : undefined;
};
Dailymotion.prototype.createLongUrl = function (vi, params) {
return this.createUrl('https://dailymotion.com/video/', vi, params);
};
Dailymotion.prototype.parse = function (url, params) {
var _this = this;
Dailymotion.prototype.createEmbedUrl = function (vi, params) {
return this.createUrl('https://www.dailymotion.com/embed/video/', vi, params);
};
var result = {
mediaType: this.mediaTypes.VIDEO,
params: _this.parseParameters(params),
id: _this.parseUrl(url)
Dailymotion.prototype.createImageUrl = function (vi, params) {
delete params.start;
return this.createUrl('https://www.dailymotion.com/thumbnail/video/', vi, params);
};
return result.id ? result : undefined;
};
Dailymotion.prototype.createUrl = function (base$$2, vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
base.bind(new Dailymotion());
return base$$2 + vi.id + combineParams$3(params);
};
var combineParams$4 = util.combineParams,
getTime$2 = util.getTime;
Dailymotion.prototype.createShortUrl = function (vi, params) {
return this.createUrl('https://dai.ly/', vi, params);
};
function Twitch() {
this.provider = 'twitch';
this.defaultFormat = 'long';
this.formats = {
"long": this.createLongUrl,
embed: this.createEmbedUrl
};
this.mediaTypes = {
VIDEO: 'video',
STREAM: 'stream',
CLIP: 'clip'
};
}
Dailymotion.prototype.createLongUrl = function (vi, params) {
return this.createUrl('https://dailymotion.com/video/', vi, params);
};
Dailymotion.prototype.createEmbedUrl = function (vi, params) {
return this.createUrl('https://www.dailymotion.com/embed/video/', vi, params);
};
Dailymotion.prototype.createImageUrl = function (vi, params) {
delete params.start;
return this.createUrl('https://www.dailymotion.com/thumbnail/video/', vi, params);
};
base.bind(new Dailymotion());
var combineParams$4 = util.combineParams;
var getTime$2 = util.getTime;
function Twitch() {
this.provider = 'twitch';
this.defaultFormat = 'long';
this.formats = {
long: this.createLongUrl,
embed: this.createEmbedUrl
Twitch.prototype.seperateId = function (id) {
return {
pre: id[0],
id: id.substr(1)
};
};
this.mediaTypes = {
VIDEO: 'video',
STREAM: 'stream',
CLIP: 'clip'
};
}
Twitch.prototype.seperateId = function (id) {
return {
pre: id[0],
id: id.substr(1)
Twitch.prototype.parseChannel = function (result, params) {
var channel = params.channel || params.utm_content || result.channel;
delete params.utm_content;
delete params.channel;
return channel;
};
};
Twitch.prototype.parseChannel = function (result, params) {
var channel = params.channel || params.utm_content || result.channel;
delete params.utm_content;
delete params.channel;
return channel;
};
Twitch.prototype.parseUrl = function (url, result, params) {
var match;
match = url.match(/(clips\.)?twitch\.tv\/(?:(?:videos\/(\d+))|(\w+)(?:\/clip\/(\w+))?)/i);
Twitch.prototype.parseUrl = function (url, result, params) {
var match;
match = url.match(/(clips\.)?twitch\.tv\/(?:(?:videos\/(\d+))|(\w+)(?:\/clip\/(\w+))?)/i);
if (match && match[2]) {
//video
result.id = 'v' + match[2];
} else if (params.video) {
//video embed
result.id = params.video;
delete params.video;
} else if (params.clip) {
//clips embed
result.id = params.clip;
result.isClip = true;
delete params.clip;
} else if (match && match[1] && match[3]) {
//clips.twitch.tv/id
result.id = match[3];
result.isClip = true;
} else if (match && match[3] && match[4]) {
//twitch.tv/channel/clip/id
result.channel = match[3];
result.id = match[4];
result.isClip = true;
} else if (match && match[3]) {
result.channel = match[3];
}
if (match && match[2]) {
//video
result.id = 'v' + match[2];
} else if (params.video) {
//video embed
result.id = params.video;
delete params.video;
} else if (params.clip) {
//clips embed
result.id = params.clip;
result.isClip = true;
delete params.clip;
} else if (match && match[1] && match[3]) {
//clips.twitch.tv/id
result.id = match[3];
result.isClip = true;
} else if (match && match[3] && match[4]) {
//twitch.tv/channel/clip/id
result.channel = match[3];
result.id = match[4];
result.isClip = true;
} else if (match && match[3]) {
result.channel = match[3];
}
return result;
};
return result;
};
Twitch.prototype.parseMediaType = function (result) {
var mediaType;
Twitch.prototype.parseMediaType = function (result) {
var mediaType;
if (result.id) {
if (result.isClip) {
mediaType = this.mediaTypes.CLIP;
delete result.isClip;
} else {
mediaType = this.mediaTypes.VIDEO;
if (result.id) {
if (result.isClip) {
mediaType = this.mediaTypes.CLIP;
delete result.isClip;
} else {
mediaType = this.mediaTypes.VIDEO;
}
} else if (result.channel) {
mediaType = this.mediaTypes.STREAM;
}
} else if (result.channel) {
mediaType = this.mediaTypes.STREAM;
}
return mediaType;
};
return mediaType;
};
Twitch.prototype.parseParameters = function (params) {
if (params.t) {
params.start = getTime$2(params.t);
delete params.t;
}
Twitch.prototype.parseParameters = function (params) {
if (params.t) {
params.start = getTime$2(params.t);
delete params.t;
}
return params;
};
return params;
};
Twitch.prototype.parse = function (url, params) {
var _this = this;
Twitch.prototype.parse = function (url, params) {
var _this = this;
var result = {};
result = _this.parseUrl(url, result, params);
result.channel = _this.parseChannel(result, params);
result.mediaType = _this.parseMediaType(result);
result.params = _this.parseParameters(params);
return result.channel || result.id ? result : undefined;
};
var result = {};
result = _this.parseUrl(url, result, params);
result.channel = _this.parseChannel(result, params);
result.mediaType = _this.parseMediaType(result);
result.params = _this.parseParameters(params);
return result.channel || result.id ? result : undefined;
};
Twitch.prototype.createLongUrl = function (vi, params) {
var url = '';
Twitch.prototype.createLongUrl = function (vi, params) {
var url = '';
if (vi.mediaType === this.mediaTypes.STREAM && vi.channel) {
url = 'https://twitch.tv/' + vi.channel;
} else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
var sep = this.seperateId(vi.id);
url = 'https://twitch.tv/videos/' + sep.id;
if (vi.mediaType === this.mediaTypes.STREAM && vi.channel) {
url = 'https://twitch.tv/' + vi.channel;
} else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
var sep = this.seperateId(vi.id);
url = 'https://twitch.tv/videos/' + sep.id;
if (params.start) {
params.t = params.start + 's';
delete params.start;
}
} else if (vi.mediaType === this.mediaTypes.CLIP && vi.id) {
if (vi.channel) {
url = 'https://www.twitch.tv/' + vi.channel + '/clip/' + vi.id;
if (params.start) {
params.t = params.start + 's';
delete params.start;
}
} else if (vi.mediaType === this.mediaTypes.CLIP && vi.id) {
if (vi.channel) {
url = 'https://www.twitch.tv/' + vi.channel + '/clip/' + vi.id;
} else {
url = 'https://clips.twitch.tv/' + vi.id;
}
} else {
url = 'https://clips.twitch.tv/' + vi.id;
return undefined;
}
} else {
return undefined;
}
url += combineParams$4(params);
return url;
};
url += combineParams$4(params);
return url;
};
Twitch.prototype.createEmbedUrl = function (vi, params) {
var url = 'https://player.twitch.tv/';
Twitch.prototype.createEmbedUrl = function (vi, params) {
var url = 'https://player.twitch.tv/';
if (vi.mediaType === this.mediaTypes.STREAM && vi.channel) {
params.channel = vi.channel;
} else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
params.video = vi.id;
if (vi.mediaType === this.mediaTypes.STREAM && vi.channel) {
params.channel = vi.channel;
} else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
params.video = vi.id;
if (params.start) {
params.t = params.start + 's';
delete params.start;
if (params.start) {
params.t = params.start + 's';
delete params.start;
}
} else if (vi.mediaType === this.mediaTypes.CLIP && vi.id) {
url = 'https://clips.twitch.tv/embed';
params.clip = vi.id;
} else {
return undefined;
}
} else if (vi.mediaType === this.mediaTypes.CLIP && vi.id) {
url = 'https://clips.twitch.tv/embed';
params.clip = vi.id;
} else {
return undefined;
}
url += combineParams$4(params);
return url;
};
url += combineParams$4(params);
return url;
};
base.bind(new Twitch());
base.bind(new Twitch());
var combineParams$5 = util.combineParams;
var getTime$3 = util.getTime;
var combineParams$5 = util.combineParams,
getTime$3 = util.getTime;
function Vimeo() {
this.provider = 'vimeo';
this.alternatives = ['vimeopro', 'vimeocdn'];
this.defaultFormat = 'long';
this.formats = {
long: this.createLongUrl,
embed: this.createEmbedUrl,
image: this.createImageUrl
};
this.mediaTypes = {
VIDEO: 'video'
};
}
Vimeo.prototype.parseUrl = function (url, result) {
var match = url.match(/(vimeo(?:cdn|pro)?)\.com\/(?:(?:channels\/[\w]+|(?:(?:album\/\d+|groups\/[\w]+|staff\/frame)\/)?videos?)\/)?(\d+)(?:_(\d+)(?:x(\d+))?)?(\.\w+)?/i);
if (!match) {
return result;
function Vimeo() {
this.provider = 'vimeo';
this.alternatives = ['vimeopro', 'vimeocdn'];
this.defaultFormat = 'long';
this.formats = {
"long": this.createLongUrl,
embed: this.createEmbedUrl,
image: this.createImageUrl
};
this.mediaTypes = {
VIDEO: 'video'
};
}
result.id = match[2];
Vimeo.prototype.parseUrl = function (url, result) {
var match = url.match(/(vimeo(?:cdn|pro)?)\.com\/(?:(?:channels\/[\w]+|(?:(?:album\/\d+|groups\/[\w]+|staff\/frame)\/)?videos?)\/)?(\d+)(?:_(\d+)(?:x(\d+))?)?(\.\w+)?/i);
if (match[1] === 'vimeocdn') {
if (match[3]) {
result.imageWidth = parseInt(match[3]);
if (match[4]) {
//height can only be set when width is also set
result.imageHeight = parseInt(match[4]);
}
if (!match) {
return result;
}
result.imageExtension = match[5];
}
result.id = match[2];
return result;
};
if (match[1] === 'vimeocdn') {
if (match[3]) {
result.imageWidth = parseInt(match[3]);
Vimeo.prototype.parseParameters = function (params) {
return this.parseTime(params);
};
if (match[4]) {
//height can only be set when width is also set
result.imageHeight = parseInt(match[4]);
}
}
Vimeo.prototype.parseTime = function (params) {
if (params.t) {
params.start = getTime$3(params.t);
delete params.t;
}
result.imageExtension = match[5];
}
return params;
};
return result;
};
Vimeo.prototype.parse = function (url, params) {
var result = {
mediaType: this.mediaTypes.VIDEO,
params: this.parseParameters(params)
Vimeo.prototype.parseParameters = function (params) {
return this.parseTime(params);
};
result = this.parseUrl(url, result);
return result.id ? result : undefined;
};
Vimeo.prototype.createUrl = function (baseUrl, vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
Vimeo.prototype.parseTime = function (params) {
if (params.t) {
params.start = getTime$3(params.t);
delete params.t;
}
var url = baseUrl + vi.id;
var startTime = params.start;
delete params.start;
url += combineParams$5(params);
return params;
};
if (startTime) {
url += '#t=' + startTime;
}
Vimeo.prototype.parse = function (url, params) {
var result = {
mediaType: this.mediaTypes.VIDEO,
params: this.parseParameters(params)
};
result = this.parseUrl(url, result);
return result.id ? result : undefined;
};
return url;
};
Vimeo.prototype.createUrl = function (baseUrl, vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
Vimeo.prototype.createLongUrl = function (vi, params) {
return this.createUrl('https://vimeo.com/', vi, params);
};
var url = baseUrl + vi.id;
var startTime = params.start;
delete params.start;
url += combineParams$5(params);
Vimeo.prototype.createEmbedUrl = function (vi, params) {
return this.createUrl('//player.vimeo.com/video/', vi, params);
};
if (startTime) {
url += '#t=' + startTime;
}
Vimeo.prototype.createImageUrl = function (vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
return url;
};
var url = 'https://i.vimeocdn.com/video/' + vi.id;
Vimeo.prototype.createLongUrl = function (vi, params) {
return this.createUrl('https://vimeo.com/', vi, params);
};
if (vi.imageWidth && vi.imageHeight) {
url += '_' + vi.imageWidth + 'x' + vi.imageHeight;
} else if (vi.imageWidth) {
url += '_' + vi.imageWidth;
}
Vimeo.prototype.createEmbedUrl = function (vi, params) {
return this.createUrl('//player.vimeo.com/video/', vi, params);
};
if (vi.imageExtension === undefined) {
vi.imageExtension = '.webp';
}
Vimeo.prototype.createImageUrl = function (vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
url += vi.imageExtension;
delete vi.imageExtension;
url += combineParams$5(params);
return url;
};
var url = 'https://i.vimeocdn.com/video/' + vi.id;
base.bind(new Vimeo());
if (vi.imageWidth && vi.imageHeight) {
url += '_' + vi.imageWidth + 'x' + vi.imageHeight;
} else if (vi.imageWidth) {
url += '_' + vi.imageWidth;
}
var combineParams$6 = util.combineParams;
var getTime$4 = util.getTime;
if (vi.imageExtension === undefined) {
vi.imageExtension = '.webp';
}
function Wistia() {
this.provider = 'wistia';
this.alternatives = [];
this.defaultFormat = 'long';
this.formats = {
long: this.createLongUrl,
embed: this.createEmbedUrl,
embedjsonp: this.createEmbedJsonpUrl
url += vi.imageExtension;
delete vi.imageExtension;
url += combineParams$5(params);
return url;
};
this.mediaTypes = {
VIDEO: 'video',
EMBEDVIDEO: 'embedvideo'
};
}
Wistia.prototype.parseUrl = function (url) {
var match = url.match(/(?:(?:medias|iframe)\/|wvideo=)([\w-]+)/);
return match ? match[1] : undefined;
};
base.bind(new Vimeo());
Wistia.prototype.parseChannel = function (url) {
var match = url.match(/(?:(?:https?:)?\/\/)?([^.]*)\.wistia\./);
var channel = match ? match[1] : undefined;
var combineParams$6 = util.combineParams,
getTime$4 = util.getTime;
if (channel === 'fast' || channel === 'content') {
return undefined;
function Wistia() {
this.provider = 'wistia';
this.alternatives = [];
this.defaultFormat = 'long';
this.formats = {
"long": this.createLongUrl,
embed: this.createEmbedUrl,
embedjsonp: this.createEmbedJsonpUrl
};
this.mediaTypes = {
VIDEO: 'video',
EMBEDVIDEO: 'embedvideo'
};
}
return channel;
};
Wistia.prototype.parseUrl = function (url) {
var match = url.match(/(?:(?:medias|iframe)\/|wvideo=)([\w-]+)/);
return match ? match[1] : undefined;
};
Wistia.prototype.parseParameters = function (params, result) {
if (params.wtime) {
params.start = getTime$4(params.wtime);
delete params.wtime;
}
Wistia.prototype.parseChannel = function (url) {
var match = url.match(/(?:(?:https?:)?\/\/)?([^.]*)\.wistia\./);
var channel = match ? match[1] : undefined;
if (params.wvideo === result.id) {
delete params.wvideo;
}
if (channel === 'fast' || channel === 'content') {
return undefined;
}
return params;
};
Wistia.prototype.parseMediaType = function (result) {
if (result.id && result.channel) {
return this.mediaTypes.VIDEO;
} else if (result.id) {
delete result.channel;
return this.mediaTypes.EMBEDVIDEO;
} else {
return undefined;
}
};
Wistia.prototype.parse = function (url, params) {
var result = {
id: this.parseUrl(url),
channel: this.parseChannel(url)
return channel;
};
result.params = this.parseParameters(params, result);
result.mediaType = this.parseMediaType(result);
if (!result.id) {
return undefined;
}
Wistia.prototype.parseParameters = function (params, result) {
if (params.wtime) {
params.start = getTime$4(params.wtime);
delete params.wtime;
}
return result;
};
if (params.wvideo === result.id) {
delete params.wvideo;
}
Wistia.prototype.createUrl = function (vi, params, url) {
if (params.start) {
params.wtime = params.start;
delete params.start;
}
return params;
};
url += combineParams$6(params);
return url;
};
Wistia.prototype.parseMediaType = function (result) {
if (result.id && result.channel) {
return this.mediaTypes.VIDEO;
} else if (result.id) {
delete result.channel;
return this.mediaTypes.EMBEDVIDEO;
} else {
return undefined;
}
};
Wistia.prototype.createLongUrl = function (vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
Wistia.prototype.parse = function (url, params) {
var result = {
id: this.parseUrl(url),
channel: this.parseChannel(url)
};
result.params = this.parseParameters(params, result);
result.mediaType = this.parseMediaType(result);
var url = 'https://' + vi.channel + '.wistia.com/medias/' + vi.id;
return this.createUrl(vi, params, url);
};
if (!result.id) {
return undefined;
}
Wistia.prototype.createEmbedUrl = function (vi, params) {
if (!vi.id || !(vi.mediaType === this.mediaTypes.VIDEO || vi.mediaType === this.mediaTypes.EMBEDVIDEO)) {
return undefined;
}
return result;
};
var url = 'https://fast.wistia.com/embed/iframe/' + vi.id;
return this.createUrl(vi, params, url);
};
Wistia.prototype.createUrl = function (vi, params, url) {
if (params.start) {
params.wtime = params.start;
delete params.start;
}
Wistia.prototype.createEmbedJsonpUrl = function (vi) {
if (!vi.id || !(vi.mediaType === this.mediaTypes.VIDEO || vi.mediaType === this.mediaTypes.EMBEDVIDEO)) {
return undefined;
}
url += combineParams$6(params);
return url;
};
return 'https://fast.wistia.com/embed/medias/' + vi.id + '.jsonp';
};
Wistia.prototype.createLongUrl = function (vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
base.bind(new Wistia());
var url = 'https://' + vi.channel + '.wistia.com/medias/' + vi.id;
return this.createUrl(vi, params, url);
};
var combineParams$7 = util.combineParams;
Wistia.prototype.createEmbedUrl = function (vi, params) {
if (!vi.id || !(vi.mediaType === this.mediaTypes.VIDEO || vi.mediaType === this.mediaTypes.EMBEDVIDEO)) {
return undefined;
}
function Youku() {
this.provider = 'youku';
this.defaultFormat = 'long';
this.formats = {
embed: this.createEmbedUrl,
long: this.createLongUrl,
flash: this.createFlashUrl,
static: this.createStaticUrl
var url = 'https://fast.wistia.com/embed/iframe/' + vi.id;
return this.createUrl(vi, params, url);
};
this.mediaTypes = {
VIDEO: 'video'
};
}
Youku.prototype.parseUrl = function (url) {
var match = url.match(/(?:(?:embed|sid)\/|v_show\/id_|VideoIDS=)([a-zA-Z0-9]+)/);
return match ? match[1] : undefined;
};
Wistia.prototype.createEmbedJsonpUrl = function (vi) {
if (!vi.id || !(vi.mediaType === this.mediaTypes.VIDEO || vi.mediaType === this.mediaTypes.EMBEDVIDEO)) {
return undefined;
}
Youku.prototype.parseParameters = function (params) {
if (params.VideoIDS) {
delete params.VideoIDS;
}
return params;
};
Youku.prototype.parse = function (url, params) {
var _this = this;
var result = {
mediaType: this.mediaTypes.VIDEO,
id: _this.parseUrl(url),
params: _this.parseParameters(params)
return 'https://fast.wistia.com/embed/medias/' + vi.id + '.jsonp';
};
if (!result.id) {
return undefined;
}
base.bind(new Wistia());
return result;
};
var combineParams$7 = util.combineParams;
Youku.prototype.createUrl = function (baseUrl, vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
function Youku() {
this.provider = 'youku';
this.defaultFormat = 'long';
this.formats = {
embed: this.createEmbedUrl,
"long": this.createLongUrl,
flash: this.createFlashUrl,
"static": this.createStaticUrl
};
this.mediaTypes = {
VIDEO: 'video'
};
}
var url = baseUrl + vi.id;
url += combineParams$7(params);
return url;
};
Youku.prototype.parseUrl = function (url) {
var match = url.match(/(?:(?:embed|sid)\/|v_show\/id_|VideoIDS=)([a-zA-Z0-9]+)/);
return match ? match[1] : undefined;
};
Youku.prototype.createEmbedUrl = function (vi, params) {
return this.createUrl('http://player.youku.com/embed/', vi, params);
};
Youku.prototype.parseParameters = function (params) {
if (params.VideoIDS) {
delete params.VideoIDS;
}
Youku.prototype.createLongUrl = function (vi, params) {
return this.createUrl('http://v.youku.com/v_show/id_', vi, params);
};
return params;
};
Youku.prototype.createStaticUrl = function (vi, params) {
return this.createUrl('http://static.youku.com/v1.0.0638/v/swf/loader.swf?VideoIDS=', vi, params);
};
Youku.prototype.parse = function (url, params) {
var _this = this;
Youku.prototype.createFlashUrl = function (vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
var result = {
mediaType: this.mediaTypes.VIDEO,
id: _this.parseUrl(url),
params: _this.parseParameters(params)
};
var url = 'http://player.youku.com/player.php/sid/' + vi.id + '/v.swf';
url += combineParams$7(params);
return url;
};
if (!result.id) {
return undefined;
}
base.bind(new Youku());
return result;
};
var combineParams$8 = util.combineParams;
var getTime$5 = util.getTime;
Youku.prototype.createUrl = function (baseUrl, vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
function YouTube() {
this.provider = 'youtube';
this.alternatives = ['youtu', 'ytimg'];
this.defaultFormat = 'long';
this.formats = {
short: this.createShortUrl,
long: this.createLongUrl,
embed: this.createEmbedUrl,
shortImage: this.createShortImageUrl,
longImage: this.createLongImageUrl
var url = baseUrl + vi.id;
url += combineParams$7(params);
return url;
};
this.imageQualities = {
'0': '0',
'1': '1',
'2': '2',
'3': '3',
DEFAULT: 'default',
HQDEFAULT: 'hqdefault',
SDDEFAULT: 'sddefault',
MQDEFAULT: 'mqdefault',
MAXRESDEFAULT: 'maxresdefault'
Youku.prototype.createEmbedUrl = function (vi, params) {
return this.createUrl('http://player.youku.com/embed/', vi, params);
};
this.defaultImageQuality = this.imageQualities.HQDEFAULT;
this.mediaTypes = {
VIDEO: 'video',
PLAYLIST: 'playlist',
SHARE: 'share',
CHANNEL: 'channel'
Youku.prototype.createLongUrl = function (vi, params) {
return this.createUrl('http://v.youku.com/v_show/id_', vi, params);
};
}
YouTube.prototype.parseVideoUrl = function (url) {
var match = url.match(/(?:(?:v|vi|be|videos|embed)\/(?!videoseries)|(?:v|ci)=)([\w-]{11})/i);
return match ? match[1] : undefined;
};
Youku.prototype.createStaticUrl = function (vi, params) {
return this.createUrl('http://static.youku.com/v1.0.0638/v/swf/loader.swf?VideoIDS=', vi, params);
};
YouTube.prototype.parseChannelUrl = function (url) {
// Match an opaque channel ID
var match = url.match(/\/channel\/([\w-]+)/);
Youku.prototype.createFlashUrl = function (vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
if (match) {
return {
id: match[1],
mediaType: this.mediaTypes.CHANNEL
};
} // Match a vanity channel name or a user name. User urls are deprecated and
// currently redirect to the channel of that same name.
var url = 'http://player.youku.com/player.php/sid/' + vi.id + '/v.swf';
url += combineParams$7(params);
return url;
};
base.bind(new Youku());
match = url.match(/\/(?:c|user)\/([\w-]+)/);
var combineParams$8 = util.combineParams,
getTime$5 = util.getTime;
if (match) {
return {
name: match[1],
mediaType: this.mediaTypes.CHANNEL
function YouTube() {
this.provider = 'youtube';
this.alternatives = ['youtu', 'ytimg'];
this.defaultFormat = 'long';
this.formats = {
"short": this.createShortUrl,
"long": this.createLongUrl,
embed: this.createEmbedUrl,
shortImage: this.createShortImageUrl,
longImage: this.createLongImageUrl
};
this.imageQualities = {
'0': '0',
'1': '1',
'2': '2',
'3': '3',
DEFAULT: 'default',
HQDEFAULT: 'hqdefault',
SDDEFAULT: 'sddefault',
MQDEFAULT: 'mqdefault',
MAXRESDEFAULT: 'maxresdefault'
};
this.defaultImageQuality = this.imageQualities.HQDEFAULT;
this.mediaTypes = {
VIDEO: 'video',
PLAYLIST: 'playlist',
SHARE: 'share',
CHANNEL: 'channel'
};
}
};
YouTube.prototype.parseParameters = function (params, result) {
if (params.start || params.t) {
params.start = getTime$5(params.start || params.t);
delete params.t;
}
YouTube.prototype.parseVideoUrl = function (url) {
var match = url.match(/(?:(?:v|vi|be|videos|embed)\/(?!videoseries)|(?:v|ci)=)([\w-]{11})/i);
return match ? match[1] : undefined;
};
if (params.v === result.id) {
delete params.v;
}
YouTube.prototype.parseChannelUrl = function (url) {
// Match an opaque channel ID
var match = url.match(/\/channel\/([\w-]+)/);
if (params.list === result.id) {
delete params.list;
}
if (match) {
return {
id: match[1],
mediaType: this.mediaTypes.CHANNEL
};
} // Match a vanity channel name or a user name. User urls are deprecated and
// currently redirect to the channel of that same name.
return params;
};
YouTube.prototype.parseMediaType = function (result) {
if (result.params.list) {
result.list = result.params.list;
delete result.params.list;
}
match = url.match(/\/(?:c|user)\/([\w-]+)/);
if (result.id && !result.params.ci) {
result.mediaType = this.mediaTypes.VIDEO;
} else if (result.list) {
delete result.id;
result.mediaType = this.mediaTypes.PLAYLIST;
} else if (result.params.ci) {
delete result.params.ci;
result.mediaType = this.mediaTypes.SHARE;
} else {
return undefined;
}
if (match) {
return {
name: match[1],
mediaType: this.mediaTypes.CHANNEL
};
}
};
return result;
};
YouTube.prototype.parseParameters = function (params, result) {
if (params.start || params.t) {
params.start = getTime$5(params.start || params.t);
delete params.t;
}
YouTube.prototype.parse = function (url, params) {
var channelResult = this.parseChannelUrl(url);
if (params.v === result.id) {
delete params.v;
}
if (channelResult) {
return channelResult;
} else {
var result = {
params: params,
id: this.parseVideoUrl(url)
};
result.params = this.parseParameters(params, result);
result = this.parseMediaType(result);
return result;
}
};
if (params.list === result.id) {
delete params.list;
}
YouTube.prototype.createShortUrl = function (vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
return params;
};
var url = 'https://youtu.be/' + vi.id;
YouTube.prototype.parseMediaType = function (result) {
if (result.params.list) {
result.list = result.params.list;
delete result.params.list;
}
if (params.start) {
url += '#t=' + params.start;
}
if (result.id && !result.params.ci) {
result.mediaType = this.mediaTypes.VIDEO;
} else if (result.list) {
delete result.id;
result.mediaType = this.mediaTypes.PLAYLIST;
} else if (result.params.ci) {
delete result.params.ci;
result.mediaType = this.mediaTypes.SHARE;
} else {
return undefined;
}
return url;
};
return result;
};
YouTube.prototype.createLongUrl = function (vi, params) {
var url = '';
var startTime = params.start;
delete params.start;
YouTube.prototype.parse = function (url, params) {
var channelResult = this.parseChannelUrl(url);
if (vi.mediaType === this.mediaTypes.CHANNEL) {
if (vi.id) {
url += 'https://www.youtube.com/channel/' + vi.id;
} else if (vi.name) {
url += 'https://www.youtube.com/c/' + vi.name;
if (channelResult) {
return channelResult;
} else {
var result = {
params: params,
id: this.parseVideoUrl(url)
};
result.params = this.parseParameters(params, result);
result = this.parseMediaType(result);
return result;
}
};
YouTube.prototype.createShortUrl = function (vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
} else if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.list) {
params.feature = 'share';
url += 'https://www.youtube.com/playlist';
} else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
params.v = vi.id;
url += 'https://www.youtube.com/watch';
} else if (vi.mediaType === this.mediaTypes.SHARE && vi.id) {
params.ci = vi.id;
url += 'https://www.youtube.com/shared';
} else {
return undefined;
}
if (vi.list) {
params.list = vi.list;
}
var url = 'https://youtu.be/' + vi.id;
url += combineParams$8(params);
if (params.start) {
url += '#t=' + params.start;
}
if (vi.mediaType !== this.mediaTypes.PLAYLIST && startTime) {
url += '#t=' + startTime;
}
return url;
};
return url;
};
YouTube.prototype.createLongUrl = function (vi, params) {
var url = '';
var startTime = params.start;
delete params.start;
YouTube.prototype.createEmbedUrl = function (vi, params) {
var url = 'https://www.youtube.com/embed';
if (vi.mediaType === this.mediaTypes.CHANNEL) {
if (vi.id) {
url += 'https://www.youtube.com/channel/' + vi.id;
} else if (vi.name) {
url += 'https://www.youtube.com/c/' + vi.name;
} else {
return undefined;
}
} else if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.list) {
params.feature = 'share';
url += 'https://www.youtube.com/playlist';
} else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
params.v = vi.id;
url += 'https://www.youtube.com/watch';
} else if (vi.mediaType === this.mediaTypes.SHARE && vi.id) {
params.ci = vi.id;
url += 'https://www.youtube.com/shared';
} else {
return undefined;
}
if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.list) {
params.listType = 'playlist';
} else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
url += '/' + vi.id; //loop hack
if (vi.list) {
params.list = vi.list;
}
if (params.loop === '1') {
params.playlist = vi.id;
url += combineParams$8(params);
if (vi.mediaType !== this.mediaTypes.PLAYLIST && startTime) {
url += '#t=' + startTime;
}
} else {
return undefined;
}
if (vi.list) {
params.list = vi.list;
}
return url;
};
url += combineParams$8(params);
return url;
};
YouTube.prototype.createEmbedUrl = function (vi, params) {
var url = 'https://www.youtube.com/embed';
YouTube.prototype.createImageUrl = function (baseUrl, vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.list) {
params.listType = 'playlist';
} else if (vi.mediaType === this.mediaTypes.VIDEO && vi.id) {
url += '/' + vi.id; //loop hack
var url = baseUrl + vi.id + '/';
var quality = params.imageQuality || this.defaultImageQuality;
return url + quality + '.jpg';
};
if (params.loop === '1') {
params.playlist = vi.id;
}
} else {
return undefined;
}
YouTube.prototype.createShortImageUrl = function (vi, params) {
return this.createImageUrl('https://i.ytimg.com/vi/', vi, params);
};
if (vi.list) {
params.list = vi.list;
}
YouTube.prototype.createLongImageUrl = function (vi, params) {
return this.createImageUrl('https://img.youtube.com/vi/', vi, params);
};
url += combineParams$8(params);
return url;
};
base.bind(new YouTube());
YouTube.prototype.createImageUrl = function (baseUrl, vi, params) {
if (!vi.id || vi.mediaType !== this.mediaTypes.VIDEO) {
return undefined;
}
var combineParams$9 = util.combineParams;
var getTime$6 = util.getTime;
var url = baseUrl + vi.id + '/';
var quality = params.imageQuality || this.defaultImageQuality;
return url + quality + '.jpg';
};
function SoundCloud() {
this.provider = 'soundcloud';
this.defaultFormat = 'long';
this.formats = {
long: this.createLongUrl,
embed: this.createEmbedUrl
YouTube.prototype.createShortImageUrl = function (vi, params) {
return this.createImageUrl('https://i.ytimg.com/vi/', vi, params);
};
this.mediaTypes = {
TRACK: 'track',
PLAYLIST: 'playlist',
APITRACK: 'apitrack',
APIPLAYLIST: 'apiplaylist'
YouTube.prototype.createLongImageUrl = function (vi, params) {
return this.createImageUrl('https://img.youtube.com/vi/', vi, params);
};
}
SoundCloud.prototype.parseUrl = function (url, result) {
var match = url.match(/soundcloud\.com\/(?:([\w-]+)\/(sets\/)?)([\w-]+)/i);
base.bind(new YouTube());
if (!match) {
return result;
}
var combineParams$9 = util.combineParams,
getTime$6 = util.getTime;
result.channel = match[1];
if (match[1] === 'playlists' || match[2]) {
//playlist
result.list = match[3];
} else {
//track
result.id = match[3];
function SoundCloud() {
this.provider = 'soundcloud';
this.defaultFormat = 'long';
this.formats = {
"long": this.createLongUrl,
embed: this.createEmbedUrl
};
this.mediaTypes = {
TRACK: 'track',
PLAYLIST: 'playlist',
APITRACK: 'apitrack',
APIPLAYLIST: 'apiplaylist'
};
}
return result;
};
SoundCloud.prototype.parseUrl = function (url, result) {
var match = url.match(/(?:m\.)?soundcloud\.com\/(?:([\w-]+)\/(sets\/)?)([\w-]+)/i);
SoundCloud.prototype.parseParameters = function (params) {
if (params.t) {
params.start = getTime$6(params.t);
delete params.t;
}
if (!match) {
return result;
}
return params;
};
result.channel = match[1];
SoundCloud.prototype.parseMediaType = function (result) {
if (result.id) {
if (result.channel === 'tracks') {
delete result.channel;
delete result.params.url;
result.mediaType = this.mediaTypes.APITRACK;
if (match[1] === 'playlists' || match[2]) {
//playlist
result.list = match[3];
} else {
result.mediaType = this.mediaTypes.TRACK;
//track
result.id = match[3];
}
}
if (result.list) {
if (result.channel === 'playlists') {
delete result.channel;
delete result.params.url;
result.mediaType = this.mediaTypes.APIPLAYLIST;
} else {
result.mediaType = this.mediaTypes.PLAYLIST;
return result;
};
SoundCloud.prototype.parseParameters = function (params) {
if (params.t) {
params.start = getTime$6(params.t);
delete params.t;
}
}
return result;
};
return params;
};
SoundCloud.prototype.parse = function (url, params) {
var result = {};
result = this.parseUrl(url, result);
result.params = this.parseParameters(params);
result = this.parseMediaType(result);
SoundCloud.prototype.parseMediaType = function (result) {
if (result.id) {
if (result.channel === 'tracks') {
delete result.channel;
delete result.params.url;
result.mediaType = this.mediaTypes.APITRACK;
} else {
result.mediaType = this.mediaTypes.TRACK;
}
}
if (!result.id && !result.list) {
return undefined;
}
if (result.list) {
if (result.channel === 'playlists') {
delete result.channel;
delete result.params.url;
result.mediaType = this.mediaTypes.APIPLAYLIST;
} else {
result.mediaType = this.mediaTypes.PLAYLIST;
}
}
return result;
};
return result;
};
SoundCloud.prototype.createLongUrl = function (vi, params) {
var url = '';
var startTime = params.start;
delete params.start;
SoundCloud.prototype.parse = function (url, params) {
var result = {};
result = this.parseUrl(url, result);
result.params = this.parseParameters(params);
result = this.parseMediaType(result);
if (vi.mediaType === this.mediaTypes.TRACK && vi.id && vi.channel) {
url = 'https://soundcloud.com/' + vi.channel + '/' + vi.id;
} else if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.list && vi.channel) {
url = 'https://soundcloud.com/' + vi.channel + '/sets/' + vi.list;
} else if (vi.mediaType === this.mediaTypes.APITRACK && vi.id) {
url = 'https://api.soundcloud.com/tracks/' + vi.id;
} else if (vi.mediaType === this.mediaTypes.APIPLAYLIST && vi.list) {
url = 'https://api.soundcloud.com/playlists/' + vi.list;
} else {
return undefined;
}
if (!result.id && !result.list) {
return undefined;
}
url += combineParams$9(params);
return result;
};
if (startTime) {
url += '#t=' + startTime;
}
SoundCloud.prototype.createLongUrl = function (vi, params) {
var url = '';
var startTime = params.start;
delete params.start;
return url;
};
if (vi.mediaType === this.mediaTypes.TRACK && vi.id && vi.channel) {
url = 'https://soundcloud.com/' + vi.channel + '/' + vi.id;
} else if (vi.mediaType === this.mediaTypes.PLAYLIST && vi.list && vi.channel) {
url = 'https://soundcloud.com/' + vi.channel + '/sets/' + vi.list;
} else if (vi.mediaType === this.mediaTypes.APITRACK && vi.id) {
url = 'https://api.soundcloud.com/tracks/' + vi.id;
} else if (vi.mediaType === this.mediaTypes.APIPLAYLIST && vi.list) {
url = 'https://api.soundcloud.com/playlists/' + vi.list;
} else {
return undefined;
}
SoundCloud.prototype.createEmbedUrl = function (vi, params) {
var url = 'https://w.soundcloud.com/player/';
delete params.start;
url += combineParams$9(params);
if (vi.mediaType === this.mediaTypes.APITRACK && vi.id) {
params.url = 'https%3A//api.soundcloud.com/tracks/' + vi.id;
} else if (vi.mediaType === this.mediaTypes.APIPLAYLIST && vi.list) {
params.url = 'https%3A//api.soundcloud.com/playlists/' + vi.list;
} else {
return undefined;
}
if (startTime) {
url += '#t=' + startTime;
}
url += combineParams$9(params);
return url;
};
return url;
};
base.bind(new SoundCloud());
SoundCloud.prototype.createEmbedUrl = function (vi, params) {
var url = 'https://w.soundcloud.com/player/';
delete params.start;
var combineParams$10 = util.combineParams;
if (vi.mediaType === this.mediaTypes.APITRACK && vi.id) {
params.url = 'https%3A//api.soundcloud.com/tracks/' + vi.id;
} else if (vi.mediaType === this.mediaTypes.APIPLAYLIST && vi.list) {
params.url = 'https%3A//api.soundcloud.com/playlists/' + vi.list;
} else {
return undefined;
}
function TeacherTube() {
this.provider = 'teachertube';
this.alternatives = [];
this.defaultFormat = 'long';
this.formats = {
long: this.createLongUrl,
embed: this.createEmbedUrl
url += combineParams$9(params);
return url;
};
this.mediaTypes = {
VIDEO: 'video',
AUDIO: 'audio',
DOCUMENT: 'document',
CHANNEL: 'channel',
COLLECTION: 'collection',
GROUP: 'group'
};
}
TeacherTube.prototype.parse = function (url, params) {
var result = {};
result.list = this.parsePlaylist(params);
result.params = params;
var match = url.match(/\/(audio|video|document|user\/channel|collection|group)\/(?:[\w-]+-)?(\w+)/);
base.bind(new SoundCloud());
if (!match) {
return undefined;
var combineParams$a = util.combineParams;
function TeacherTube() {
this.provider = 'teachertube';
this.alternatives = [];
this.defaultFormat = 'long';
this.formats = {
"long": this.createLongUrl,
embed: this.createEmbedUrl
};
this.mediaTypes = {
VIDEO: 'video',
AUDIO: 'audio',
DOCUMENT: 'document',
CHANNEL: 'channel',
COLLECTION: 'collection',
GROUP: 'group'
};
}
result.mediaType = this.parseMediaType(match[1]);
result.id = match[2];
return result;
};
TeacherTube.prototype.parse = function (url, params) {
var result = {};
result.list = this.parsePlaylist(params);
result.params = params;
var match = url.match(/\/(audio|video|document|user\/channel|collection|group)\/(?:[\w-]+-)?(\w+)/);
TeacherTube.prototype.parsePlaylist = function (params) {
if (params['playlist-id']) {
var list = params['playlist-id'];
delete params['playlist-id'];
return list;
}
if (!match) {
return undefined;
}
return undefined;
};
result.mediaType = this.parseMediaType(match[1]);
result.id = match[2];
return result;
};
TeacherTube.prototype.parseMediaType = function (mediaTypeMatch) {
switch (mediaTypeMatch) {
case 'audio':
return this.mediaTypes.AUDIO;
TeacherTube.prototype.parsePlaylist = function (params) {
if (params['playlist-id']) {
var list = params['playlist-id'];
delete params['playlist-id'];
return list;
}
case 'video':
return this.mediaTypes.VIDEO;
return undefined;
};
case 'document':
return this.mediaTypes.DOCUMENT;
TeacherTube.prototype.parseMediaType = function (mediaTypeMatch) {
switch (mediaTypeMatch) {
case 'audio':
return this.mediaTypes.AUDIO;
case 'user/channel':
return this.mediaTypes.CHANNEL;
case 'video':
return this.mediaTypes.VIDEO;
case 'collection':
return this.mediaTypes.COLLECTION;
case 'document':
return this.mediaTypes.DOCUMENT;
case 'group':
return this.mediaTypes.GROUP;
}
};
case 'user/channel':
return this.mediaTypes.CHANNEL;
TeacherTube.prototype.createLongUrl = function (vi, params) {
if (!vi.id) {
return undefined;
}
case 'collection':
return this.mediaTypes.COLLECTION;
var url = 'https://www.teachertube.com/';
case 'group':
return this.mediaTypes.GROUP;
}
};
if (vi.list) {
params['playlist-id'] = vi.list;
}
TeacherTube.prototype.createLongUrl = function (vi, params) {
if (!vi.id) {
return undefined;
}
if (vi.mediaType === this.mediaTypes.CHANNEL) {
url += 'user/channel/';
} else {
url += vi.mediaType + '/';
}
var url = 'https://www.teachertube.com/';
url += vi.id;
url += combineParams$10(params);
return url;
};
if (vi.list) {
params['playlist-id'] = vi.list;
}
TeacherTube.prototype.createEmbedUrl = function (vi, params) {
if (!vi.id) {
return undefined;
}
if (vi.mediaType === this.mediaTypes.CHANNEL) {
url += 'user/channel/';
} else {
url += vi.mediaType + '/';
}
var url = 'https://www.teachertube.com/embed/';
url += vi.id;
url += combineParams$a(params);
return url;
};
if (vi.mediaType === this.mediaTypes.VIDEO || vi.mediaType === this.mediaTypes.AUDIO) {
url += vi.mediaType + '/' + vi.id;
} else {
return undefined;
}
TeacherTube.prototype.createEmbedUrl = function (vi, params) {
if (!vi.id) {
return undefined;
}
url += combineParams$10(params);
return url;
};
var url = 'https://www.teachertube.com/embed/';
base.bind(new TeacherTube());
if (vi.mediaType === this.mediaTypes.VIDEO || vi.mediaType === this.mediaTypes.AUDIO) {
url += vi.mediaType + '/' + vi.id;
} else {
return undefined;
}
var lib = base;
url += combineParams$a(params);
return url;
};
return lib;
base.bind(new TeacherTube());
var lib = base;
return lib;
})));

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.urlParser=t()}(this,function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}var t=function(t,i){if("object"!==e(t))return"";var r="",a=0,s=Object.keys(t);if(0===s.length)return"";for(s.sort(),i||(r+="?"+s[0]+"="+t[s[0]],a+=1);a<s.length;a+=1)r+="&"+s[a]+"="+t[s[a]];return r},i=function(e){return void 0===e?0:e.match(/^(\d+[smhdw]?)+$/)?function(e){var t,i=0,r={s:1,m:60,h:3600,d:86400,w:604800};t=(e=e.replace(/([smhdw])/g," $1 ").trim()).split(" ");for(var a=0;a<t.length;a+=2)i+=parseInt(t[a],10)*r[t[a+1]||"s"];return i}(e):e.match(/^(\d+:?)+$/)?function(e){for(var t=0,i=[1,60,3600,86400,604800],r=e.split(":"),a=0;a<r.length;a++)t+=parseInt(r[a],10)*i[r.length-a-1];return t}(e):0},r=function(e){if("string"!=typeof e)return{};var t,i={},r=(e=e.split("+").join(" ")).match(/(?:[?](?:[^=]+)=(?:[^&#]*)(?:[&](?:[^=]+)=(?:[^&#]*))*(?:[#].*)?)|(?:[#].*)/);if(null===r)return{};t=r[0].substr(1).split(/[&#=]/);for(var a=0;a<t.length;a+=2)i[decodeURIComponent(t[a])]=decodeURIComponent(t[a+1]||"");return i};function a(){for(var e=["parseProvider","parse","bind","create"],t=0;t<e.length;t++){var i=e[t];this[i]=this[i].bind(this)}this.plugins={}}var s=a;a.prototype.parseProvider=function(e){var t=e.match(/(?:(?:https?:)?\/\/)?(?:[^.]+\.)?(\w+)\./i);return t?t[1]:void 0},a.prototype.parse=function(e){if(void 0!==e){var t,i=this.parseProvider(e),a=this.plugins[i];if(i&&a&&a.parse)return(t=a.parse.call(a,e,r(e)))&&((t=function(e){e.params&&0===Object.keys(e.params).length&&delete e.params;return e}(t)).provider=a.provider),t}},a.prototype.bind=function(e){if(this.plugins[e.provider]=e,e.alternatives)for(var t=0;t<e.alternatives.length;t+=1)this.plugins[e.alternatives[t]]=e},a.prototype.create=function(t){if("object"===e(t)&&"object"===e(t.videoInfo)){var i=t.videoInfo,r=t.params,a=this.plugins[i.provider];return r="internal"===r?i.params:r||{},a&&(t.format=t.format||a.defaultFormat,a.formats.hasOwnProperty(t.format))?a.formats[t.format].apply(a,[i,Object.assign({},r)]):void 0}};var o=new s,n=t;function p(){this.provider="canalplus",this.defaultFormat="embed",this.formats={embed:this.createEmbedUrl},this.mediaTypes={VIDEO:"video"}}p.prototype.parseParameters=function(e){return delete e.vid,e},p.prototype.parse=function(e,t){var i={mediaType:this.mediaTypes.VIDEO,id:t.vid};if(i.params=this.parseParameters(t),i.id)return i},p.prototype.createEmbedUrl=function(e,t){if(e.id&&e.mediaType===this.mediaTypes.VIDEO){var i="http://player.canalplus.fr/embed/";return t.vid=e.id,i+=n(t)}},o.bind(new p);var d=t;function l(){this.provider="coub",this.defaultFormat="long",this.formats={long:this.createLongUrl,embed:this.createEmbedUrl},this.mediaTypes={VIDEO:"video"}}l.prototype.parseUrl=function(e){var t=e.match(/(?:embed|view)\/([a-zA-Z\d]+)/i);return t?t[1]:void 0},l.prototype.parse=function(e,t){var i={mediaType:this.mediaTypes.VIDEO,params:t,id:this.parseUrl(e)};if(i.id)return i},l.prototype.createUrl=function(e,t,i){if(t.id&&t.mediaType===this.mediaTypes.VIDEO){var r=e+t.id;return r+=d(i)}},l.prototype.createLongUrl=function(e,t){return this.createUrl("https://coub.com/view/",e,t)},l.prototype.createEmbedUrl=function(e,t){return this.createUrl("//coub.com/embed/",e,t)},o.bind(new l);var m=t,c=i;function h(){this.provider="dailymotion",this.alternatives=["dai"],this.defaultFormat="long",this.formats={short:this.createShortUrl,long:this.createLongUrl,embed:this.createEmbedUrl,image:this.createImageUrl},this.mediaTypes={VIDEO:"video"}}h.prototype.parseParameters=function(e){return this.parseTime(e)},h.prototype.parseTime=function(e){return e.start&&(e.start=c(e.start)),e},h.prototype.parseUrl=function(e){var t=e.match(/(?:\/video|ly)\/([A-Za-z0-9]+)/i);return t?t[1]:void 0},h.prototype.parse=function(e,t){var i={mediaType:this.mediaTypes.VIDEO,params:this.parseParameters(t),id:this.parseUrl(e)};return i.id?i:void 0},h.prototype.createUrl=function(e,t,i){if(t.id&&t.mediaType===this.mediaTypes.VIDEO)return e+t.id+m(i)},h.prototype.createShortUrl=function(e,t){return this.createUrl("https://dai.ly/",e,t)},h.prototype.createLongUrl=function(e,t){return this.createUrl("https://dailymotion.com/video/",e,t)},h.prototype.createEmbedUrl=function(e,t){return this.createUrl("https://www.dailymotion.com/embed/video/",e,t)},h.prototype.createImageUrl=function(e,t){return delete t.start,this.createUrl("https://www.dailymotion.com/thumbnail/video/",e,t)},o.bind(new h);var u=t,y=i;function f(){this.provider="twitch",this.defaultFormat="long",this.formats={long:this.createLongUrl,embed:this.createEmbedUrl},this.mediaTypes={VIDEO:"video",STREAM:"stream",CLIP:"clip"}}f.prototype.seperateId=function(e){return{pre:e[0],id:e.substr(1)}},f.prototype.parseChannel=function(e,t){var i=t.channel||t.utm_content||e.channel;return delete t.utm_content,delete t.channel,i},f.prototype.parseUrl=function(e,t,i){var r;return(r=e.match(/(clips\.)?twitch\.tv\/(?:(?:videos\/(\d+))|(\w+)(?:\/clip\/(\w+))?)/i))&&r[2]?t.id="v"+r[2]:i.video?(t.id=i.video,delete i.video):i.clip?(t.id=i.clip,t.isClip=!0,delete i.clip):r&&r[1]&&r[3]?(t.id=r[3],t.isClip=!0):r&&r[3]&&r[4]?(t.channel=r[3],t.id=r[4],t.isClip=!0):r&&r[3]&&(t.channel=r[3]),t},f.prototype.parseMediaType=function(e){var t;return e.id?e.isClip?(t=this.mediaTypes.CLIP,delete e.isClip):t=this.mediaTypes.VIDEO:e.channel&&(t=this.mediaTypes.STREAM),t},f.prototype.parseParameters=function(e){return e.t&&(e.start=y(e.t),delete e.t),e},f.prototype.parse=function(e,t){var i={};return(i=this.parseUrl(e,i,t)).channel=this.parseChannel(i,t),i.mediaType=this.parseMediaType(i),i.params=this.parseParameters(t),i.channel||i.id?i:void 0},f.prototype.createLongUrl=function(e,t){var i="";if(e.mediaType===this.mediaTypes.STREAM&&e.channel)i="https://twitch.tv/"+e.channel;else if(e.mediaType===this.mediaTypes.VIDEO&&e.id){i="https://twitch.tv/videos/"+this.seperateId(e.id).id,t.start&&(t.t=t.start+"s",delete t.start)}else{if(e.mediaType!==this.mediaTypes.CLIP||!e.id)return;i=e.channel?"https://www.twitch.tv/"+e.channel+"/clip/"+e.id:"https://clips.twitch.tv/"+e.id}return i+=u(t)},f.prototype.createEmbedUrl=function(e,t){var i="https://player.twitch.tv/";if(e.mediaType===this.mediaTypes.STREAM&&e.channel)t.channel=e.channel;else if(e.mediaType===this.mediaTypes.VIDEO&&e.id)t.video=e.id,t.start&&(t.t=t.start+"s",delete t.start);else{if(e.mediaType!==this.mediaTypes.CLIP||!e.id)return;i="https://clips.twitch.tv/embed",t.clip=e.id}return i+=u(t)},o.bind(new f);var v=t,T=i;function U(){this.provider="vimeo",this.alternatives=["vimeopro","vimeocdn"],this.defaultFormat="long",this.formats={long:this.createLongUrl,embed:this.createEmbedUrl,image:this.createImageUrl},this.mediaTypes={VIDEO:"video"}}U.prototype.parseUrl=function(e,t){var i=e.match(/(vimeo(?:cdn|pro)?)\.com\/(?:(?:channels\/[\w]+|(?:(?:album\/\d+|groups\/[\w]+|staff\/frame)\/)?videos?)\/)?(\d+)(?:_(\d+)(?:x(\d+))?)?(\.\w+)?/i);return i?(t.id=i[2],"vimeocdn"===i[1]&&(i[3]&&(t.imageWidth=parseInt(i[3]),i[4]&&(t.imageHeight=parseInt(i[4]))),t.imageExtension=i[5]),t):t},U.prototype.parseParameters=function(e){return this.parseTime(e)},U.prototype.parseTime=function(e){return e.t&&(e.start=T(e.t),delete e.t),e},U.prototype.parse=function(e,t){var i={mediaType:this.mediaTypes.VIDEO,params:this.parseParameters(t)};return(i=this.parseUrl(e,i)).id?i:void 0},U.prototype.createUrl=function(e,t,i){if(t.id&&t.mediaType===this.mediaTypes.VIDEO){var r=e+t.id,a=i.start;return delete i.start,r+=v(i),a&&(r+="#t="+a),r}},U.prototype.createLongUrl=function(e,t){return this.createUrl("https://vimeo.com/",e,t)},U.prototype.createEmbedUrl=function(e,t){return this.createUrl("//player.vimeo.com/video/",e,t)},U.prototype.createImageUrl=function(e,t){if(e.id&&e.mediaType===this.mediaTypes.VIDEO){var i="https://i.vimeocdn.com/video/"+e.id;return e.imageWidth&&e.imageHeight?i+="_"+e.imageWidth+"x"+e.imageHeight:e.imageWidth&&(i+="_"+e.imageWidth),void 0===e.imageExtension&&(e.imageExtension=".webp"),i+=e.imageExtension,delete e.imageExtension,i+=v(t)}},o.bind(new U);var g=t,E=i;function I(){this.provider="wistia",this.alternatives=[],this.defaultFormat="long",this.formats={long:this.createLongUrl,embed:this.createEmbedUrl,embedjsonp:this.createEmbedJsonpUrl},this.mediaTypes={VIDEO:"video",EMBEDVIDEO:"embedvideo"}}I.prototype.parseUrl=function(e){var t=e.match(/(?:(?:medias|iframe)\/|wvideo=)([\w-]+)/);return t?t[1]:void 0},I.prototype.parseChannel=function(e){var t=e.match(/(?:(?:https?:)?\/\/)?([^.]*)\.wistia\./),i=t?t[1]:void 0;if("fast"!==i&&"content"!==i)return i},I.prototype.parseParameters=function(e,t){return e.wtime&&(e.start=E(e.wtime),delete e.wtime),e.wvideo===t.id&&delete e.wvideo,e},I.prototype.parseMediaType=function(e){return e.id&&e.channel?this.mediaTypes.VIDEO:e.id?(delete e.channel,this.mediaTypes.EMBEDVIDEO):void 0},I.prototype.parse=function(e,t){var i={id:this.parseUrl(e),channel:this.parseChannel(e)};if(i.params=this.parseParameters(t,i),i.mediaType=this.parseMediaType(i),i.id)return i},I.prototype.createUrl=function(e,t,i){return t.start&&(t.wtime=t.start,delete t.start),i+=g(t)},I.prototype.createLongUrl=function(e,t){if(e.id&&e.mediaType===this.mediaTypes.VIDEO){var i="https://"+e.channel+".wistia.com/medias/"+e.id;return this.createUrl(e,t,i)}},I.prototype.createEmbedUrl=function(e,t){if(e.id&&(e.mediaType===this.mediaTypes.VIDEO||e.mediaType===this.mediaTypes.EMBEDVIDEO)){var i="https://fast.wistia.com/embed/iframe/"+e.id;return this.createUrl(e,t,i)}},I.prototype.createEmbedJsonpUrl=function(e){if(e.id&&(e.mediaType===this.mediaTypes.VIDEO||e.mediaType===this.mediaTypes.EMBEDVIDEO))return"https://fast.wistia.com/embed/medias/"+e.id+".jsonp"},o.bind(new I);var b=t;function w(){this.provider="youku",this.defaultFormat="long",this.formats={embed:this.createEmbedUrl,long:this.createLongUrl,flash:this.createFlashUrl,static:this.createStaticUrl},this.mediaTypes={VIDEO:"video"}}w.prototype.parseUrl=function(e){var t=e.match(/(?:(?:embed|sid)\/|v_show\/id_|VideoIDS=)([a-zA-Z0-9]+)/);return t?t[1]:void 0},w.prototype.parseParameters=function(e){return e.VideoIDS&&delete e.VideoIDS,e},w.prototype.parse=function(e,t){var i={mediaType:this.mediaTypes.VIDEO,id:this.parseUrl(e),params:this.parseParameters(t)};if(i.id)return i},w.prototype.createUrl=function(e,t,i){if(t.id&&t.mediaType===this.mediaTypes.VIDEO){var r=e+t.id;return r+=b(i)}},w.prototype.createEmbedUrl=function(e,t){return this.createUrl("http://player.youku.com/embed/",e,t)},w.prototype.createLongUrl=function(e,t){return this.createUrl("http://v.youku.com/v_show/id_",e,t)},w.prototype.createStaticUrl=function(e,t){return this.createUrl("http://static.youku.com/v1.0.0638/v/swf/loader.swf?VideoIDS=",e,t)},w.prototype.createFlashUrl=function(e,t){if(e.id&&e.mediaType===this.mediaTypes.VIDEO){var i="http://player.youku.com/player.php/sid/"+e.id+"/v.swf";return i+=b(t)}},o.bind(new w);var L=t,D=i;function A(){this.provider="youtube",this.alternatives=["youtu","ytimg"],this.defaultFormat="long",this.formats={short:this.createShortUrl,long:this.createLongUrl,embed:this.createEmbedUrl,shortImage:this.createShortImageUrl,longImage:this.createLongImageUrl},this.imageQualities={0:"0",1:"1",2:"2",3:"3",DEFAULT:"default",HQDEFAULT:"hqdefault",SDDEFAULT:"sddefault",MQDEFAULT:"mqdefault",MAXRESDEFAULT:"maxresdefault"},this.defaultImageQuality=this.imageQualities.HQDEFAULT,this.mediaTypes={VIDEO:"video",PLAYLIST:"playlist",SHARE:"share",CHANNEL:"channel"}}A.prototype.parseVideoUrl=function(e){var t=e.match(/(?:(?:v|vi|be|videos|embed)\/(?!videoseries)|(?:v|ci)=)([\w-]{11})/i);return t?t[1]:void 0},A.prototype.parseChannelUrl=function(e){var t=e.match(/\/channel\/([\w-]+)/);return t?{id:t[1],mediaType:this.mediaTypes.CHANNEL}:(t=e.match(/\/(?:c|user)\/([\w-]+)/))?{name:t[1],mediaType:this.mediaTypes.CHANNEL}:void 0},A.prototype.parseParameters=function(e,t){return(e.start||e.t)&&(e.start=D(e.start||e.t),delete e.t),e.v===t.id&&delete e.v,e.list===t.id&&delete e.list,e},A.prototype.parseMediaType=function(e){if(e.params.list&&(e.list=e.params.list,delete e.params.list),e.id&&!e.params.ci)e.mediaType=this.mediaTypes.VIDEO;else if(e.list)delete e.id,e.mediaType=this.mediaTypes.PLAYLIST;else{if(!e.params.ci)return;delete e.params.ci,e.mediaType=this.mediaTypes.SHARE}return e},A.prototype.parse=function(e,t){var i=this.parseChannelUrl(e);if(i)return i;var r={params:t,id:this.parseVideoUrl(e)};return r.params=this.parseParameters(t,r),r=this.parseMediaType(r)},A.prototype.createShortUrl=function(e,t){if(e.id&&e.mediaType===this.mediaTypes.VIDEO){var i="https://youtu.be/"+e.id;return t.start&&(i+="#t="+t.start),i}},A.prototype.createLongUrl=function(e,t){var i="",r=t.start;if(delete t.start,e.mediaType===this.mediaTypes.CHANNEL)if(e.id)i+="https://www.youtube.com/channel/"+e.id;else{if(!e.name)return;i+="https://www.youtube.com/c/"+e.name}else if(e.mediaType===this.mediaTypes.PLAYLIST&&e.list)t.feature="share",i+="https://www.youtube.com/playlist";else if(e.mediaType===this.mediaTypes.VIDEO&&e.id)t.v=e.id,i+="https://www.youtube.com/watch";else{if(e.mediaType!==this.mediaTypes.SHARE||!e.id)return;t.ci=e.id,i+="https://www.youtube.com/shared"}return e.list&&(t.list=e.list),i+=L(t),e.mediaType!==this.mediaTypes.PLAYLIST&&r&&(i+="#t="+r),i},A.prototype.createEmbedUrl=function(e,t){var i="https://www.youtube.com/embed";if(e.mediaType===this.mediaTypes.PLAYLIST&&e.list)t.listType="playlist";else{if(e.mediaType!==this.mediaTypes.VIDEO||!e.id)return;i+="/"+e.id,"1"===t.loop&&(t.playlist=e.id)}return e.list&&(t.list=e.list),i+=L(t)},A.prototype.createImageUrl=function(e,t,i){if(t.id&&t.mediaType===this.mediaTypes.VIDEO)return e+t.id+"/"+(i.imageQuality||this.defaultImageQuality)+".jpg"},A.prototype.createShortImageUrl=function(e,t){return this.createImageUrl("https://i.ytimg.com/vi/",e,t)},A.prototype.createLongImageUrl=function(e,t){return this.createImageUrl("https://img.youtube.com/vi/",e,t)},o.bind(new A);var O=t,P=i;function V(){this.provider="soundcloud",this.defaultFormat="long",this.formats={long:this.createLongUrl,embed:this.createEmbedUrl},this.mediaTypes={TRACK:"track",PLAYLIST:"playlist",APITRACK:"apitrack",APIPLAYLIST:"apiplaylist"}}V.prototype.parseUrl=function(e,t){var i=e.match(/soundcloud\.com\/(?:([\w-]+)\/(sets\/)?)([\w-]+)/i);return i?(t.channel=i[1],"playlists"===i[1]||i[2]?t.list=i[3]:t.id=i[3],t):t},V.prototype.parseParameters=function(e){return e.t&&(e.start=P(e.t),delete e.t),e},V.prototype.parseMediaType=function(e){return e.id&&("tracks"===e.channel?(delete e.channel,delete e.params.url,e.mediaType=this.mediaTypes.APITRACK):e.mediaType=this.mediaTypes.TRACK),e.list&&("playlists"===e.channel?(delete e.channel,delete e.params.url,e.mediaType=this.mediaTypes.APIPLAYLIST):e.mediaType=this.mediaTypes.PLAYLIST),e},V.prototype.parse=function(e,t){var i={};if((i=this.parseUrl(e,i)).params=this.parseParameters(t),(i=this.parseMediaType(i)).id||i.list)return i},V.prototype.createLongUrl=function(e,t){var i="",r=t.start;if(delete t.start,e.mediaType===this.mediaTypes.TRACK&&e.id&&e.channel)i="https://soundcloud.com/"+e.channel+"/"+e.id;else if(e.mediaType===this.mediaTypes.PLAYLIST&&e.list&&e.channel)i="https://soundcloud.com/"+e.channel+"/sets/"+e.list;else if(e.mediaType===this.mediaTypes.APITRACK&&e.id)i="https://api.soundcloud.com/tracks/"+e.id;else{if(e.mediaType!==this.mediaTypes.APIPLAYLIST||!e.list)return;i="https://api.soundcloud.com/playlists/"+e.list}return i+=O(t),r&&(i+="#t="+r),i},V.prototype.createEmbedUrl=function(e,t){var i="https://w.soundcloud.com/player/";if(delete t.start,e.mediaType===this.mediaTypes.APITRACK&&e.id)t.url="https%3A//api.soundcloud.com/tracks/"+e.id;else{if(e.mediaType!==this.mediaTypes.APIPLAYLIST||!e.list)return;t.url="https%3A//api.soundcloud.com/playlists/"+e.list}return i+=O(t)},o.bind(new V);var S=t;function C(){this.provider="teachertube",this.alternatives=[],this.defaultFormat="long",this.formats={long:this.createLongUrl,embed:this.createEmbedUrl},this.mediaTypes={VIDEO:"video",AUDIO:"audio",DOCUMENT:"document",CHANNEL:"channel",COLLECTION:"collection",GROUP:"group"}}return C.prototype.parse=function(e,t){var i={};i.list=this.parsePlaylist(t),i.params=t;var r=e.match(/\/(audio|video|document|user\/channel|collection|group)\/(?:[\w-]+-)?(\w+)/);if(r)return i.mediaType=this.parseMediaType(r[1]),i.id=r[2],i},C.prototype.parsePlaylist=function(e){if(e["playlist-id"]){var t=e["playlist-id"];return delete e["playlist-id"],t}},C.prototype.parseMediaType=function(e){switch(e){case"audio":return this.mediaTypes.AUDIO;case"video":return this.mediaTypes.VIDEO;case"document":return this.mediaTypes.DOCUMENT;case"user/channel":return this.mediaTypes.CHANNEL;case"collection":return this.mediaTypes.COLLECTION;case"group":return this.mediaTypes.GROUP}},C.prototype.createLongUrl=function(e,t){if(e.id){var i="https://www.teachertube.com/";return e.list&&(t["playlist-id"]=e.list),e.mediaType===this.mediaTypes.CHANNEL?i+="user/channel/":i+=e.mediaType+"/",i+=e.id,i+=S(t)}},C.prototype.createEmbedUrl=function(e,t){if(e.id){var i="https://www.teachertube.com/embed/";if(e.mediaType===this.mediaTypes.VIDEO||e.mediaType===this.mediaTypes.AUDIO)return i+=e.mediaType+"/"+e.id,i+=S(t)}},o.bind(new C),o});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).urlParser=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}var t=function(t,i){if("object"!==e(t))return"";var r="",a=0,s=Object.keys(t);if(0===s.length)return"";for(s.sort(),i||(r+="?"+s[0]+"="+t[s[0]],a+=1);a<s.length;a+=1)r+="&"+s[a]+"="+t[s[a]];return r},i=function(e){return void 0===e?0:e.match(/^(\d+[smhdw]?)+$/)?function(e){var t,i=0,r={s:1,m:60,h:3600,d:86400,w:604800};t=(e=e.replace(/([smhdw])/g," $1 ").trim()).split(" ");for(var a=0;a<t.length;a+=2)i+=parseInt(t[a],10)*r[t[a+1]||"s"];return i}(e):e.match(/^(\d+:?)+$/)?function(e){for(var t=0,i=[1,60,3600,86400,604800],r=e.split(":"),a=0;a<r.length;a++)t+=parseInt(r[a],10)*i[r.length-a-1];return t}(e):0},r=function(e){if("string"!=typeof e)return{};var t,i={},r=(e=e.split("+").join(" ")).match(/(?:[?](?:[^=]+)=(?:[^&#]*)(?:[&](?:[^=]+)=(?:[^&#]*))*(?:[#].*)?)|(?:[#].*)/);if(null===r)return{};t=r[0].substr(1).split(/[&#=]/);for(var a=0;a<t.length;a+=2)i[decodeURIComponent(t[a])]=decodeURIComponent(t[a+1]||"");return i};function a(){for(var e=0,t=["parseProvider","parse","bind","create"];e<t.length;e++){var i=t[e];this[i]=this[i].bind(this)}this.plugins={}}var s=a;a.prototype.parseProvider=function(e){var t=e.match(/(?:(?:https?:)?\/\/)?(?:[^.]+\.)?(\w+)\./i);return t?t[1]:void 0},a.prototype.parse=function(e){if(void 0!==e){var t,i=this.parseProvider(e),a=this.plugins[i];if(i&&a&&a.parse)return(t=a.parse.call(a,e,r(e)))&&((t=function(e){e.params&&0===Object.keys(e.params).length&&delete e.params;return e}(t)).provider=a.provider),t}},a.prototype.bind=function(e){if(this.plugins[e.provider]=e,e.alternatives)for(var t=0;t<e.alternatives.length;t+=1)this.plugins[e.alternatives[t]]=e},a.prototype.create=function(t){if("object"===e(t)&&"object"===e(t.videoInfo)){var i=t.videoInfo,r=t.params,a=this.plugins[i.provider];return r="internal"===r?i.params:r||{},a&&(t.format=t.format||a.defaultFormat,a.formats.hasOwnProperty(t.format))?a.formats[t.format].apply(a,[i,Object.assign({},r)]):void 0}};var o=new s,n=t;function p(){this.provider="canalplus",this.defaultFormat="embed",this.formats={embed:this.createEmbedUrl},this.mediaTypes={VIDEO:"video"}}p.prototype.parseParameters=function(e){return delete e.vid,e},p.prototype.parse=function(e,t){var i={mediaType:this.mediaTypes.VIDEO,id:t.vid};if(i.params=this.parseParameters(t),i.id)return i},p.prototype.createEmbedUrl=function(e,t){if(e.id&&e.mediaType===this.mediaTypes.VIDEO){var i="http://player.canalplus.fr/embed/";return t.vid=e.id,i+=n(t)}},o.bind(new p);var d=t;function l(){this.provider="coub",this.defaultFormat="long",this.formats={long:this.createLongUrl,embed:this.createEmbedUrl},this.mediaTypes={VIDEO:"video"}}l.prototype.parseUrl=function(e){var t=e.match(/(?:embed|view)\/([a-zA-Z\d]+)/i);return t?t[1]:void 0},l.prototype.parse=function(e,t){var i={mediaType:this.mediaTypes.VIDEO,params:t,id:this.parseUrl(e)};if(i.id)return i},l.prototype.createUrl=function(e,t,i){if(t.id&&t.mediaType===this.mediaTypes.VIDEO){var r=e+t.id;return r+=d(i)}},l.prototype.createLongUrl=function(e,t){return this.createUrl("https://coub.com/view/",e,t)},l.prototype.createEmbedUrl=function(e,t){return this.createUrl("//coub.com/embed/",e,t)},o.bind(new l);var m=t,c=i;function h(){this.provider="dailymotion",this.alternatives=["dai"],this.defaultFormat="long",this.formats={short:this.createShortUrl,long:this.createLongUrl,embed:this.createEmbedUrl,image:this.createImageUrl},this.mediaTypes={VIDEO:"video"}}h.prototype.parseParameters=function(e){return this.parseTime(e)},h.prototype.parseTime=function(e){return e.start&&(e.start=c(e.start)),e},h.prototype.parseUrl=function(e){var t=e.match(/(?:\/video|ly)\/([A-Za-z0-9]+)/i);return t?t[1]:void 0},h.prototype.parse=function(e,t){var i={mediaType:this.mediaTypes.VIDEO,params:this.parseParameters(t),id:this.parseUrl(e)};return i.id?i:void 0},h.prototype.createUrl=function(e,t,i){if(t.id&&t.mediaType===this.mediaTypes.VIDEO)return e+t.id+m(i)},h.prototype.createShortUrl=function(e,t){return this.createUrl("https://dai.ly/",e,t)},h.prototype.createLongUrl=function(e,t){return this.createUrl("https://dailymotion.com/video/",e,t)},h.prototype.createEmbedUrl=function(e,t){return this.createUrl("https://www.dailymotion.com/embed/video/",e,t)},h.prototype.createImageUrl=function(e,t){return delete t.start,this.createUrl("https://www.dailymotion.com/thumbnail/video/",e,t)},o.bind(new h);var u=t,y=i;function f(){this.provider="twitch",this.defaultFormat="long",this.formats={long:this.createLongUrl,embed:this.createEmbedUrl},this.mediaTypes={VIDEO:"video",STREAM:"stream",CLIP:"clip"}}f.prototype.seperateId=function(e){return{pre:e[0],id:e.substr(1)}},f.prototype.parseChannel=function(e,t){var i=t.channel||t.utm_content||e.channel;return delete t.utm_content,delete t.channel,i},f.prototype.parseUrl=function(e,t,i){var r;return(r=e.match(/(clips\.)?twitch\.tv\/(?:(?:videos\/(\d+))|(\w+)(?:\/clip\/(\w+))?)/i))&&r[2]?t.id="v"+r[2]:i.video?(t.id=i.video,delete i.video):i.clip?(t.id=i.clip,t.isClip=!0,delete i.clip):r&&r[1]&&r[3]?(t.id=r[3],t.isClip=!0):r&&r[3]&&r[4]?(t.channel=r[3],t.id=r[4],t.isClip=!0):r&&r[3]&&(t.channel=r[3]),t},f.prototype.parseMediaType=function(e){var t;return e.id?e.isClip?(t=this.mediaTypes.CLIP,delete e.isClip):t=this.mediaTypes.VIDEO:e.channel&&(t=this.mediaTypes.STREAM),t},f.prototype.parseParameters=function(e){return e.t&&(e.start=y(e.t),delete e.t),e},f.prototype.parse=function(e,t){var i={};return(i=this.parseUrl(e,i,t)).channel=this.parseChannel(i,t),i.mediaType=this.parseMediaType(i),i.params=this.parseParameters(t),i.channel||i.id?i:void 0},f.prototype.createLongUrl=function(e,t){var i="";if(e.mediaType===this.mediaTypes.STREAM&&e.channel)i="https://twitch.tv/"+e.channel;else if(e.mediaType===this.mediaTypes.VIDEO&&e.id){i="https://twitch.tv/videos/"+this.seperateId(e.id).id,t.start&&(t.t=t.start+"s",delete t.start)}else{if(e.mediaType!==this.mediaTypes.CLIP||!e.id)return;i=e.channel?"https://www.twitch.tv/"+e.channel+"/clip/"+e.id:"https://clips.twitch.tv/"+e.id}return i+=u(t)},f.prototype.createEmbedUrl=function(e,t){var i="https://player.twitch.tv/";if(e.mediaType===this.mediaTypes.STREAM&&e.channel)t.channel=e.channel;else if(e.mediaType===this.mediaTypes.VIDEO&&e.id)t.video=e.id,t.start&&(t.t=t.start+"s",delete t.start);else{if(e.mediaType!==this.mediaTypes.CLIP||!e.id)return;i="https://clips.twitch.tv/embed",t.clip=e.id}return i+=u(t)},o.bind(new f);var v=t,T=i;function U(){this.provider="vimeo",this.alternatives=["vimeopro","vimeocdn"],this.defaultFormat="long",this.formats={long:this.createLongUrl,embed:this.createEmbedUrl,image:this.createImageUrl},this.mediaTypes={VIDEO:"video"}}U.prototype.parseUrl=function(e,t){var i=e.match(/(vimeo(?:cdn|pro)?)\.com\/(?:(?:channels\/[\w]+|(?:(?:album\/\d+|groups\/[\w]+|staff\/frame)\/)?videos?)\/)?(\d+)(?:_(\d+)(?:x(\d+))?)?(\.\w+)?/i);return i?(t.id=i[2],"vimeocdn"===i[1]&&(i[3]&&(t.imageWidth=parseInt(i[3]),i[4]&&(t.imageHeight=parseInt(i[4]))),t.imageExtension=i[5]),t):t},U.prototype.parseParameters=function(e){return this.parseTime(e)},U.prototype.parseTime=function(e){return e.t&&(e.start=T(e.t),delete e.t),e},U.prototype.parse=function(e,t){var i={mediaType:this.mediaTypes.VIDEO,params:this.parseParameters(t)};return(i=this.parseUrl(e,i)).id?i:void 0},U.prototype.createUrl=function(e,t,i){if(t.id&&t.mediaType===this.mediaTypes.VIDEO){var r=e+t.id,a=i.start;return delete i.start,r+=v(i),a&&(r+="#t="+a),r}},U.prototype.createLongUrl=function(e,t){return this.createUrl("https://vimeo.com/",e,t)},U.prototype.createEmbedUrl=function(e,t){return this.createUrl("//player.vimeo.com/video/",e,t)},U.prototype.createImageUrl=function(e,t){if(e.id&&e.mediaType===this.mediaTypes.VIDEO){var i="https://i.vimeocdn.com/video/"+e.id;return e.imageWidth&&e.imageHeight?i+="_"+e.imageWidth+"x"+e.imageHeight:e.imageWidth&&(i+="_"+e.imageWidth),void 0===e.imageExtension&&(e.imageExtension=".webp"),i+=e.imageExtension,delete e.imageExtension,i+=v(t)}},o.bind(new U);var g=t,E=i;function I(){this.provider="wistia",this.alternatives=[],this.defaultFormat="long",this.formats={long:this.createLongUrl,embed:this.createEmbedUrl,embedjsonp:this.createEmbedJsonpUrl},this.mediaTypes={VIDEO:"video",EMBEDVIDEO:"embedvideo"}}I.prototype.parseUrl=function(e){var t=e.match(/(?:(?:medias|iframe)\/|wvideo=)([\w-]+)/);return t?t[1]:void 0},I.prototype.parseChannel=function(e){var t=e.match(/(?:(?:https?:)?\/\/)?([^.]*)\.wistia\./),i=t?t[1]:void 0;if("fast"!==i&&"content"!==i)return i},I.prototype.parseParameters=function(e,t){return e.wtime&&(e.start=E(e.wtime),delete e.wtime),e.wvideo===t.id&&delete e.wvideo,e},I.prototype.parseMediaType=function(e){return e.id&&e.channel?this.mediaTypes.VIDEO:e.id?(delete e.channel,this.mediaTypes.EMBEDVIDEO):void 0},I.prototype.parse=function(e,t){var i={id:this.parseUrl(e),channel:this.parseChannel(e)};if(i.params=this.parseParameters(t,i),i.mediaType=this.parseMediaType(i),i.id)return i},I.prototype.createUrl=function(e,t,i){return t.start&&(t.wtime=t.start,delete t.start),i+=g(t)},I.prototype.createLongUrl=function(e,t){if(e.id&&e.mediaType===this.mediaTypes.VIDEO){var i="https://"+e.channel+".wistia.com/medias/"+e.id;return this.createUrl(e,t,i)}},I.prototype.createEmbedUrl=function(e,t){if(e.id&&(e.mediaType===this.mediaTypes.VIDEO||e.mediaType===this.mediaTypes.EMBEDVIDEO)){var i="https://fast.wistia.com/embed/iframe/"+e.id;return this.createUrl(e,t,i)}},I.prototype.createEmbedJsonpUrl=function(e){if(e.id&&(e.mediaType===this.mediaTypes.VIDEO||e.mediaType===this.mediaTypes.EMBEDVIDEO))return"https://fast.wistia.com/embed/medias/"+e.id+".jsonp"},o.bind(new I);var b=t;function w(){this.provider="youku",this.defaultFormat="long",this.formats={embed:this.createEmbedUrl,long:this.createLongUrl,flash:this.createFlashUrl,static:this.createStaticUrl},this.mediaTypes={VIDEO:"video"}}w.prototype.parseUrl=function(e){var t=e.match(/(?:(?:embed|sid)\/|v_show\/id_|VideoIDS=)([a-zA-Z0-9]+)/);return t?t[1]:void 0},w.prototype.parseParameters=function(e){return e.VideoIDS&&delete e.VideoIDS,e},w.prototype.parse=function(e,t){var i={mediaType:this.mediaTypes.VIDEO,id:this.parseUrl(e),params:this.parseParameters(t)};if(i.id)return i},w.prototype.createUrl=function(e,t,i){if(t.id&&t.mediaType===this.mediaTypes.VIDEO){var r=e+t.id;return r+=b(i)}},w.prototype.createEmbedUrl=function(e,t){return this.createUrl("http://player.youku.com/embed/",e,t)},w.prototype.createLongUrl=function(e,t){return this.createUrl("http://v.youku.com/v_show/id_",e,t)},w.prototype.createStaticUrl=function(e,t){return this.createUrl("http://static.youku.com/v1.0.0638/v/swf/loader.swf?VideoIDS=",e,t)},w.prototype.createFlashUrl=function(e,t){if(e.id&&e.mediaType===this.mediaTypes.VIDEO){var i="http://player.youku.com/player.php/sid/"+e.id+"/v.swf";return i+=b(t)}},o.bind(new w);var L=t,D=i;function A(){this.provider="youtube",this.alternatives=["youtu","ytimg"],this.defaultFormat="long",this.formats={short:this.createShortUrl,long:this.createLongUrl,embed:this.createEmbedUrl,shortImage:this.createShortImageUrl,longImage:this.createLongImageUrl},this.imageQualities={0:"0",1:"1",2:"2",3:"3",DEFAULT:"default",HQDEFAULT:"hqdefault",SDDEFAULT:"sddefault",MQDEFAULT:"mqdefault",MAXRESDEFAULT:"maxresdefault"},this.defaultImageQuality=this.imageQualities.HQDEFAULT,this.mediaTypes={VIDEO:"video",PLAYLIST:"playlist",SHARE:"share",CHANNEL:"channel"}}A.prototype.parseVideoUrl=function(e){var t=e.match(/(?:(?:v|vi|be|videos|embed)\/(?!videoseries)|(?:v|ci)=)([\w-]{11})/i);return t?t[1]:void 0},A.prototype.parseChannelUrl=function(e){var t=e.match(/\/channel\/([\w-]+)/);return t?{id:t[1],mediaType:this.mediaTypes.CHANNEL}:(t=e.match(/\/(?:c|user)\/([\w-]+)/))?{name:t[1],mediaType:this.mediaTypes.CHANNEL}:void 0},A.prototype.parseParameters=function(e,t){return(e.start||e.t)&&(e.start=D(e.start||e.t),delete e.t),e.v===t.id&&delete e.v,e.list===t.id&&delete e.list,e},A.prototype.parseMediaType=function(e){if(e.params.list&&(e.list=e.params.list,delete e.params.list),e.id&&!e.params.ci)e.mediaType=this.mediaTypes.VIDEO;else if(e.list)delete e.id,e.mediaType=this.mediaTypes.PLAYLIST;else{if(!e.params.ci)return;delete e.params.ci,e.mediaType=this.mediaTypes.SHARE}return e},A.prototype.parse=function(e,t){var i=this.parseChannelUrl(e);if(i)return i;var r={params:t,id:this.parseVideoUrl(e)};return r.params=this.parseParameters(t,r),r=this.parseMediaType(r)},A.prototype.createShortUrl=function(e,t){if(e.id&&e.mediaType===this.mediaTypes.VIDEO){var i="https://youtu.be/"+e.id;return t.start&&(i+="#t="+t.start),i}},A.prototype.createLongUrl=function(e,t){var i="",r=t.start;if(delete t.start,e.mediaType===this.mediaTypes.CHANNEL)if(e.id)i+="https://www.youtube.com/channel/"+e.id;else{if(!e.name)return;i+="https://www.youtube.com/c/"+e.name}else if(e.mediaType===this.mediaTypes.PLAYLIST&&e.list)t.feature="share",i+="https://www.youtube.com/playlist";else if(e.mediaType===this.mediaTypes.VIDEO&&e.id)t.v=e.id,i+="https://www.youtube.com/watch";else{if(e.mediaType!==this.mediaTypes.SHARE||!e.id)return;t.ci=e.id,i+="https://www.youtube.com/shared"}return e.list&&(t.list=e.list),i+=L(t),e.mediaType!==this.mediaTypes.PLAYLIST&&r&&(i+="#t="+r),i},A.prototype.createEmbedUrl=function(e,t){var i="https://www.youtube.com/embed";if(e.mediaType===this.mediaTypes.PLAYLIST&&e.list)t.listType="playlist";else{if(e.mediaType!==this.mediaTypes.VIDEO||!e.id)return;i+="/"+e.id,"1"===t.loop&&(t.playlist=e.id)}return e.list&&(t.list=e.list),i+=L(t)},A.prototype.createImageUrl=function(e,t,i){if(t.id&&t.mediaType===this.mediaTypes.VIDEO)return e+t.id+"/"+(i.imageQuality||this.defaultImageQuality)+".jpg"},A.prototype.createShortImageUrl=function(e,t){return this.createImageUrl("https://i.ytimg.com/vi/",e,t)},A.prototype.createLongImageUrl=function(e,t){return this.createImageUrl("https://img.youtube.com/vi/",e,t)},o.bind(new A);var O=t,P=i;function V(){this.provider="soundcloud",this.defaultFormat="long",this.formats={long:this.createLongUrl,embed:this.createEmbedUrl},this.mediaTypes={TRACK:"track",PLAYLIST:"playlist",APITRACK:"apitrack",APIPLAYLIST:"apiplaylist"}}V.prototype.parseUrl=function(e,t){var i=e.match(/(?:m\.)?soundcloud\.com\/(?:([\w-]+)\/(sets\/)?)([\w-]+)/i);return i?(t.channel=i[1],"playlists"===i[1]||i[2]?t.list=i[3]:t.id=i[3],t):t},V.prototype.parseParameters=function(e){return e.t&&(e.start=P(e.t),delete e.t),e},V.prototype.parseMediaType=function(e){return e.id&&("tracks"===e.channel?(delete e.channel,delete e.params.url,e.mediaType=this.mediaTypes.APITRACK):e.mediaType=this.mediaTypes.TRACK),e.list&&("playlists"===e.channel?(delete e.channel,delete e.params.url,e.mediaType=this.mediaTypes.APIPLAYLIST):e.mediaType=this.mediaTypes.PLAYLIST),e},V.prototype.parse=function(e,t){var i={};if((i=this.parseUrl(e,i)).params=this.parseParameters(t),(i=this.parseMediaType(i)).id||i.list)return i},V.prototype.createLongUrl=function(e,t){var i="",r=t.start;if(delete t.start,e.mediaType===this.mediaTypes.TRACK&&e.id&&e.channel)i="https://soundcloud.com/"+e.channel+"/"+e.id;else if(e.mediaType===this.mediaTypes.PLAYLIST&&e.list&&e.channel)i="https://soundcloud.com/"+e.channel+"/sets/"+e.list;else if(e.mediaType===this.mediaTypes.APITRACK&&e.id)i="https://api.soundcloud.com/tracks/"+e.id;else{if(e.mediaType!==this.mediaTypes.APIPLAYLIST||!e.list)return;i="https://api.soundcloud.com/playlists/"+e.list}return i+=O(t),r&&(i+="#t="+r),i},V.prototype.createEmbedUrl=function(e,t){var i="https://w.soundcloud.com/player/";if(delete t.start,e.mediaType===this.mediaTypes.APITRACK&&e.id)t.url="https%3A//api.soundcloud.com/tracks/"+e.id;else{if(e.mediaType!==this.mediaTypes.APIPLAYLIST||!e.list)return;t.url="https%3A//api.soundcloud.com/playlists/"+e.list}return i+=O(t)},o.bind(new V);var S=t;function C(){this.provider="teachertube",this.alternatives=[],this.defaultFormat="long",this.formats={long:this.createLongUrl,embed:this.createEmbedUrl},this.mediaTypes={VIDEO:"video",AUDIO:"audio",DOCUMENT:"document",CHANNEL:"channel",COLLECTION:"collection",GROUP:"group"}}return C.prototype.parse=function(e,t){var i={};i.list=this.parsePlaylist(t),i.params=t;var r=e.match(/\/(audio|video|document|user\/channel|collection|group)\/(?:[\w-]+-)?(\w+)/);if(r)return i.mediaType=this.parseMediaType(r[1]),i.id=r[2],i},C.prototype.parsePlaylist=function(e){if(e["playlist-id"]){var t=e["playlist-id"];return delete e["playlist-id"],t}},C.prototype.parseMediaType=function(e){switch(e){case"audio":return this.mediaTypes.AUDIO;case"video":return this.mediaTypes.VIDEO;case"document":return this.mediaTypes.DOCUMENT;case"user/channel":return this.mediaTypes.CHANNEL;case"collection":return this.mediaTypes.COLLECTION;case"group":return this.mediaTypes.GROUP}},C.prototype.createLongUrl=function(e,t){if(e.id){var i="https://www.teachertube.com/";return e.list&&(t["playlist-id"]=e.list),e.mediaType===this.mediaTypes.CHANNEL?i+="user/channel/":i+=e.mediaType+"/",i+=e.id,i+=S(t)}},C.prototype.createEmbedUrl=function(e,t){if(e.id){var i="https://www.teachertube.com/embed/";if(e.mediaType===this.mediaTypes.VIDEO||e.mediaType===this.mediaTypes.AUDIO)return i+=e.mediaType+"/"+e.id,i+=S(t)}},o.bind(new C),o}));

@@ -25,3 +25,3 @@ const {

var match = url.match(
/soundcloud\.com\/(?:([\w-]+)\/(sets\/)?)([\w-]+)/i
/(?:m\.)?soundcloud\.com\/(?:([\w-]+)\/(sets\/)?)([\w-]+)/i
);

@@ -28,0 +28,0 @@ if (!match) {

@@ -68,2 +68,3 @@ const {

op.format = op.format || plugin.defaultFormat;
// eslint-disable-next-line no-prototype-builtins
if (plugin.formats.hasOwnProperty(op.format)) {

@@ -70,0 +71,0 @@ return plugin.formats[op.format].apply(plugin, [vi, Object.assign({}, params)]);

{
"name": "js-video-url-parser",
"version": "0.4.0",
"version": "0.4.1",
"description": "A parser to extract provider, video id, starttime and others from YouTube, Vimeo, ... urls",

@@ -32,15 +32,14 @@ "main": "lib/index.js",

"devDependencies": {
"@babel/core": "^7.3.4",
"@babel/preset-env": "^7.3.4",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^8.2.3",
"babel-preset-minify": "^0.2.0",
"eslint": "^4.19.1",
"eslint-plugin-jest": "^21.15.1",
"jest": "^24.1.0",
"rollup": "^0.54.1",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^8.4.1",
"rollup-plugin-minify-es": "^1.1.1",
"rollup-plugin-node-resolve": "^3.3.0"
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"babel-eslint": "^10.1.0",
"babel-preset-minify": "^0.5.1",
"eslint": "^6.8.0",
"eslint-plugin-jest": "^23.8.2",
"jest": "^25.2.3",
"rollup": "^2.2.0",
"rollup-plugin-babel": "^4.4.0",
"@rollup/plugin-node-resolve": "^7.1.1",
"@rollup/plugin-commonjs": "^11.0.2",
"rollup-plugin-terser": "^5.3.0"
},

@@ -52,4 +51,4 @@ "scripts": {

"lintdryfix": "./node_modules/.bin/eslint . --fix-dry-run",
"all": "npm run test && npm run lint && npm run build"
"all": "npm audit && npm run test && npm run lint && npm run build"
}
}

@@ -44,11 +44,11 @@ jsVideoUrlParser [![Build Status](https://travis-ci.org/Zod-/jsVideoUrlParser.svg)](https://travis-ci.org/Zod-/jsVideoUrlParser) [![Gitter](https://badges.gitter.im/Zod-/jsVideoUrlParser.svg)](https://gitter.im/Zod-/jsVideoUrlParser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

import urlParser from "js-video-url-parser/lib/base";
import "js-video-url-parser/lib/provider/canalplus';
import "js-video-url-parser/lib/provider/coub';
import "js-video-url-parser/lib/provider/dailymotion';
import "js-video-url-parser/lib/provider/twitch';
import "js-video-url-parser/lib/provider/vimeo';
import "js-video-url-parser/lib/provider/wistia';
import "js-video-url-parser/lib/provider/youku';
import "js-video-url-parser/lib/provider/youtube';
import "js-video-url-parser/lib/provider/teachertube';
import "js-video-url-parser/lib/provider/canalplus";
import "js-video-url-parser/lib/provider/coub";
import "js-video-url-parser/lib/provider/dailymotion";
import "js-video-url-parser/lib/provider/twitch";
import "js-video-url-parser/lib/provider/vimeo";
import "js-video-url-parser/lib/provider/wistia";
import "js-video-url-parser/lib/provider/youku";
import "js-video-url-parser/lib/provider/youtube";
import "js-video-url-parser/lib/provider/teachertube";

@@ -55,0 +55,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc