Skip to content

Commit

Permalink
fix: Trim new video formats names
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Sep 5, 2024
1 parent 6a5033a commit b48d452
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/transform/plugins/video/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export enum VideoService {
Vine = 'vine',
Prezi = 'prezi',
Osf = 'osf',
YandexVideo = 'yandexVideo',
VkVideo = 'vkVideo',
Yandex = 'yandex',
Vk = 'vk',
}

export const defaults: VideoFullOptions = {
Expand All @@ -20,6 +20,6 @@ export const defaults: VideoFullOptions = {
vine: {width: 600, height: 600, embed: 'simple'},
prezi: {width: 550, height: 400},
osf: {width: '100%', height: '100%'},
yandexVideo: {width: 640, height: 390},
vkVideo: {width: 640, height: 390},
yandex: {width: 640, height: 390},
vk: {width: 640, height: 390},
};
4 changes: 2 additions & 2 deletions src/transform/plugins/video/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Process @[vine](vineVideoID)
// Process @[prezi](preziID)
// Process @[osf](guid)
// Process @[yandexVideo](videoID)
// Process @[vkVideo](videoID)
// Process @[yandex](videoID)
// Process @[vk](videoID)

import type MarkdownIt from 'markdown-it';
// eslint-disable-next-line no-duplicate-imports
Expand Down
20 changes: 10 additions & 10 deletions src/transform/plugins/video/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export function mfrParser(url: string) {
return match ? match[1] : url;
}

const yandexVideoRegex = /^https:\/\/runtime.video.cloud.yandex.net\/player\/video\/([a-zA-Z0-9]+)/;
export function yandexVideoParser(url: string) {
const match = url.match(yandexVideoRegex);
const yandexRegex = /^https:\/\/runtime.video.cloud.yandex.net\/player\/video\/([a-zA-Z0-9]+)/;
export function yandexParser(url: string) {
const match = url.match(yandexRegex);
return match ? match[1] : url;
}

const vkVideoRegex = /^https:\/\/vk.com\/video_ext\.php?(oid=[-\d]+&id=[-\d]+)/;
export function vkVideoParser(url: string) {
const match = url.match(vkVideoRegex);
const vkRegex = /^https:\/\/vk.com\/video_ext\.php?(oid=[-\d]+&id=[-\d]+)/;
export function vkParser(url: string) {
const match = url.match(vkRegex);
return match ? match[1] : url;
}

Expand All @@ -64,11 +64,11 @@ export function parseVideoUrl(service: string, url: string): string | false {
case VideoService.Osf:
videoID = mfrParser(url);
break;
case VideoService.YandexVideo:
videoID = yandexVideoParser(url);
case VideoService.Yandex:
videoID = yandexParser(url);
break;
case VideoService.VkVideo:
videoID = vkVideoParser(url);
case VideoService.Vk:
videoID = vkParser(url);
break;
default:
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/transform/plugins/video/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export type VideoServicesOptions = {
[VideoService.Vine]: {width: number; height: number; embed: 'simple' | string};
[VideoService.Prezi]: {width: number; height: number};
[VideoService.Osf]: {width: string; height: string};
[VideoService.YandexVideo]: {width: number; height: number};
[VideoService.VkVideo]: {width: number; height: number};
[VideoService.Yandex]: {width: number; height: number};
[VideoService.Vk]: {width: number; height: number};
};

export type VideoFullOptions = VideoServicesOptions & {
Expand Down
4 changes: 2 additions & 2 deletions src/transform/plugins/video/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export const videoUrl: VideoUrlFn = (service, videoID, options) => {
);
case 'osf':
return `https://mfr.osf.io/render?url=https://osf.io/${videoID}/?action=download`;
case 'yandexVideo':
case 'yandex':
return `https://runtime.video.cloud.yandex.net/player/${videoID}`;
case 'vkVideo':
case 'vk':
return `https://vk.com/video_ext.php?${videoID}`;
default:
return service;
Expand Down

0 comments on commit b48d452

Please sign in to comment.