Clean URL search params

Closes #316
This commit is contained in:
Max Isom 2021-09-14 09:42:45 -04:00
parent 4bce011b0c
commit fcbff53a7a
No known key found for this signature in database
GPG key ID: 25C9B1A7F6798880
3 changed files with 21 additions and 3 deletions

View file

@ -90,6 +90,6 @@
"spotify-web-api-node": "^5.0.2", "spotify-web-api-node": "^5.0.2",
"sqlite3": "^5.0.2", "sqlite3": "^5.0.2",
"youtube.ts": "^0.2.0", "youtube.ts": "^0.2.0",
"ytdl-core": "^4.8.3" "ytdl-core": "^4.9.1"
} }
} }

View file

@ -34,7 +34,16 @@ export default class {
async youtubeVideo(url: string): Promise<QueuedSong|null> { async youtubeVideo(url: string): Promise<QueuedSong|null> {
try { 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 { return {
title: videoDetails.snippet.title, title: videoDetails.snippet.title,

View file

@ -3295,7 +3295,7 @@ youtube.ts@^0.2.0:
axios "^0.19.0" axios "^0.19.0"
ytdl-core "^4.0.3" ytdl-core "^4.0.3"
ytdl-core@^4.0.3, ytdl-core@^4.8.3: ytdl-core@^4.0.3:
version "4.8.3" version "4.8.3"
resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.8.3.tgz#21570d1834db13dec7828cf87bbf4c83c0fe68d7" resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.8.3.tgz#21570d1834db13dec7828cf87bbf4c83c0fe68d7"
integrity sha512-cWCBeX4FCgjcKmuVK384MT582RIAakpUSeMF/NPVmhO8cWiG+LeQLnBordvLolb0iXYzfUvalgmycYAE5Sy6Xw== integrity sha512-cWCBeX4FCgjcKmuVK384MT582RIAakpUSeMF/NPVmhO8cWiG+LeQLnBordvLolb0iXYzfUvalgmycYAE5Sy6Xw==
@ -3303,3 +3303,12 @@ ytdl-core@^4.0.3, ytdl-core@^4.8.3:
m3u8stream "^0.8.3" m3u8stream "^0.8.3"
miniget "^4.0.0" miniget "^4.0.0"
sax "^1.1.3" 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"