Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 34 additions & 21 deletions src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import type { ServicesConfigType } from './serviceConfig';

const SERVICES: ServicesConfigType = {
vimeo: {
regex: /(?:http[s]?:\/\/)?(?:www.)?(?:player.)?vimeo\.co(?:.+\/([^\/]\d+)(?:#t=[\d]+)?s?$)/,
embedUrl: 'https://player.vimeo.com/video/<%= remote_id %>?title=0&byline=0',
regex:
/(?:http[s]?:\/\/)?(?:www.)?(?:player.)?vimeo\.co(?:.+\/([^\/]\d+)(?:#t=[\d]+)?s?$)/,
embedUrl:
'https://player.vimeo.com/video/<%= remote_id %>?title=0&byline=0',
html: '<iframe style="width:100%;" height="320" frameborder="0"></iframe>',
height: 320,
width: 580,
},
youtube: {
regex: /(?:https?:\/\/)?(?:www\.)?(?:(?:youtu\.be\/)|(?:youtube\.com)\/(?:v\/|u\/\w\/|embed\/|watch))(?:(?:\?v=)?([^#&?=]*))?((?:[?&]\w*=\w*)*)/,
regex:
/(?:https?:\/\/)?(?:www\.)?(?:(?:youtu\.be\/)|(?:youtube\.com)\/(?:v\/|u\/\w\/|embed\/|watch|shorts\/))(?:(?:\?v=)?([^#&?=]*))?((?:[?&]\w*=\w*)*)/,
embedUrl: 'https://www.youtube.com/embed/<%= remote_id %>',
html: '<iframe style="width:100%;" height="320" frameborder="0" allowfullscreen></iframe>',
height: 320,
Expand All @@ -29,9 +32,10 @@ const SERVICES: ServicesConfigType = {
list: 'list',
};

let newParams = params.slice(1)
let newParams = params
.slice(1)
.split('&')
.map(param => {
.map((param) => {
const [name, value] = param.split('=');

if (!id && name === 'v') {
Expand All @@ -40,19 +44,21 @@ const SERVICES: ServicesConfigType = {
return null;
}

if (!(paramsMap[name])) {
if (!paramsMap[name]) {
return null;
}

if (value === 'LL' ||
if (
value === 'LL' ||
value.startsWith('RDMM') ||
value.startsWith('FL')) {
value.startsWith('FL')
) {
return null;
}

return `${paramsMap[name]}=${value}`;
})
.filter(param => !!param);
.filter((param) => !!param);

return id + '?' + newParams.join('&');
},
Expand Down Expand Up @@ -101,30 +107,33 @@ const SERVICES: ServicesConfigType = {
},
'yandex-music-album': {
regex: /https?:\/\/music\.yandex\.ru\/album\/([0-9]*)\/?$/,
embedUrl: 'https://music\.yandex\.ru/iframe/#album/<%= remote_id %>/',
html: '<iframe frameborder=\"0\" style=\"border:none;width:540px;height:400px;\" style=\"width:100%;\" height=\"400\"></iframe>',
embedUrl: 'https://music.yandex.ru/iframe/#album/<%= remote_id %>/',
html: '<iframe frameborder="0" style="border:none;width:540px;height:400px;" style="width:100%;" height="400"></iframe>',
height: 400,
width: 540,
},
'yandex-music-track': {
regex: /https?:\/\/music\.yandex\.ru\/album\/([0-9]*)\/track\/([0-9]*)/,
embedUrl: 'https://music\.yandex\.ru/iframe/#track/<%= remote_id %>/',
embedUrl: 'https://music.yandex.ru/iframe/#track/<%= remote_id %>/',
html: '<iframe frameborder="0" style="border:none;width:540px;height:100px;" style="width:100%;" height="100"></iframe>',
height: 100,
width: 540,
id: (ids) => ids.join('/'),
},
'yandex-music-playlist': {
regex: /https?:\/\/music\.yandex\.ru\/users\/([^\/\?\&]*)\/playlists\/([0-9]*)/,
embedUrl: 'https://music\.yandex\.ru/iframe/#playlist/<%= remote_id %>/show/cover/description/',
regex:
/https?:\/\/music\.yandex\.ru\/users\/([^\/\?\&]*)\/playlists\/([0-9]*)/,
embedUrl:
'https://music.yandex.ru/iframe/#playlist/<%= remote_id %>/show/cover/description/',
html: '<iframe frameborder="0" style="border:none;width:540px;height:400px;" width="540" height="400"></iframe>',
height: 400,
width: 540,
id: (ids) => ids.join('/'),
},
codepen: {
regex: /https?:\/\/codepen\.io\/([^\/\?\&]*)\/pen\/([^\/\?\&]*)/,
embedUrl: 'https://codepen.io/<%= remote_id %>?height=300&theme-id=0&default-tab=css,result&embed-version=2',
embedUrl:
'https://codepen.io/<%= remote_id %>?height=300&theme-id=0&default-tab=css,result&embed-version=2',
html: "<iframe height='300' scrolling='no' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'></iframe>",
height: 300,
width: 600,
Expand All @@ -137,15 +146,16 @@ const SERVICES: ServicesConfigType = {
html: '<iframe width="400" height="505" style="margin: 0 auto;" frameborder="0" scrolling="no" allowtransparency="true"></iframe>',
height: 505,
width: 400,
id: (groups: string[]) => groups?.[0]?.split("/")[0],
id: (groups: string[]) => groups?.[0]?.split('/')[0],
},
twitter: {
regex: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)/,
embedUrl: 'https://platform.twitter.com/embed/Tweet.html?id=<%= remote_id %>',
embedUrl:
'https://platform.twitter.com/embed/Tweet.html?id=<%= remote_id %>',
html: '<iframe width="600" height="600" style="margin: 0 auto;" frameborder="0" scrolling="no" allowtransparency="true"></iframe>',
height: 300,
width: 600,
id: ids => ids[1],
id: (ids) => ids[1],
},
reddit: {
regex: /https:\/\/www\.reddit\.com\/(.*)/,
Expand All @@ -166,15 +176,17 @@ const SERVICES: ServicesConfigType = {
},
facebook: {
regex: /https?:\/\/www.facebook.com\/([^\/\?\&]*)\/(.*)/,
embedUrl: 'https://www.facebook.com/plugins/post.php?href=https://www.facebook.com/<%= remote_id %>&width=500',
embedUrl:
'https://www.facebook.com/plugins/post.php?href=https://www.facebook.com/<%= remote_id %>&width=500',
html: "<iframe scrolling='no' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%; min-height: 500px; max-height: 1000px;'></iframe>",
id: (ids) => {
return ids.join('/');
},
},
aparat: {
regex: /(?:http[s]?:\/\/)?(?:www.)?aparat\.com\/v\/([^\/\?\&]+)\/?/,
embedUrl: 'https://www.aparat.com/video/video/embed/videohash/<%= remote_id %>/vt/frame',
embedUrl:
'https://www.aparat.com/video/video/embed/videohash/<%= remote_id %>/vt/frame',
html: '<iframe width="600" height="300" style="margin: 0 auto;" frameborder="0" scrolling="no" allowtransparency="true"></iframe>',
height: 300,
width: 600,
Expand All @@ -186,7 +198,8 @@ const SERVICES: ServicesConfigType = {
},
github: {
regex: /https?:\/\/gist.github.com\/([^\/\?\&]*)\/([^\/\?\&]*)/,
embedUrl: 'data:text/html;charset=utf-8,<head><base target="_blank" /></head><body><script src="https://gist.github.com/<%= remote_id %>" ></script></body>',
embedUrl:
'data:text/html;charset=utf-8,<head><base target="_blank" /></head><body><script src="https://gist.github.com/<%= remote_id %>" ></script></body>',
html: '<iframe width="100%" height="350" frameborder="0" style="margin: 0 auto;"></iframe>',
height: 300,
width: 600,
Expand Down
Loading