mirror of
https://github.com/d-fi/d-fi-core.git
synced 2025-07-29 16:45:31 +02:00
match youtube short urls
This commit is contained in:
parent
38707163c7
commit
c6f3527fba
@ -43,7 +43,7 @@ export const getUrlParts = async (url: string, setToken = false): Promise<urlPar
|
|||||||
url = 'https://open.spotify.com/' + spotify[1] + '/' + spotify[2];
|
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) {
|
if (!site) {
|
||||||
throw new Error('Unknown URL: ' + url);
|
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};
|
return {type: 'youtube-track', id: yotubeId};
|
||||||
|
|
||||||
|
case 'youtu.be':
|
||||||
|
return {type: 'youtube-track', id: url.split('/').pop() as string};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error('Unable to parse URL: ' + url);
|
throw new Error('Unable to parse URL: ' + url);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user