fix(plugins/music): spotify playlist mode

This commit is contained in:
lowlighter
2022-12-18 17:35:27 -05:00
parent 248ccb1237
commit b1d8d0c971

View File

@@ -124,14 +124,14 @@ export default async function({login, imports, data, q, account}, {enabled = fal
//Spotify //Spotify
case "spotify": { case "spotify": {
//Parse tracklist //Parse tracklist
await frame.waitForSelector("table") await frame.waitForSelector("ol")
tracks = [ tracks = [
...await frame.evaluate(() => ...await frame.evaluate(() =>
[...document.querySelectorAll("table tr")].map(tr => ({ [...document.querySelectorAll("ol li")].map(tr => ({
name: tr.querySelector("td:nth-child(2) div div:nth-child(1)").innerText, name: tr.querySelector("h3").innerText,
artist: tr.querySelector("td:nth-child(2) div div:nth-child(2)").innerText, artist: tr.querySelector("h4").innerText,
//Spotify doesn't provide artworks so we fallback on playlist artwork instead //Spotify doesn't provide artworks so we fallback on playlist artwork instead
artwork: window.getComputedStyle(document.querySelector("button[title=Play]")?.parentNode ?? document.querySelector("button").parentNode, null).backgroundImage.match(/^url\("(?<url>https:...+)"\)$/)?.groups?.url ?? null, artwork: window.getComputedStyle(document.querySelector("div[style^='--image-src:']") ?? null)?.backgroundImage.match(/^url\("(?<url>https:...+)"\)$/)?.groups?.url ?? null,
})) }))
), ),
] ]