fix: fixed bugs in downloader (#1342)

This commit is contained in:
JellyBrick
2023-10-23 00:19:01 +09:00
committed by GitHub
parent fa4c69d228
commit 8a89bbccf7
2 changed files with 21 additions and 10 deletions

View File

@ -84,8 +84,8 @@ export const getCookieFromWindow = async (win: BrowserWindow) => {
url: 'https://music.youtube.com',
})
)
.map((it) => it.name + '=' + it.value + ';')
.join('');
.map((it) => it.name + '=' + it.value)
.join(';');
};
export default async (win_: BrowserWindow) => {
@ -450,12 +450,11 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
try {
givenUrl = new URL(givenUrl ?? '');
} catch {
return;
givenUrl = new URL(win.webContents.getURL());
}
const playlistId =
getPlaylistID(givenUrl) ||
getPlaylistID(new URL(win.webContents.getURL())) ||
getPlaylistID(new URL(playingUrl));
if (!playlistId) {
@ -604,7 +603,7 @@ function getFFmpegMetadataArgs(metadata: CustomSongInfo) {
// Playlist radio modifier needs to be cut from playlist ID
const INVALID_PLAYLIST_MODIFIER = 'RDAMPL';
const getPlaylistID = (aURL: URL) => {
const getPlaylistID = (aURL?: URL): string | null | undefined => {
const result =
aURL?.searchParams.get('list') || aURL?.searchParams.get('playlist');
if (result?.startsWith(INVALID_PLAYLIST_MODIFIER)) {