Git Product home page Git Product logo

spotify.ahk's People

Contributors

cloakersmoker avatar jnllnd avatar joedf avatar masonjar13 avatar zachingle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spotify.ahk's Issues

Spotify.ahk throws 404 error if spotify hasn't played anything before use

Hey!

Love your script/API for Spotify! Been using it a lot.

I have noticed something though.
The API throws 404 errors when you do
Spoofy.Player.LastTrack(),
Spoofy.Player.PlayPause()
and Spoofy.Player.NextTrack()
if you use them before Spotify have played something.

In other words:

  1. Open spotify
  2. Use one of the above functions (it is possible the same applies to the other functions, but I haven't tested them).
  3. The API will throw the below error.

And the error is not thrown when you do this:

  1. Open spotify
  2. Make spotify play something (using the Spotify app).
  3. The functions work, and no errors are thrown.
---------------------------
SpotifyShortcuts.ahk
---------------------------
Error in #include file "[PATH]\Spotify.ahk":
     404 not 2xx for request "PUT:https://api.spotify.com/v1/me/player/pause".

	Line#
	173: For index,SubHeaderArray in HeaderArray
	173: {
	174: SpotifyWinHttp.SetRequestHeader(SubHeaderArray[1], SubHeaderArray[2])  
	175: }
	177: SpotifyWinHttp.Send(body)  
	179: if (SpotifyWinHttp.Status > 299 && !noErr)  
	179: {
--->	180: Throw,{message: SpotifyWinHttp.Status . " not 2xx for request """ . method . ":" . url . """.", what: "HTTP response code not 2xx", file: A_LineFile, line: A_LineNumber}
	181: }
	183: Return,SpotifyWinHttp.ResponseText
	184: }
	188: {
	189: res.SetBodyText("Page not found")  
	190: }
	191: {

The current thread will exit.
---------------------------
OK   
---------------------------

Unable to connect localhost

Hey.

Recently the script stopped working for me after I changed my graphics card. I uninstall every graphics drivers with DDU before I installed the new VGA.
No idea if it has to do with it at all.

It's constantly eating 20-25% of my CPU, probably stuck in the background.

  • Firewall is turned off,
  • Deleted registry key

I appreciate any help!
image

Spotify authorization page not opening automatically

The Spotify authorization page does not open when I create a Spotify object, not even with an unmodified version of Example Hotkeys.ahk. This has led to my not being able to use any hotkeys for Spotify. I have tried going to the link directly from the source code, but, even though everything seems to authorize fine then, Spotify.ahk still does not work.

Spotify version: 1.0.91.183.g259b84fa (Windows Store version)
AutoHotkey version: 1.1.30.00
Operating System: Windows 10 Home 64-bit Version 1803 (OS Build 17134.345)

I have had the same results on a build from around a week ago and the latest one as of the time of my writing this. Windows, AutoHotkey, and Spotify are all up-to-date.

Add support for positions in RemoveTrack()

Hey,

Could you look into adding positions in the RemoveTrack() and AddTrack() and potentially other functions where that is relevant/available, but especially the RemoveTrack function?

I have tested positions using Spotify API console, and it works. Positions is the position of the trac in the playlist counting from 0.
https://developer.spotify.com/console/delete-playlist-tracks/

I'm asking for this as it gives me the ability to remove one occurrence of a track rather than all of them from a playlist.

Thanks in advance.

Error in Line 204 of Spotify.ahk

Hello!
btw im a "newbie" in AHK so sorry in case my report is stupid. When i try to play a Playlist in spotify i get the message that there is a error in Line 204 in the spotify.ahk (i uploadet the error popup)

here is the code with i call the function:

`
1B07: ; I call the function with a gui button

Spoofy := new Spotify()

1Playlist := Spoofy.Playlists.GetPlaylist(6JcjkR4UtyOGaR8RRp2xxx)

1Playlist.Play()
return
`

The #Include Spotify.ahk is in one of the first lines of my scribt.

So is that a problem with the Spotify.ahk or is the problem me?

Unbenannt

Error 400 when opening example hotkeys for the first time

When I run Example Hotkeys.ahk for the first time to get the prompt to authorize the app, all I get is this

I've googled for over 2 hours now to try and fix this, and I'm slowly losing my mind here. Not very savvy with this API auth token thing.

Negative volume

The user can make the volume percentage go negative. This causes the script to throw an error.
image

As you can see the volume percentage passed to the API is a negative value. This can easily be fixed by modifying 'Example Hotkeys.ahk' like this:

F1::
if(VolumePercentage - 1 > 0) ; Don't allow volume percentage to go negative
	VolumePercentage--
spoofy.Player.SetVolume(VolumePercentage) ; Decrement the volume percentage and set the player to the new volume percentage
return

Error in line 124 of spotify.ahk

image
I am running a fresh install of this. I tried it about 8 hours ago and it was working fine, then I wake up this morning to see this? I have tried to remove the app from my spotify account to hopefully get it to re-auth but just this error.

Way to manually connect to a device

Tl;dr: when spotify opens for the first time it isn't playing anything therefore it is "not connected to a device" therefore I can't change the sound volume etc. A work around I've found to use is to manually send a Media_Next & Media_Prev to catch onto the app player since it starts playback by default when skipping a track and allows spotify.ahk to hook onto it. This allows me to use the commands on spotify's startup like 90% of the time but I've come to realize that if enough time has passed since the last time you opened spotify (I usually always keep it open) it doesn't even have a song to skip ie.
image

So my question basically is, is there a way to manually connect to a device via the api or something? Ot really would only save me like 2 clicks but for an otherwise fully automated experience it's kind of annoying haha. Cheers in advance

Bad Request Https error

Bad Request
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

i get this now when trying to identify.
if i change spotify.ahk to have https in the url for localhost it gives bad uri

Add License?

Hoping to use this library in another open source project; would appreciate if it had a license on it! Ideally MIT or GNU GPLv3. I'm happy to make a PR for it if there's one you're leaning towards.

If it helps: https://choosealicense.com/

PREMIUM_REQUIRED: Player command failed: Premium required

Hey,

It looks like something Spotify has done recently broke most of Spotify.ahk.

I keep getting Premium required errors, and some stuff simply doesn't work (such as info like Track name, album name etc. in GetCurrentPlaybackInfo).

And yes, I do have Spotify Premium.

I have made some quick additions to your example code to add stuff like Previous and next song, playback info etc.

Example code

The F and Media shortcuts all gives the premium required error, the F6 does not give an error, but it doesn't give any information about name, album or progress.

Show/Hide Script Example
#Persistent
#SingleInstance, Force

#Include %A_ScriptDir%
#Include Spotify.ahk
global VolumePercentage
global ShuffleMode
global RepeatMode := 0
spoofy := new Spotify
VolumePercentage := spoofy.Player.GetCurrentPlaybackInfo().Device.Volume
return

F1::
if(VolumePercentage - 1 > 0)
  VolumePercentage--
spoofy.Player.SetVolume(VolumePercentage) ; Decrement the volume percentage and set the player to the new volume percentage
return

F2::
VolumePercentage++
spoofy.Player.SetVolume(VolumePercentage) ; Increment the volume percentage and set the player to the new volume percentage
return 

F3::
ShuffleMode := !ShuffleMode
spoofy.Player.SetShuffle(ShuffleMode) ; Swap the shuffle mode of the player
return 

F4::
RepeatMode := RepeatMode + (RepeatMode = 0 ? 1 : (RepeatMode = 1 ? 1 : (RepeatMode = 2 ? 1 : -2)))
spoofy.Player.SetRepeatMode(RepeatMode) ; Cycle through the three repeat modes (1-2, 2-3, 3-1)
return 

F6::
spoofy := new Spotify
CurrentPlayback := Spoofy.Player.GetCurrentPlaybackInfo()
Track_Name := CurrentPlayback.Track.Name	
Album_Name := CurrentPlayback.Track.Album.Name	
Track_Duration := MariusAPI_FormatSeconds(Round(CurrentPlayback.Track.Duration / 1000))
Track_Artist_Main := CurrentPlayback.Track.Artists[1].Name
Track_Progress := MariusAPI_FormatSeconds(Round(CurrentPlayback.Progress_ms / 1000))
Message = 
  ( Join`r`n LTrim
    Track Name: %Track_Name% 
    Progress: %Track_Progress% / %Track_Duration%

    Album: %Album_Name% 
  )
MsgBox, %Message%
return 

Media_Prev::
  Spoofy.Player.LastTrack()
return 

Media_Play_Pause::
  Spoofy.Player.PlayPause()
return 

Media_Next::
  Spoofy.Player.NextTrack()
return 

It wasn't until recently that the errors started on stuff that worked fine before.

Show/Hide Code Error
---------------------------
Spotify Example Hotkeys.ahk
---------------------------
Error in #include file ".....\Spotify.ahk":
   PREMIUM_REQUIRED: Player command failed: Premium required

  Line#
  196: }
  198: ErrorMessage .= ErrorObject.Message  
  199: }
  200: Else
  200: {
  201: ErrorMessage := SpotifyWinHttp.Status . " not 2xx for request """ . method . ":" . url . """."
  202: }
--->	204: Throw,{message: ErrorMessage, what: "HTTP response code not 2xx", file: A_LineFile, line: A_LineNumber}
  205: }
  207: Return,SpotifyWinHttp.ResponseText
  208: }
  212: {
  213: res.SetBodyText("Page not found")  
  214: }
  215: {

The current thread will exit.
---------------------------
OK   
---------------------------

Any idea what's up?

Spotify doesn't open

Hi,
today I stumbled over this project and gave it a try:
when I start it, my Chrome browser opens up the page to authorize Spotify.ahk. I confirm this, but then the page loads forever and Spotify doesn't show up in the browser tab. I guess that's not normal, am I right?

Second, in my user account I can see that Spotify.ahk was successfully registered as an allowed application.
But if I open Spotify web player in Chrome manually, the shortcuts still don't work.

Is this project still working for someone? Or is it outdated?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.