diff --git a/app/js/tl/src.js b/app/js/tl/src.js index e6bb93c4..cb4d5334 100644 --- a/app/js/tl/src.js +++ b/app/js/tl/src.js @@ -36,7 +36,7 @@ function src(mode, offset) { var user = $('#his-data').attr('user-id') } if (!mode) { - var start = 'https://' + domain + '/api/v2/search?q=' + q + add + var start = 'https://' + domain + '/api/v2/search?resolve=true&q=' + q + add } else { var start = 'https://' + domain + '/api/v1/search?q=' + q } diff --git a/app/main/np.js b/app/main/np.js index d8146de3..8275e9c4 100644 --- a/app/main/np.js +++ b/app/main/np.js @@ -1,36 +1,42 @@ function np(mainWindow) { - const electron = require("electron"); - const join = require('path').join; - const app = electron.app; - const fs = require("fs"); - var ipc = electron.ipcMain; - ipc.on('itunes', async (e, args) => { - //Verified on Windows - 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(); + const electron = require('electron') + const join = require('path').join + const app = electron.app + const fs = require('fs') + const fpath = join(app.getPath('userData'), 'npexec') + const npExec = fs.readFileSync(fpath, 'utf8') + const ipc = electron.ipcMain - const artwork = await nowplaying.getThumbnailBuffer(value.databaseID); - const base64 = artwork.toString('base64'); - value.artwork = base64 - e.sender.webContents.send('itunes-np', value); - } catch (error) { - // エラーを返す - console.error(error); - e.sender.webContents.send('itunes-np', error); - } - } else { - - } - } - - }); + const { exec } = require('child_process') + 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() + if(!value && npExec) { + exec(npExec, (error, stdout, stderr) => { + e.sender.webContents.send('itunes-np', stdout) + }) + } else { + const artwork = await nowplaying.getThumbnailBuffer(value.databaseID) + const base64 = artwork.toString('base64') + value.artwork = base64 + e.sender.webContents.send('itunes-np', value) + } + } catch (error) { + // エラーを返す + console.error(error) + e.sender.webContents.send('itunes-np', error) + } + } else { + } + } + }) + } -exports.TheDeskNowPlaying = np; \ No newline at end of file +exports.TheDeskNowPlaying = np