2019-05-19 17:39:30 +10:00
|
|
|
function np(mainWindow) {
|
2020-01-12 03:23:07 +11:00
|
|
|
const electron = require('electron')
|
|
|
|
const ipc = electron.ipcMain
|
|
|
|
ipc.on('itunes', async (e, args) => {
|
|
|
|
console.log('Access')
|
|
|
|
if (args[0] == 'set') {
|
|
|
|
} else {
|
|
|
|
var platform = process.platform
|
|
|
|
var bit = process.arch
|
|
|
|
if (platform == 'darwin') {
|
|
|
|
try {
|
|
|
|
const nowplaying = require('itunes-nowplaying-mac')
|
|
|
|
let value = await nowplaying()
|
2020-01-23 02:51:50 +11:00
|
|
|
try {
|
|
|
|
const artwork = await nowplaying.getThumbnailBuffer(value.databaseID)
|
|
|
|
if(artwork) {
|
|
|
|
const base64 = artwork.toString('base64')
|
|
|
|
value.artwork = base64
|
|
|
|
e.sender.webContents.send('itunes-np', value)
|
|
|
|
}
|
|
|
|
} catch (error) {
|
2020-01-23 02:53:35 +11:00
|
|
|
console.error(error)
|
2020-01-23 02:51:50 +11:00
|
|
|
e.sender.webContents.send('itunes-np', value)
|
2020-01-23 02:49:36 +11:00
|
|
|
}
|
2020-01-23 02:51:50 +11:00
|
|
|
|
2020-01-12 03:23:07 +11:00
|
|
|
} catch (error) {
|
2020-01-23 02:53:35 +11:00
|
|
|
console.error(error)
|
2020-04-07 16:53:53 +10:00
|
|
|
e.sender.webContents.send('itunes-np', error)
|
2020-01-12 03:23:07 +11:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
}
|
2020-01-13 00:49:52 +11:00
|
|
|
})
|
|
|
|
|
2019-04-03 14:59:29 +11:00
|
|
|
}
|
2020-01-12 03:23:07 +11:00
|
|
|
exports.TheDeskNowPlaying = np
|