Add: #208 Apple Music artwork request

This commit is contained in:
cutls 2020-04-07 14:40:27 +09:00
parent 429a5c764f
commit 50a2ce1470
2 changed files with 17 additions and 2 deletions

View File

@ -124,7 +124,7 @@ function nowplaying(mode) {
postMessage(["itunes", ""], "*");
}
}
function npCore(arg) {
async function npCore(arg) {
console.table(arg);
var content = localStorage.getItem("np-temp");
if (!content || content == "" || content == "null") {
@ -139,6 +139,9 @@ function npCore(arg) {
} else if (platform == "darwin") {
if (flag && arg.artwork) {
media(arg.artwork, "image/png", "new");
} else if (flag) {
var q = arg.artist + ' ' + arg.album.name + ' ' + arg.name
postMessage(["bmpImage", [await getUnknownAA(q), 0]], "*");
}
}
var regExp = new RegExp("{song}", "g");
@ -183,3 +186,15 @@ if (location.search) {
} else {
}
}
async function getUnknownAA(q) {
const start = 'https://itunes.apple.com/search?term=' + q + '&country=JP&entity=song'
let promise = await fetch(start, {
method: 'GET'
})
const json = await promise.json()
if(!json.resultCount) {
return []
}
const data = json.results
return data[0].artworkUrl100
}

View File

@ -1,4 +1,4 @@
let ver = '20.2.1 (Kawaii)'
let ver = '20.2.0 (Kawaii)'
if (process.argv.indexOf('--automatic') === -1) {
let input = require('readline-sync').question('version string [empty: ' + ver + ' (default)]? ')
if (input) {