Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing on macOS Catalina #42

Open
phubbard opened this issue Nov 28, 2019 · 13 comments
Open

Failing on macOS Catalina #42

phubbard opened this issue Nov 28, 2019 · 13 comments

Comments

@phubbard
Copy link

No description provided.

@phubbard
Copy link
Author

Upgraded to latest MacOS and getting errors - looks like it can't find osascript maybe? Here's a log:

 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
Error: Command failed: 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();    currentState['\''repeat'\''] = itunes.songRepeat();    currentState['\''shuffle'\''] = itunes.shuffleEnabled() && itunes.shuffleMode();    if (currentTrack.year()) {      currentState['\''album'\''] += " (" + currentTrack.year() + ")";    }  }  return currentState;})());'
0:1117: execution error: Error on line 1: Error: Application can't be found. (-2700)

    at ChildProcess.exithandler (child_process.js:295:12)
    at ChildProcess.emit (events.js:203:13)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
  killed: false,
  code: 1,
  signal: null,
  cmd: `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();    currentState['\\''repeat'\\''] = itunes.songRepeat();    currentState['\\''shuffle'\\''] = itunes.shuffleEnabled() && itunes.shuffleMode();    if (currentTrack.year()) {      currentState['\\''album'\\''] += " (" + currentTrack.year() + ")";    }  }  return currentState;})());'`
}
'[2019-11-28T16:30:15.055Z] - ::ffff:204.128.136.216 - GET /now_playing 500 67.566 ms - 21b'

@peterson79
Copy link

Still an issue, it looks like it is a problem with the "osa" package. Did you ever figure it out?

@Gearlux
Copy link

Gearlux commented Mar 22, 2020

Catalina changed the application name from 'iTunes' to 'Music'.
You have to change all occurrences of Application('iTunes') to Application('Music')

Here's how to find all occurrences in a Mac Terminal:
find . -name "*.js" -exec grep -H "Application('iTunes')" {} ;

@scstraus
Copy link

@Gearlux Are you able to successfully control the new Apple Music app with it once you make these changes?

@Gearlux
Copy link

Gearlux commented May 17, 2020 via email

@scstraus
Copy link

Great, thanks so much for that confirmation. It was one of the main things holding me back from upgrading. So no issues whatsoever? TBH I'm really surprised, I thought Apple would throw out that baby with the iTunes bathwater ;-).

@Gearlux
Copy link

Gearlux commented May 19, 2020 via email

@kcossabo
Copy link

after installing this on Catalina I used Retroactive to reinstall iTunes......

It works fine, there are two apps on the Mac mini 'Music' and 'iTunes'

I have Home Assitant (HASS.IO) using this REST API to control "iTunes" on Catalina.

I had issues installing this API, but after I got it working, and using retroactive to reinstall it worked well..


the issues I hit;

sudo npm install forever -g
  • script/bootstrap ran with error
sudo chown -R $USER:$(id -gn $USER) /Users/{userID}/.config
  • replacing {userID} with your userid, then re-ran the bootstrap worked.
  • then installed the above retroactive
  • then tested
curl -X PUT http://10.10.10.3:8181/playlists/vinal-recordings-my-fav/play
curl -X PUT http://10.10.10.3:8181/pause

then set up an Automator script to start the server on reboot

@SdeGeata
Copy link

SdeGeata commented Mar 7, 2021

Hello!

So I just upgraded to Catalina in order to install the Home Assistant app on my Macbook. Now the api isn't working anymore. I tried find . -name "*.js" -exec grep -H "Application('iTunes')" {} ; with Terminal to find the iTunes occurrences, but I am getting this error message:

StiofansMacBookPro:~ stiofandegeata$ find . -name "*.js" -exec grep -H "Application('iTunes')" {} ; find: -exec: no terminating ";" or "+"

What do I do?

@kcossabo
Copy link

kcossabo commented Mar 7, 2021

Hello!

So I just upgraded to Catalina in order to install the Home Assistant app on my Macbook. Now the api isn't working anymore. I tried find . -name "*.js" -exec grep -H "Application('iTunes')" {} ; with Terminal to find the iTunes occurrences, but I am getting this error message:

StiofansMacBookPro:~ stiofandegeata$ find . -name "*.js" -exec grep -H "Application('iTunes')" {} ; find: -exec: no terminating ";" or "+"

What do I do?

What did you upgrade from? MUSIC is the replacement for iTunes. If you have not reinstalled iTunes, then you will need to via Retroactive (See above)

@SdeGeata
Copy link

SdeGeata commented Mar 8, 2021

Hello @kcossabo!

Thanks for your reply, I ended up just solving the issue a few minutes ago.

To answer your question though, I upgraded from 10.14.6 Mojave, so yes, iTunes was replaced by Music. I couldn't get that command line script to work to show me what to modify in the references to "application(iTunes)" so I ended up doing a global find with Nova. That worked, but the modifications didn't work anyhow.

I ended up finding a pull request that was modified for Music, I downloaded that one and all is well now! I've got Music up and running in my Home Assistant dashboard, album art and all.

That pull is here, in case anyone else has the same issue I had:
https://github.com/DrMachin/itunes-api

@kcossabo
Copy link

kcossabo commented Mar 8, 2021

That pull is here, in case anyone else has the same issue I had:
https://github.com/DrMachin/itunes-api

@SdeGeata YOU ROCK! Thank You, I will update to that version!!!

@SdeGeata
Copy link

SdeGeata commented Mar 8, 2021

That pull is here, in case anyone else has the same issue I had:
https://github.com/DrMachin/itunes-api

@SdeGeata YOU ROCK! Thank You, I will update to that version!!!

I’d say DrMachin rocks, he’s the guy that put all the work in to fix this thing - i only stumbled across it... but hey, glad it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants