mybar icon indicating copy to clipboard operation
mybar copied to clipboard

Music

Open tanaynistala opened this issue 5 years ago • 1 comments

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?

tanaynistala avatar Mar 23 '20 14:03 tanaynistala

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!

belmind avatar Mar 27 '20 22:03 belmind