Add: #208 Apple Music artwork request
This commit is contained in:
parent
429a5c764f
commit
50a2ce1470
|
@ -124,7 +124,7 @@ function nowplaying(mode) {
|
||||||
postMessage(["itunes", ""], "*");
|
postMessage(["itunes", ""], "*");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function npCore(arg) {
|
async function npCore(arg) {
|
||||||
console.table(arg);
|
console.table(arg);
|
||||||
var content = localStorage.getItem("np-temp");
|
var content = localStorage.getItem("np-temp");
|
||||||
if (!content || content == "" || content == "null") {
|
if (!content || content == "" || content == "null") {
|
||||||
|
@ -139,6 +139,9 @@ function npCore(arg) {
|
||||||
} else if (platform == "darwin") {
|
} else if (platform == "darwin") {
|
||||||
if (flag && arg.artwork) {
|
if (flag && arg.artwork) {
|
||||||
media(arg.artwork, "image/png", "new");
|
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");
|
var regExp = new RegExp("{song}", "g");
|
||||||
|
@ -183,3 +186,15 @@ if (location.search) {
|
||||||
} else {
|
} 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
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
let ver = '20.2.1 (Kawaii)'
|
let ver = '20.2.0 (Kawaii)'
|
||||||
if (process.argv.indexOf('--automatic') === -1) {
|
if (process.argv.indexOf('--automatic') === -1) {
|
||||||
let input = require('readline-sync').question('version string [empty: ' + ver + ' (default)]? ')
|
let input = require('readline-sync').question('version string [empty: ' + ver + ' (default)]? ')
|
||||||
if (input) {
|
if (input) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user