minor embedable content update
This commit is contained in:
parent
198e80ad81
commit
a077c816e2
2 changed files with 33 additions and 22 deletions
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
|
@ -37,6 +37,7 @@
|
||||||
"libcurl",
|
"libcurl",
|
||||||
"libx",
|
"libx",
|
||||||
"matroska",
|
"matroska",
|
||||||
|
"mbed",
|
||||||
"Microformat",
|
"Microformat",
|
||||||
"microformats",
|
"microformats",
|
||||||
"mkvtoolsnix",
|
"mkvtoolsnix",
|
||||||
|
|
|
||||||
|
|
@ -2,57 +2,62 @@ const sources = [
|
||||||
{
|
{
|
||||||
name: 'youtube',
|
name: 'youtube',
|
||||||
url: 'https://www.youtube-nocookie.com/embed/',
|
url: 'https://www.youtube-nocookie.com/embed/',
|
||||||
regex: /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:shorts\/|[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,
|
regex: /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:shorts\/|[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)(?<id>[a-zA-Z0-9_-]{11})/,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "instagram",
|
name: "instagram_post",
|
||||||
url: "https://www.instagram.com/p/",
|
url: "https://www.instagram.com/p/",
|
||||||
regex: /https?:\/\/(?:www\.)?instagram\.com\/p\/([^/?#&]+)/,
|
regex: /https?:\/\/(?:www\.)?instagram\.com\/p\/(?<id>[^/?#&]+)/,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "instagram_story",
|
||||||
|
url: "https://www.instagram.com/stories/highlights/",
|
||||||
|
regex: /https?:\/\/(?:www\.)?instagram\.com\/stories\/highlights\/(?<id>[^/?#&]+)/,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "twitter",
|
name: "twitter",
|
||||||
url: "https://twitter.com/i/status/",
|
url: "https://twitter.com/i/status/",
|
||||||
regex: /https?:\/\/(?:www\.)?twitter\.com\/i\/status\/([^/?#&]+)/,
|
regex: /https?:\/\/(?:www\.)?(twitter\.com|x\.com)\/.+?\/status\/(?<id>[^/?#&]+)/,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "facebook",
|
name: "facebook",
|
||||||
url: "https://www.facebook.com/plugins/post.php?href=",
|
url: "https://www.facebook.com/plugins/post.php?href=",
|
||||||
regex: /https?:\/\/(?:www\.)?facebook\.com\/(?:[^/?#&]+)\/posts\/([^/?#&]+)/,
|
regex: /https?:\/\/(?:www\.)?facebook\.com\/(?:[^/?#&]+)\/posts\/(?<id>[^/?#&]+)/,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "tiktok",
|
name: "tiktok",
|
||||||
url: "https://www.tiktok.com/embed/",
|
url: "https://www.tiktok.com/embed/",
|
||||||
regex: /https?:\/\/(?:www\.)?tiktok\.com\/(?:[^/?#&]+)\/video\/([^/?#&]+)/,
|
regex: /https?:\/\/(?:www\.)?tiktok\.com\/(?:[^/?#&]+)\/video\/(?<id>[^/?#&]+)/,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "vimeo",
|
name: "vimeo",
|
||||||
url: "https://player.vimeo.com/video/",
|
url: "https://player.vimeo.com/video/",
|
||||||
regex: /https?:\/\/(?:www\.)?vimeo\.com\/(?:[^/?#&]+)\/([^/?#&]+)/,
|
regex: /https?:\/\/(?:www\.)?vimeo\.com(?:\/[^/?#&]+)?\/(?<id>[^/?#&]+)/,
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "soundcloud",
|
|
||||||
url: "https://w.soundcloud.com/player/?url=",
|
|
||||||
regex: /https?:\/\/(?:www\.)?soundcloud\.com\/(?:[^/?#&]+)\/([^/?#&]+)/,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "spotify",
|
name: "spotify",
|
||||||
url: "https://open.spotify.com/embed/",
|
url: "https://open.spotify.com/embed/",
|
||||||
regex: /https?:\/\/(?:open\.)?spotify\.com\/(?:[^/?#&]+)\/([^/?#&]+)/,
|
regex: /https?:\/\/(?:open\.)?spotify\.com\/(?:[^/?#&]+)\/(?<id>[^/?#&]+)/,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "twitch",
|
name: "twitch_vod",
|
||||||
url: "https://player.twitch.tv/?channel=",
|
url: "https://player.twitch.tv/?parent={origin}&video=",
|
||||||
regex: /https?:\/\/(?:www\.)?twitch\.tv\/(?:[^/?#&]+)\/([^/?#&]+)/,
|
regex: /https?:\/\/(?:www\.)?twitch\.tv\/(?:[^/?#&]+)\/(?<id>[^/?#&]+)/,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mixcloud",
|
name: "twitch_clip",
|
||||||
url: "https://www.mixcloud.com/widget/iframe/",
|
url: "https://clips.twitch.tv/embed?parent={origin}&clip=",
|
||||||
regex: /https?:\/\/(?:www\.)?mixcloud\.com\/(?:[^/?#&]+)\/([^/?#&]+)/,
|
regex: /https?:\/\/(?:www\.)?twitch\.tv\/(?:[^/?#&]+)\/clip\/(?<id>[^/?#&]+)/,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "twitch_channel",
|
||||||
|
url: "https://player.twitch.tv/?parent={origin}&channel=",
|
||||||
|
regex: /https?:\/\/(?:www\.)?twitch\.tv\/(?<id>[^/?#&]+)/,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "dailymotion",
|
name: "dailymotion",
|
||||||
url: "https://www.dailymotion.com/embed/video/",
|
url: "https://www.dailymotion.com/embed/video/",
|
||||||
regex: /https?:\/\/(?:www\.)?dailymotion\.com\/(?:[^/?#&]+)\/video\/([^/?#&]+)/,
|
regex: /^.+dailymotion.com\/(video|hub)\/(?<id>[^_]+)[^#]*(#video=([^_&]+))?/,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -62,8 +67,13 @@ const isEmbedable = url => {
|
||||||
|
|
||||||
const getEmbedable = url => {
|
const getEmbedable = url => {
|
||||||
const source = sources.find(source => source.regex.test(url));
|
const source = sources.find(source => source.regex.test(url));
|
||||||
const id = source.regex.exec(url)[1];
|
if (!source) {
|
||||||
return source.url + id;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
source.url.replace(/\{origin\}/g, window.location.origin);
|
||||||
|
|
||||||
|
return source.url + source.regex.exec(url)['groups'].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { isEmbedable, getEmbedable };
|
export { isEmbedable, getEmbedable };
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue