diff --git a/lib/main.js b/lib/main.js index 4a24210..7502371 100644 --- a/lib/main.js +++ b/lib/main.js @@ -3,7 +3,7 @@ const QS = require('querystring'); const PARSE_ITEM = require('./parseItem.js'); const MINIGET = require('miniget'); -const YT_HOSTS = ['www.youtube.com', 'youtube.com', 'music.youtube.com']; +const YT_HOSTS = ['www.youtube.com', 'youtube.com', 'music.youtube.com', 'youtu.be']; const BASE_PLIST_URL = 'https://www.youtube.com/playlist?'; const BASE_API_URL = 'https://www.youtube.com/youtubei/v1/browse?key='; diff --git a/test/main-test.js b/test/main-test.js index a0d55a8..21857f0 100644 --- a/test/main-test.js +++ b/test/main-test.js @@ -396,11 +396,11 @@ describe('YTPL.getPlaylistID()', () => { ); }); - it('errors for youtu.be links', async() => { + it('errors for invalid youtu.be links', async() => { const ref = 'https://youtu.be/channel/whatever'; await ASSERT.rejects( YTPL.getPlaylistID(ref), - /not a known youtube link/, + /Unable to find a id in ./, ); }); @@ -487,6 +487,12 @@ describe('YTPL.getPlaylistID()', () => { const uploads = await YTPL.getPlaylistID(ref); ASSERT.equal(uploads, 'UUqwGaUvq_l0RKszeHhZ5leA'); }); + + it('resolves playlist from youtu.be share link', async() => { + const ref = 'https://youtu.be/hIaYzwf0A8A?list=PL37UZ2QfPUvyeqqNi4m_byAjAbSHBIosW'; + const playlist = await YTPL.getPlaylistID(ref); + ASSERT.equal(playlist, 'PL37UZ2QfPUvyeqqNi4m_byAjAbSHBIosW'); + }); }); describe('YTPL.validateID()', () => { @@ -572,4 +578,9 @@ describe('YTPL.validateID()', () => { const ref = 'https://www.youtube.com/watch?v=ASDF&list=UUqwGaUvq_l0RKszeHhZ5leA'; ASSERT.ok(YTPL.validateID(ref)); }); + + it('true for youtu.be share link', () => { + const ref = 'https://youtu.be/hIaYzwf0A8A?list=PL37UZ2QfPUvyeqqNi4m_byAjAbSHBIosW'; + ASSERT.ok(YTPL.validateID(ref)); + }); });