Skip to content

Commit a964d8a

Browse files
Support dropping YouTube music links into a playlist (#3116)
1 parent 6b21581 commit a964d8a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/sources/youtube/index.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,22 @@ function getStartTime(url: URL) {
2626
return seconds;
2727
}
2828

29+
const SHORT_HOSTNAMES = new Set([
30+
'youtu.be',
31+
'www.youtu.be',
32+
]);
33+
const LONG_HOSTNAMES = new Set([
34+
'youtube.com',
35+
'www.youtube.com',
36+
'music.youtube.com',
37+
]);
38+
2939
function fromMediaUrl(url: URL) {
3040
let sourceID;
31-
if (url.hostname === 'youtu.be' || url.hostname === 'www.youtu.be') {
41+
if (SHORT_HOSTNAMES.has(url.hostname)) {
3242
sourceID = url.pathname;
3343
}
34-
if ((url.hostname === 'youtube.com' || url.hostname === 'www.youtube.com') && url.pathname === '/watch') {
44+
if (LONG_HOSTNAMES.has(url.hostname) && url.pathname === '/watch') {
3545
sourceID = url.searchParams.get('v');
3646
}
3747

0 commit comments

Comments
 (0)