match youtube short urls

This commit is contained in:
Sayem Chowdhury 2021-03-28 01:43:47 +06:00
parent 38707163c7
commit c6f3527fba

View File

@ -43,7 +43,7 @@ export const getUrlParts = async (url: string, setToken = false): Promise<urlPar
url = 'https://open.spotify.com/' + spotify[1] + '/' + spotify[2];
}
const site = url.match(/deezer|spotify|tidal|youtube/);
const site = url.match(/deezer|spotify|tidal|youtu\.?be/);
if (!site) {
throw new Error('Unknown URL: ' + url);
}
@ -71,6 +71,9 @@ export const getUrlParts = async (url: string, setToken = false): Promise<urlPar
}
return {type: 'youtube-track', id: yotubeId};
case 'youtu.be':
return {type: 'youtube-track', id: url.split('/').pop() as string};
default:
throw new Error('Unable to parse URL: ' + url);
}