diff options
| author | Max Isom <[email protected]> | 2021-09-14 09:42:45 -0400 |
|---|---|---|
| committer | Max Isom <[email protected]> | 2021-09-14 09:43:34 -0400 |
| commit | fcbff53a7a17e16adfd80cb0723273a17f473d2a (patch) | |
| tree | a70570755e54b9d1e63cd29c4f9cc4d3f2e3a434 | |
| parent | 4bce011b0cea52b0ed14a80beea9d0ddf0901e23 (diff) | |
| download | muse-fcbff53a7a17e16adfd80cb0723273a17f473d2a.tar.xz muse-fcbff53a7a17e16adfd80cb0723273a17f473d2a.zip | |
Clean URL search params
Closes #316
| -rw-r--r-- | package.json | 2 | ||||
| -rw-r--r-- | src/services/get-songs.ts | 11 | ||||
| -rw-r--r-- | yarn.lock | 11 |
3 files changed, 21 insertions, 3 deletions
diff --git a/package.json b/package.json index 2a0e0fc..d5f98f3 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,6 @@ "spotify-web-api-node": "^5.0.2", "sqlite3": "^5.0.2", "youtube.ts": "^0.2.0", - "ytdl-core": "^4.8.3" + "ytdl-core": "^4.9.1" } } diff --git a/src/services/get-songs.ts b/src/services/get-songs.ts index c7d37ea..129f167 100644 --- a/src/services/get-songs.ts +++ b/src/services/get-songs.ts @@ -34,7 +34,16 @@ export default class { async youtubeVideo(url: string): Promise<QueuedSong|null> { try { - const videoDetails = await this.youtube.videos.get(url); + // 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()); return { title: videoDetails.snippet.title, @@ -3295,7 +3295,7 @@ youtube.ts@^0.2.0: axios "^0.19.0" ytdl-core "^4.0.3" -ytdl-core@^4.0.3, ytdl-core@^4.8.3: +ytdl-core@^4.0.3: version "4.8.3" resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.8.3.tgz#21570d1834db13dec7828cf87bbf4c83c0fe68d7" integrity sha512-cWCBeX4FCgjcKmuVK384MT582RIAakpUSeMF/NPVmhO8cWiG+LeQLnBordvLolb0iXYzfUvalgmycYAE5Sy6Xw== @@ -3303,3 +3303,12 @@ ytdl-core@^4.0.3, ytdl-core@^4.8.3: m3u8stream "^0.8.3" miniget "^4.0.0" sax "^1.1.3" + +ytdl-core@^4.9.1: + version "4.9.1" + resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.9.1.tgz#f587e2bd8329b5133c0bac4ce5ee1f3c7a1175a9" + integrity sha512-6Jbp5RDhUEozlaJQAR+l8oV8AHsx3WUXxSyPxzE6wOIAaLql7Hjiy0ZM58wZoyj1YEenlEPjEqcJIjKYKxvHtQ== + dependencies: + m3u8stream "^0.8.3" + miniget "^4.0.0" + sax "^1.1.3" |
