From ade5893183d32e516bc54535fe82b66795788731 Mon Sep 17 00:00:00 2001 From: kPherox Date: Sun, 14 Apr 2019 00:12:35 +0900 Subject: [PATCH 1/4] Unpack asar for itunes-nowplaying-mac --- app/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/package.json b/app/package.json index 0edca0d9..a3671c83 100644 --- a/app/package.json +++ b/app/package.json @@ -54,6 +54,9 @@ "build": { "productName": "TheDesk", "appId": "top.thedesk", + "asarUnpack": [ + "node_modules/itunes-nowplaying-mac" + ], "directories": { "output": "../build" }, From 5a03df6ee93713d76e8b76d9e3a2ebfc7c49561e Mon Sep 17 00:00:00 2001 From: kPherox Date: Sun, 14 Apr 2019 00:13:57 +0900 Subject: [PATCH 2/4] Change itunes-nowplaying-mac pull request number --- app/js/ui/spotify.js | 4 ++-- app/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/js/ui/spotify.js b/app/js/ui/spotify.js index 2bf196fd..a9bd9659 100644 --- a/app/js/ui/spotify.js +++ b/app/js/ui/spotify.js @@ -142,8 +142,8 @@ function nowplaying(mode){ media(arg.path,"image/png","new"); } }else if(platform=="darwin"){ - if(flag && arg.artworks[0]){ - ipc.send('bmp-image', [arg.artworks[0].path,0]); + if(flag && arg.existsArtwork){ + media(arg.artworks[0].data,"image/png","new"); } } var regExp = new RegExp("{song}", "g"); diff --git a/app/package.json b/app/package.json index a3671c83..a367a6e4 100644 --- a/app/package.json +++ b/app/package.json @@ -48,7 +48,7 @@ }, "optionalDependencies": { "nowplaying-node": "^0.1.3", - "itunes-nowplaying-mac": "git+https://github.com/rinsuki/itunes-nowplaying-mac#pull/1/head", + "itunes-nowplaying-mac": "git+https://github.com/rinsuki/itunes-nowplaying-mac#pull/4/head", "font-manager": "^0.3.0" }, "build": { From efac88db4c7c674638eaa3d8b62f3ff831463f2d Mon Sep 17 00:00:00 2001 From: kPherox Date: Sun, 14 Apr 2019 01:32:16 +0900 Subject: [PATCH 3/4] Change to pass error on itunes-np --- app/js/ui/spotify.js | 4 ++++ app/main/np.js | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/js/ui/spotify.js b/app/js/ui/spotify.js index a9bd9659..b40c46b5 100644 --- a/app/js/ui/spotify.js +++ b/app/js/ui/spotify.js @@ -129,6 +129,10 @@ function nowplaying(mode){ ipc.send('itunes', ""); ipc.once('itunes-np', function (event, arg) { + if (arg.cmd) { + console.error(arg); + return; + } console.log(arg); var content=localStorage.getItem("np-temp"); if(!content || content=="" || content=="null"){ diff --git a/app/main/np.js b/app/main/np.js index 31ad140b..352add5f 100644 --- a/app/main/np.js +++ b/app/main/np.js @@ -29,8 +29,9 @@ function np(mainWindow){ nowplaying.getRawData().then(function (value) { mainWindow.webContents.send('itunes-np', value); }).catch(function (error) { - // 非同期処理失敗。呼ばれない - console.log(error); + // エラーを返す + console.error(error); + mainWindow.webContents.send('itunes-np', error); }); }else{ var {NowPlaying,PlayerName} = require("nowplaying-node"); From cc20b0a7c0591afb0fe1e4cd8429b4071e273cd0 Mon Sep 17 00:00:00 2001 From: kPherox Date: Sun, 14 Apr 2019 01:33:00 +0900 Subject: [PATCH 4/4] Replace promise to async/await --- app/main/np.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/main/np.js b/app/main/np.js index 352add5f..43668da6 100644 --- a/app/main/np.js +++ b/app/main/np.js @@ -4,7 +4,7 @@ function np(mainWindow){ const app = electron.app; const fs = require("fs"); var ipc = electron.ipcMain; - ipc.on('itunes', (e, args) => { + ipc.on('itunes', async (e, args) => { //Verified on Windows console.log("Access"); if(args[0]=="set"){ @@ -25,14 +25,15 @@ function np(mainWindow){ var platform=process.platform; var bit=process.arch; if(platform=="darwin"){ - const nowplaying = require("itunes-nowplaying-mac") - nowplaying.getRawData().then(function (value) { + try { + const nowplaying = require("itunes-nowplaying-mac"); + const value = await nowplaying.getRawData(); mainWindow.webContents.send('itunes-np', value); - }).catch(function (error) { + } catch (error) { // エラーを返す console.error(error); mainWindow.webContents.send('itunes-np', error); - }); + } }else{ var {NowPlaying,PlayerName} = require("nowplaying-node"); var nppath=join(app.getPath("userData"), "nowplaying");