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

Music #2

Open
tanaynistala opened this issue Mar 23, 2020 · 1 comment
Open

Music #2

tanaynistala opened this issue Mar 23, 2020 · 1 comment

Comments

@tanaynistala
Copy link

Sorry if this is the wrong place to post this, but is there a way to pull music from the default Music app instead of Spotify?

@belmind
Copy link

belmind commented Mar 27, 2020

Sure! 👍🏼

If you take a look at index.jsx you have the following code:

# === SPOTIFY === #
# Uses <JSONQuote> to get around weird quote escape error
SPOTIFY=$(
	osascript -l JavaScript <<EOD | sed -e 's/<JSONQuote>/\"/g'
	
	if (Application('Spotify').running()) {
		var spotify = Application('Spotify')
		if (spotify.currentTrack() !== null) {
			
		var song = spotify.currentTrack().name().replace(/\"/g, "\\\'")
		var artist = spotify.currentTrack().artist().replace(/\"/g, "\\\'")
		var artwork = spotify.currentTrack().artworkUrl()
		var duration = spotify.currentTrack().duration()
		var position = spotify.playerPosition()
		var state = spotify.playerState()
		var shuffle = spotify.shuffling()
		var repeat = spotify.repeating()
		
		"{<JSONQuote>song<JSONQuote>: <JSONQuote>" + song + "<JSONQuote>, <JSONQuote>artist<JSONQuote>: <JSONQuote>" + artist + "<JSONQuote>, <JSONQuote>artwork<JSONQuote>: <JSONQuote>" + artwork + "<JSONQuote>, <JSONQuote>duration<JSONQuote>: <JSONQuote>" + duration + "<JSONQuote>, <JSONQuote>position<JSONQuote>: <JSONQuote>" + position + "<JSONQuote>, <JSONQuote>state<JSONQuote>: <JSONQuote>" + state + "<JSONQuote>, <JSONQuote>repeat<JSONQuote>: <JSONQuote>" + repeat + "<JSONQuote>, <JSONQuote>shuffle<JSONQuote>: <JSONQuote>" + shuffle + "<JSONQuote>}"
		} else {
			"{}"
		}
	} else {
		"{}"
	}
EOD
)

Here is a link for osascript!
Try to find a way to do the same thing but for Music.app.
Good luck!

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

2 participants