Add macOS control center nowplaying
This commit is contained in:
parent
8c2d17d096
commit
57ca23e4e5
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -26,3 +26,9 @@ app/git
|
||||||
releasenote.md
|
releasenote.md
|
||||||
app/yarn-error.log
|
app/yarn-error.log
|
||||||
app/js/platform/aiscript.js
|
app/js/platform/aiscript.js
|
||||||
|
app/view/es-ES
|
||||||
|
app/view/es-FR
|
||||||
|
app/view/es-NO
|
||||||
|
app/view/es-CN
|
||||||
|
app/view/es-RU
|
||||||
|
app/view/es-TW
|
|
@ -155,6 +155,8 @@ function nowplaying(mode) {
|
||||||
}
|
}
|
||||||
} else if (mode == 'itunes') {
|
} else if (mode == 'itunes') {
|
||||||
postMessage(['itunes', ''], '*')
|
postMessage(['itunes', ''], '*')
|
||||||
|
} else if (mode == 'anynp') {
|
||||||
|
postMessage(['itunes', 'anynp'], '*')
|
||||||
} else if (mode == 'lastFm') {
|
} else if (mode == 'lastFm') {
|
||||||
var user = localStorage.getItem('lastFmUser')
|
var user = localStorage.getItem('lastFmUser')
|
||||||
var start = 'https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=' + user + '&limit=1&api_key=8f113803bfea951b6dde9e56d32458b2&format=json'
|
var start = 'https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=' + user + '&limit=1&api_key=8f113803bfea951b6dde9e56d32458b2&format=json'
|
||||||
|
@ -228,6 +230,16 @@ function nowplaying(mode) {
|
||||||
}
|
}
|
||||||
async function npCore(arg) {
|
async function npCore(arg) {
|
||||||
console.table(arg)
|
console.table(arg)
|
||||||
|
if(arg.anynp) {
|
||||||
|
var flag = localStorage.getItem('artwork')
|
||||||
|
var q = arg.title
|
||||||
|
if (flag && localStorage.getItem('complete-artwork')) {
|
||||||
|
aaw = await getUnknownAA(q)
|
||||||
|
postMessage(['bmpImage', [aaw.aaw, 0]], '*')
|
||||||
|
}
|
||||||
|
$('#textarea').val(q)
|
||||||
|
return false
|
||||||
|
}
|
||||||
var content = localStorage.getItem('np-temp')
|
var content = localStorage.getItem('np-temp')
|
||||||
if (!content || content == '' || content == 'null') {
|
if (!content || content == '' || content == 'null') {
|
||||||
var content = '#NowPlaying {song} / {album} / {artist}\n{url}'
|
var content = '#NowPlaying {song} / {album} / {artist}\n{url}'
|
||||||
|
|
|
@ -1,13 +1,24 @@
|
||||||
|
const { execSync } = require('child_process')
|
||||||
|
const { join } = require('path')
|
||||||
function np(mainWindow) {
|
function np(mainWindow) {
|
||||||
|
var platform = process.platform
|
||||||
|
if (platform !== 'darwin') return false
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const ipc = electron.ipcMain
|
const ipc = electron.ipcMain
|
||||||
ipc.on('itunes', async (e, args) => {
|
ipc.on('itunes', async (e, args) => {
|
||||||
console.log('Access')
|
console.log('Access')
|
||||||
if (args[0] == 'set') {
|
if (args == 'anynp') {
|
||||||
|
const dir = join(__dirname, "..", "main", "script", "macOSNP.scpt").replace("app.asar","app.asar.unpacked")
|
||||||
|
|
||||||
|
const stdout = execSync(`osascript ${dir}`).toString()
|
||||||
|
const title = stdout.substring(0, stdout.length - 100).match(/"(.+)?"/)[1].replace('\"','"')
|
||||||
|
const ret = {
|
||||||
|
title: title,
|
||||||
|
anynp: true
|
||||||
|
}
|
||||||
|
e.sender.webContents.send('itunes-np', ret)
|
||||||
} else {
|
} else {
|
||||||
var platform = process.platform
|
|
||||||
var bit = process.arch
|
|
||||||
if (platform == 'darwin') {
|
|
||||||
try {
|
try {
|
||||||
const nowplaying = require('itunes-nowplaying-mac')
|
const nowplaying = require('itunes-nowplaying-mac')
|
||||||
let value = await nowplaying()
|
let value = await nowplaying()
|
||||||
|
@ -27,8 +38,6 @@ function np(mainWindow) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
e.sender.webContents.send('itunes-np', error)
|
e.sender.webContents.send('itunes-np', error)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
BIN
app/main/script/macOSNP.applescript
Normal file
BIN
app/main/script/macOSNP.applescript
Normal file
Binary file not shown.
BIN
app/main/script/macOSNP.scpt
Normal file
BIN
app/main/script/macOSNP.scpt
Normal file
Binary file not shown.
|
@ -90,7 +90,8 @@
|
||||||
"productName": "TheDesk",
|
"productName": "TheDesk",
|
||||||
"appId": "top.thedesk",
|
"appId": "top.thedesk",
|
||||||
"asarUnpack": [
|
"asarUnpack": [
|
||||||
"node_modules/itunes-nowplaying-mac"
|
"node_modules/itunes-nowplaying-mac",
|
||||||
|
"main/script"
|
||||||
],
|
],
|
||||||
"directories": {
|
"directories": {
|
||||||
"output": "../build"
|
"output": "../build"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user