Comparing version 0.0.10 to 0.0.11
@@ -39,2 +39,4 @@ var getUrls = require('get-urls'); | ||
var vimeoId = this.isVimeo(url); | ||
var bitchuteId = this.isBitchute(url); | ||
if (youtubeId) { | ||
@@ -45,3 +47,3 @@ return { | ||
'provider_name': 'YouTube', | ||
'thumbnail': 'https://i.ytimg.com/vi/' + youtubeId + '/hqdefault.jpg', | ||
'thumbnail': 'https://img.youtube.com/vi/' + youtubeId + '/mqdefault.jpg', | ||
'id': youtubeId, | ||
@@ -82,2 +84,10 @@ 'embed': this.youtube(url, youtubeId, options) | ||
} | ||
} else if (bitchuteId) { | ||
return { | ||
type: 'video', | ||
url: url, | ||
provider_name: 'BitChute', | ||
id: bitchuteId, | ||
embed: this.bitchute(url, bitchuteId, options) | ||
} | ||
} | ||
@@ -139,3 +149,11 @@ }; | ||
SteemEmbed.isBitchute = function(url) { | ||
var p = /^(?:https?:\/\/)?(?:www\.)?(?:bitchute\.com\/video\/)(\w+)\/?$/; | ||
return url.match(p) ? RegExp.$1 : false; | ||
}; | ||
module.exports = SteemEmbed; | ||
SteemEmbed.bitchute = function(url, id, options) { | ||
return '<iframe width="' + options.width + '" height="' + options.height + '" src="https://www.bitchute.com/embed/' + id + '" frameborder="0" scrolling="no" allowfullscreen></iframe>'; | ||
}; | ||
module.exports = SteemEmbed; |
{ | ||
"name": "embedjs", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Extract embed information for all the media links in your texts", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var expect = require('expect'); | ||
var embedjs = require('./../lib/embedjs'); | ||
var text = 'Lorem ipsum dolor sit amet https://www.twitch.tv/johnnydarko420, https://youtu.be/DAYNwC-aMgQ?t=2m8s consectetur adipiscing elit, https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in https://www.youtube.com/watch?v=waiCd_CVxdc reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, https://www.google.fr/?gws_rd=ssl sunt in culpa qui officia deserunt mollit anim id est laborum.'; | ||
var text = ` | ||
Lorem ipsum dolor sit amet https://www.twitch.tv/johnnydarko420, | ||
https://youtu.be/DAYNwC-aMgQ?t=2m8s consectetur adipiscing elit, | ||
https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon sed do | ||
eiusmod tempor incididunt ut labore et dolore magna aliqua. | ||
Ut enim ad minim veniam, https://www.bitchute.com/video/c7a1wNltJ30 quis | ||
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | ||
Duis aute irure dolor in https://www.youtube.com/watch?v=waiCd_CVxdc | ||
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. | ||
Excepteur sint occaecat cupidatat non proident, https://www.google.fr/?gws_rd=ssl | ||
sunt in culpa qui officia deserunt mollit anim id est laborum. | ||
`; | ||
var embeds = embedjs.getAll(text); | ||
@@ -19,3 +31,3 @@ | ||
provider_name: 'YouTube', | ||
thumbnail: 'https://i.ytimg.com/vi/DAYNwC-aMgQ/hqdefault.jpg', | ||
thumbnail: 'https://img.youtube.com/vi/DAYNwC-aMgQ/mqdefault.jpg', | ||
id: 'DAYNwC-aMgQ', | ||
@@ -33,5 +45,12 @@ embed: '<iframe width="100%" height="400" src="//www.youtube.com/embed/DAYNwC-aMgQ?autoplay=1&start=128" frameborder="0" scrolling="no" allowfullscreen></iframe>' | ||
type: 'video', | ||
url: 'https://bitchute.com/video/c7a1wNltJ30', | ||
provider_name: 'BitChute', | ||
id: 'c7a1wNltJ30', | ||
embed: '<iframe width="100%" height="400" src="https://www.bitchute.com/embed/c7a1wNltJ30" frameborder="0" scrolling="no" allowfullscreen></iframe>' | ||
}, | ||
{ | ||
type: 'video', | ||
url: 'https://youtube.com/watch?v=waiCd_CVxdc', | ||
provider_name: 'YouTube', | ||
thumbnail: 'https://i.ytimg.com/vi/waiCd_CVxdc/hqdefault.jpg', | ||
thumbnail: 'https://img.youtube.com/vi/waiCd_CVxdc/mqdefault.jpg', | ||
id: 'waiCd_CVxdc', | ||
@@ -38,0 +57,0 @@ embed: '<iframe width="100%" height="400" src="//www.youtube.com/embed/waiCd_CVxdc?autoplay=1" frameborder="0" scrolling="no" allowfullscreen></iframe>' |
26542
190
6