r/PowerShell • • Jan 26 '18

Script Sharing ps-spotify - control Spotify from PowerShell

http://github.com/bmsimons/ps-spotify
128 Upvotes

32 comments sorted by

3

u/[deleted] Jan 26 '18

I use this everyday. I couldn’t find an iOS app that would play Spotify as an alarm so I used this to make an alarm together with Task Scheduler. The only draw back is that you have to have Spotify running on a device so it won’t remotely open it. Of course it couldn’t but it’d be nice if it did.

Thanks 🙏 to OP if you’re the creator!

2

u/bmsimons Jan 26 '18

Thanks for the support! Yes, I actually am the creator ;)

1

u/[deleted] Jan 26 '18

It was also inspiration for a website I made. It’s not using PowerShell anymore but using the same API. play me a song

2

u/dr4kun Jan 26 '18

Thank you for sharing!

Would you be able to provide additional details on filling in the required fields in the .psm1 module file? In particular:

  • is going through Git and cloning of Git repositories necessary, or would downloading the files and installing them as per regular PowerShell module suffice? My guess is that PowerShell is enough;

  • based on PowerShell alone, i'm trying to get the BasicBearer, RefreshToken, and AccessToken for the module file; i've created a new app in the Spotify for developers web dashboard and followed your instructions, but i've had trouble using the correct data for the correct field.

In particular - i have the following data:

  • Client ID;

  • Client Secret;

How do they translate into BasicBearer / RefreshToken / AccessToken?

Or do i need to authenticate using SpotifyController.cs for authentication first, and only then the module would work at all?

Any step-by-step advise for Git-illiterate person who does know a fair bit of PowerShell and would love a PoSH-based Spotify client would be much appreciated.

1

u/bmsimons Jan 26 '18

Downloading the module as a zip file from GitHub should be perfectly fine. I am also considering to make a screencast to demonstrate the workflow to ease things up a little bit. I am also thinking about including the base64 bearer (client_id:client_secret) within the returned JSON from my dotnet webapp to make things somewhat easier.

0

u/[deleted] Jan 26 '18

[deleted]

1

u/dr4kun Jan 26 '18

Thank you, will give it a go!

2

u/_Slusho_ Jan 26 '18

Great work! Do I have to be a Spotify paying subscriber to get this working?

1

u/bmsimons Jan 26 '18

Only for the Spotify connect functionality I believe. I’m not 100% sure tho

1

u/_Slusho_ Jan 27 '18

I got it all set up and I cannot play any music. I get this error:

Invoke-RestMethod : {
  "error" : {
    "status" : 403,
    "message" : "Not available for the current user"
  }
}

I miss playing soma.fm through the console on Linux. I was hoping this could fill the void. I could just pay for Spotify but I'm cheap.

23

u/RubiksGamer Jan 26 '18

Pls don't hate on me, but why would you want it?

49

u/BrownNote Jan 26 '18

MUST. AUTOMATE. EVERYTHING.

0

u/[deleted] Jan 26 '18

[deleted]

4

u/admiralspark Jan 26 '18

You're doing the Bot's work, son.

14

u/ReelAwesome Jan 26 '18

detect a crash of some monitored process

play: As the World Falls Down by David Bowie

systems back up

play: Happy by Ferrel

1

u/ThePegasi Jan 26 '18

Run CCleaner

Play: When I'm Cleaning Windows by George Formby

7

u/danekan Jan 26 '18

...maybe it actually works... the frontend client is shit

5

u/codekaizen Jan 26 '18

To turn my Raspberry Pi 3 running Win10 IoT into an internet radio in about 3 minutes?

2

u/[deleted] Jan 26 '18

Doing anything from a command lines is always cool. 😎

9

u/doomjuice Jan 26 '18

Hey, I'm gonna download it just to find out how it works and that's a win I'd say, so thanks OP. Cool project!

edit: It looks like his site has a good amount of detail (not just on this project) and nicely laid out. Good stuff.

1

u/Unt4medGumyBear Oct 20 '22

absolute banger of a comment

7

u/SaltyPeaches Jan 26 '18

I never knew I wanted this. But I do most of my things from the console these days, and I listen to Spotify all day at work. This will be neat to try out!

5

u/VapingSwede Jan 26 '18

I already made our monitoring screen to tell us the error with the dot net speech synthesis. I could se this changing my spotify to some boss fight music if a sev1 would occur :3

Great job, thanks for sharing!

4

u/Tethylis Jan 26 '18

This is really neat! Thanks for sharing.

5

u/mini4x Jan 26 '18

Fixed a problem that didn't need fixing.

5

u/Fir3start3r Jan 26 '18

...some things don't need to be broken to have fun :)

3

u/[deleted] Jan 26 '18

There was no problem to fix. It’s cool functionality to play around with if you like tinkering with this stuff and he lowered the barrier of entry getting to the cool moment when you punch in a command to PowerShell then your stereo on the other side of the room fires up.

1

u/haleym Jan 26 '18

Disagree, Spotify desktop client is bloated/awful. I’m going to use this as the base for a simple little player UI that can sit in the corner of my desktop and show basic song info/controls.

3

u/mini4x Jan 26 '18

WINAMP. Kicks the llamas ass.

2

u/itmonkey78 Jan 26 '18

Share when you're finished. A mini HTML5 player is something I miss from using Grooveshark all those years ago.

1

u/Fir3start3r Jan 26 '18

Feature Request
A command to clear the cache

Thanks!

0

u/[deleted] Jan 26 '18

[deleted]

1

u/bmsimons Jan 26 '18

Great to hear that you enjoy it!