diff options
| author | Luis Ávila <[email protected]> | 2021-09-14 19:07:43 +0100 |
|---|---|---|
| committer | Luis Ávila <[email protected]> | 2021-09-14 19:07:43 +0100 |
| commit | e59db766946d7ec98638e3a05eeaa5d15b265381 (patch) | |
| tree | 20223c2aa049bc4a15bb047805164e7a17320e2d /src/services | |
| parent | 1212ffc102641127479f82f522395c46b74255d0 (diff) | |
| download | muse-e59db766946d7ec98638e3a05eeaa5d15b265381.tar.xz muse-e59db766946d7ec98638e3a05eeaa5d15b265381.zip | |
Fix URL cleaning: youtube IDs are not valid URLs
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/get-songs.ts | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/services/get-songs.ts b/src/services/get-songs.ts index 129f167..8a040c0 100644 --- a/src/services/get-songs.ts +++ b/src/services/get-songs.ts @@ -9,6 +9,7 @@ import pLimit from 'p-limit'; import shuffle from 'array-shuffle'; import {QueuedSong, QueuedPlaylist} from '../services/player'; import {TYPES} from '../types'; +import {cleanUrl} from '../utils/url'; @injectable() export default class { @@ -34,16 +35,7 @@ export default class { async youtubeVideo(url: string): Promise<QueuedSong|null> { try { - // Clean URL - const u = new URL(url); - - for (const [name] of u.searchParams) { - if (name !== 'v') { - u.searchParams.delete(name); - } - } - - const videoDetails = await this.youtube.videos.get(u.toString()); + const videoDetails = await this.youtube.videos.get(cleanUrl(url)); return { title: videoDetails.snippet.title, |
