1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

fixed youtube thumbs

This commit is contained in:
Fedor Katurov 2019-11-27 10:46:33 +07:00
parent aaa8eb5275
commit 45f7c70f83
3 changed files with 13 additions and 20 deletions

View file

@ -139,4 +139,12 @@ export const getYoutubeTitle = async (id: string) => {
Axios.get(`http://youtube.com/get_video_info?video_id=${id}`).then(console.log);
};
(<any>window).getYoutubeTitle = getYoutubeTitle;
export const getYoutubeThumb = (url: string) => {
const match =
url &&
url.match(
/http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?/
);
return match && match[1] ? `https://i.ytimg.com/vi/${match[1]}/hq720.jpg` : null;
};