Internal Server Error when running on macOS 10.12 Sierra
deftdawg opened this issue · 4 comments
I'm able to hit the basic page at 8181 and see the API commands, http://localhost:8181/artwork works, however all other functions such as now_playing and airplay devices give "internal server error"
(I also changed all the ' to " except for the logFormat because the quote escaping in the logs was making my head explode lol)
:~/source/itunes-api$ script/server
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
'[2016-09-27T11:30:34.384Z] - ::1 - GET /artwork 200 204.778 ms - 34806b'
'[2016-09-27T11:30:47.957Z] - ::1 - GET /airplay_devices 500 145.547 ms - 21b'
{ [Error: Command failed: /bin/sh -c osascript -l JavaScript -e 'var old = console.log; console.log = function () { Array.prototype.unshift.call(arguments, "<brandonhorst:node-osa>"); Array.prototype.push.call(arguments, "</brandonhorst:node-osa>"); old.apply(console, arguments); }; JSON.stringify((function getCurrentState(){ itunes = Application("iTunes"); playerState = itunes.playerState(); currentState = {}; currentState["player_state"] = playerState; if (playerState != "stopped") { currentTrack = itunes.currentTrack; currentPlaylist = itunes.currentPlaylist; currentState["id"] = currentTrack.persistentID(); currentState["name"] = currentTrack.name(); currentState["artist"] = currentTrack.artist(); currentState["album"] = currentTrack.album(); currentState["playlist"] = currentPlaylist.name(); currentState["volume"] = itunes.soundVolume(); currentState["muted"] = itunes.mute(); if (currentTrack.year()) { currentState["album"] += " (" + currentTrack.year() + ")"; } } return currentState;})());'
0:990: execution error: Error on line 1: Error: Application isn't running. (-600)
]
killed: false,
code: 1,
signal: null,
cmd: '/bin/sh -c osascript -l JavaScript -e \'var old = console.log; console.log = function () { Array.prototype.unshift.call(arguments, "<brandonhorst:node-osa>"); Array.prototype.push.call(arguments, "</brandonhorst:node-osa>"); old.apply(console, arguments); }; JSON.stringify((function getCurrentState(){ itunes = Application("iTunes"); playerState = itunes.playerState(); currentState = {}; currentState["player_state"] = playerState; if (playerState != "stopped") { currentTrack = itunes.currentTrack; currentPlaylist = itunes.currentPlaylist; currentState["id"] = currentTrack.persistentID(); currentState["name"] = currentTrack.name(); currentState["artist"] = currentTrack.artist(); currentState["album"] = currentTrack.album(); currentState["playlist"] = currentPlaylist.name(); currentState["volume"] = itunes.soundVolume(); currentState["muted"] = itunes.mute(); if (currentTrack.year()) { currentState["album"] += " (" + currentTrack.year() + ")"; } } return currentState;})());\'' }
Edit: changed title of Issue to reflect actual issue.
I just tried it out. It looks like this is a macOS 10.12 Sierra thing, not an iTunes 12.5.1 thing. I tried on 10.11 with 12.5.1 and it works fine.
It looks like something to do with how osascript has changed on 10.12. I'll take a look soon.
I've edited the title to reflect the actual issue.
Any updates on this?
This seems to be working now. Please open a new Issue if you see something else.