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

Spotify #2

Open
ThatOneCalculator opened this issue Mar 24, 2020 · 6 comments
Open

Spotify #2

ThatOneCalculator opened this issue Mar 24, 2020 · 6 comments

Comments

@ThatOneCalculator
Copy link

How do I get a refresh token so the Spotify token doesn't expire?

@enkhee-Osiris
Copy link
Owner

hey @ThatOneCalculator, Actually I have no idea. I did this project for experiment.

@ThatOneCalculator
Copy link
Author

Gotcha. If I ever figure it out, I'll post it here.

@enkhee-Osiris
Copy link
Owner

Thanks man. I really appreciate it. Have a nice day

@ThatOneCalculator
Copy link
Author

ThatOneCalculator commented Apr 11, 2020

I figured it out! As it turns out, the Spotify API is actual bs, so I did the only sensible thing...

...cut it out entirely!

Turns out, AppleScript has a giant built in dictionary for accessing info about Spotify. How neat! I put this addition into Pecan bar, but it can super easily be replicated in your bar.

song.jsx:

const command = 'bash pecan/scripts/song';
const refreshFrequency = 500; //ms

let render = ({ output }) => {
	if (String(output).includes('No song playing')){
		return (<div></div>);
	}
	else{
		return (<div class='screen'><div class='pecansong'>{output}</div></div>);
	}
}

export { command, refreshFrequency, render };

song:

#!/pecan/scripts/song'

spotify=$(osascript -e 'if application "Spotify" is running then
	set myvar to "running"
end if')

if [ "$spotify" == "running" ]; then
	song=$(osascript -e 'tell application "Spotify"
    	set track_name to name of current track
		end tell')
	artist=$(osascript -e 'tell application "Spotify"
    	set track_artist to artist of current track
		end tell')
	echo "$song by $artist"
else
	echo "No song playing"
fi

@enkhee-Osiris
Copy link
Owner

@ThatOneCalculator Hey, thank you for your contribution. I will check and implement it in next monday. Currently I don't have any mac to test.

@ThatOneCalculator
Copy link
Author

@ThatOneCalculator Hey, thank you for your contribution. I will check and implement it in next monday. Currently I don't have any mac to test.

Is it next monday? 🙃

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