UNPKG

@haruhi_smith/js-video-url-parser

Version:

A parser to extract provider, video id, starttime and others from YouTube, Vimeo, Coursera ... urls

33 lines (26 loc) 614 B
function Coursera() { this.provider = 'coursera'; this.mediaTypes = { VIDEO: 'video', }; this.mediaTypes = { VIDEO: 'video', PLAYLIST: 'playlist', }; } module.exports = Coursera; Coursera.prototype.parseUrl = function(url) { var match = url.match( /(learn\/.*\/lecture)\/([a-zA-Z/-\d]+)/i ); return match ? match[2] : undefined; }; Coursera.prototype.parse = function(url, params) { var result = { mediaType: this.mediaTypes.VIDEO, params: params, id: this.parseUrl(url), }; return result.id ? result : undefined; }; require('../base').bind(new Coursera());