fix metadata when downloading unplayed song

This commit is contained in:
Araxeus
2021-05-06 01:46:14 +03:00
parent d4811b7901
commit 844edbe2f4
3 changed files with 33 additions and 7 deletions

View File

@ -38,13 +38,18 @@ const baseUrl = defaultConfig.url;
// contextBridge.exposeInMainWorld("downloader", {
// download: () => {
global.download = () => {
let metadata;
let videoUrl = getSongMenu()
.querySelector("ytmusic-menu-navigation-item-renderer")
.querySelector("#navigation-endpoint")
.getAttribute("href");
videoUrl = !videoUrl
? global.songInfo.url || window.location.href
: baseUrl + "/" + videoUrl;
if (videoUrl) {
videoUrl = baseUrl + "/" + videoUrl;
metadata = null;
} else {
videoUrl = global.songInfo.url || window.location.href;
metadata = global.songInfo;
}
downloadVideoToMP3(
videoUrl,
@ -61,7 +66,7 @@ global.download = () => {
},
reinit,
pluginOptions,
global.songInfo
metadata
);
};
// });