Code Monkey home page Code Monkey logo

spotifyapi-net's People

Contributors

aleab avatar cvertex avatar dependabot-preview[bot] avatar dependabot[bot] avatar dsafa avatar eltoncezar avatar esskar avatar flownzu avatar gruhlum avatar gusper avatar h-philip avatar jakoss avatar jholzer avatar jimmyappelt avatar johnnycrazy avatar mfro avatar mlavende avatar n1ckhansen avatar noelg14 avatar nphmuller avatar p-bojkowski avatar petrroll avatar philippdrebes avatar renatopda8 avatar salfab avatar sparrowbrain avatar streibeb avatar suprnova avatar trudan avatar wmbch 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  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  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

spotifyapi-net's Issues

VideoAd crash

Okey, ad update is fine thanks. Spotify implements in his newest version those video ads, which are popping up and are louder than normal :/
This leads the API to crash too. I debugged it to take a look what the TrackType is when the VideoAd plays, and its just empty then. Maybe you add a String.IsNullOrEmpty(TrackType) somewhere, to make this work..

Different Paths for SppotifyWebHelper

In recent testing I discovered that the Spotify Installer behaves differently depending on your Windows version. On computers which run Windows 8.1 the Spotifywebhelper is saved directly in the root folder of the Spotify installation. On Windows 7 however the Spotifywebhelper file is saved as specified in the StartSpotifyWebhelper function. To resolve this issue you could add a check whether the file exists before starting it (generally also a good idea for the StartSpotify function). Depending on the result you could also check whether the file exists in the root directory of the installation.
unbenannt

No AuthResponse when Port is already in use

There is a Try/Catch block in the SimpleHttpServer class in the Listen Method where the exception is simply ignored. This poses an issue when Port 80 is already in use or was used before in another instance of the SpotifyAPI-NET library which was cancelled while the app was still waiting on a response. While this can be handled on the user side by closing the server before the application exits, I do believe that this should at least throw an exception which at least hints at the cause for the authentication's failure. This was also the problem in my previous Issue, but as it was closed I will reopen another Issue here.

Spotify Web authentification fails

When i try to connect and authenticate an app several times in a short period of time the hhtpserver does not recognise the answer and waits on a never comming response. This issue is always fixed after a restart. I reproduced this bug on 4 different computers, running Windows 10 x64, Windows 8.1 x64, Windows 7 x64 and x32. This happens with every spotify application, even the example application provided here. After some debugging I believe that the error resides in the SimpleHttpServer Listen method

AlbumResource.Uri = "TODO" and app crashes when playing from related artist tab

Opening an artist in spotify and playing a song from the related artist tab results in a

'System.IndexOutOfRangeException' in mscorlib.dll ("Index was outside the bounds of the array.") error

The AlbumResource.Uri returns "TODO" in this case

After already doing some checks in the GetAlbumArtUrl()

if (AlbumResource.Uri == null || AlbumResource.Uri.Contains("local") || AlbumResource.Uri.Contains("spotify:album:0000000000000000000000"))
            return "";

Maybe its better only getting the image when checking first on a valid Uri or we need to add

AlbumResource.Uri.Contains("TODO")

start playing track with timestamp

Hello,
Is it possible to play a song and specify a time where it starts?
spotify:track:1DfGPEHxTYeaJpiNA4xUb5#0:23
I can open this url in Spotify and the song starts at 0:23. When I pass this url through PlayURL() nothing happens.

Thank you.

GetSavedAlbums doesn't return album data

So, I'm playing around with the GetSavedAlbums and the method returns 16 items and when I look at the items returned, the items have an added time, but don't have any item data, it's null.

I would love to look through the code and see if I could work on fixing it or at least tracing through the path to see how the calls are being made, but I load up the source in visual studio 2013 and I can't compile it due to errors.

public string GetAlbum(String id, String market = "")
    {
        if (String.IsNullOrEmpty(market))
            return $"{APIBase}/albums/{id}";
        return $"{APIBase}/albums/{id}?market={market}";
    }

my visual studio has an issue with the $ in return. I'm using .net4.5 any suggestions because I would love to work on seeing if I myself could possibly look into this and fix it

WebClient does not support concurrent I/O

When requesting to fast after each other (came up with async and await) .NET will throw this error as webclient instance is already busy.

Can be reproduced by doing SearchItemAsync() repeatedly quickly after each other.

Best practice says to make a new WebClient for every call.

Question: Get Tracks Through Local

Is there a way to get all tracks from spotify through the local API, or do i have to create an instance of web API and use that.

Just thought the local was already connected to spotify, Should be a way to get tracks from it.

SpotifyLocalAPIClass times out when running local example project

DownloadString during SpotifyLocalAPIClass.Connect passing "http://127.0.0.1:4380/simplecsrf/token.json?&ref=&cors=&_=1423252676" fails with a standard timeout exception

System.Net.WebException occurred
HResult=-2146233079
Message=The operation has timed out
Source=System
StackTrace:
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadString(Uri address)
at System.Net.WebClient.DownloadString(String address)
at SpotifyAPI.SpotifyLocalAPI.RemoteHandler.query(String request, Boolean oauth, Boolean cfid, Int32 wait) in c:\Users\joshe\Dropbox\dev\SpotifyUtility\SpotifyAPI-NET\SpotifyAPI\SpoitfyLocalAPI\RemoteHandler.cs:line 143
InnerException:

Netstat says that port is open, and navigating to that url in my browser just gives me "not found"

image

Spotify web helper is def running

image

Queue empty state

Hi,

it´s not really an issue. It´s more a feature request. After the current (new) update of the Spotify application my queue was empty. So when it is empty and I try to get any kind of information by (eq.) _spotfy.GetStatus().Track then it is null.
It would be great to have a property or a method that give a state of the queue.

"Setting" volume and track position?

-As far as we know there is a way to know current volume(GetVolume()) but no way to set it..why?
-What do you mean by "All information got from the JSON Response"?
-Can you(I'm, how?) rewrite playUrl() func that also accept this "spotify:track:6XQ0DQ5oZUndgL4OeUcrsR#1:40" (giving timestamp I mean)

Btw thanks for this awsome project. It has realy simplified my work :)

Spotify Connect

I use spotify in my kitchen and control it there using this .NET api but I also play a lot of music in the living room which I can easily transfer from the kitchen using Spotify Connect. Is it possible to hook into connect and force the local running spotify client to take over the music stream?

(Work around I use now is to select the next song in the kitchen, spotify takes over then.)

General GDI Exception when referencing Image property which is set by GetAlbumArt

In my application I wanted to use an Image object which is provided by the GetAlbumArt function several times throughout the code. This however results in an Exception (GDIError - General GDI Exception) because the MemoryStream which creates the Image is disposed. This could be resolved by writing the MemoryStream to a byte array, then disposing the stream and creating the Image object from the byte array. Another possible solution (which I implemented in my private version of this repository) would be to create a separate function which simply returns the byte array.

Code to trigger the Exception:

pictureBox.Image = track.GetAlbumArt(...);
ImageConverter _imageConverter = new ImageConverter();
byte[] xByte = (byte[])_imageConverter.ConvertTo(pictureBox.Image, typeof(byte[])); //Exception

Requests don't go through fiddler

Hi,

I'm enjoying using this library! Thanks for making it. It's nicely written with good abstractions. Very simple to understand 😄

I've noticed that calls to api.spotify.com using this library aren't captured by Fiddler. I need fiddler to do some network reporting.
Does anyone have any idea why fiddler wouldn't pick these up?
Maybe something to do with proxy being null, or WebClient behaves differently to fiddler..

Thanks,
CVertex

Access violation at Adverts

Hey Johnny,
all works perfectly in that example application, but when my Spotify runs into an advert / imported song, i get an access violation in the example app, looking like this:
In a System.NullReferenceException Exception of type 'mscorlib.dll "has occurred, but this was not handled in user code.

Additional information: Object reference not set to an object instance.

If a handler is available for this exception, the program may continue to run safely.
(translated by Google Translator, because my Visual Studio is same as me, in german :D)

Spotify API .NET - Null Paging List

I have the following code:

    String userID = playlistInfo.getUserID(playlistURL);
    String playlistID = playlistInfo.getPlaylistID(playlistURL);

    Paging<PlaylistTrack> pagingList = webAPI.GetPlaylistTracks(userID, playlistID);

    var trackList = pagingList.Items;            

    foreach (PlaylistTrack trackInfo in trackList) 
    {
        lstSongs.Items.Add(trackInfo.Track.Artists.ToString() + " - " + trackInfo.Track.Name.ToString());
    }

When I enter a valid URL, the webAPI.GetPlaylistTracks should've return a list with various items, but, instead, it returns null. I have no idea what's wrong, so that's why I came here. Does anyone have any idea?

I've checked every line of the code, but I can't find anything that could be the problem.

Thanks

(sorry for bad english)

Code Compile Issue

[c# noob, apologies]

I am wanting to compile the example so I can use it myself.
However, I am recieving lots of these errors. Not sure if it relates to Nuget.

image

Cheers

New Spotify-Beta

There is a new Spotify-Client ready for beta testing.

You can download it here

@gusper seems like it really got better now! Maybe there are also some new hidden features within the Spotify API, who knows? 😂

Spotify does not always takes the mute but the icon in the sound mixer shows its muted

After some testing, i find that the muting Spotify does not always works.

It will mute in the sound mixer (the icon will show its muted but its not) but it actually doesn't mute spotify until i mute the app in the sound mixer for myself instead of doing it remotely.

I'm not 100% sure of when or why this actually does what it does. Sometimes it works and sometimes it doesn't.

I'l do more investigation about this issue.

(I'm use the nircmd.dll)

Can't connect to Spotify..

Hey!
Getting an issue here when I try to assign a API to my spotify variable. My code:

        private SpotifyLocalAPI _spotify;
        private Track _currentTrack; 

        static void Main(string[] args)
        {
            new Program().Start();
        }

        public void Start()
        {
            if (!api.IsSpotifyRunning())
            {
                DialogResult q = MessageBox.Show("Spotify is not running! Would you like to start it now?", "Spotify not running!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (q == DialogResult.Yes)
                {
                    SpotifyLocalAPI.RunSpotify();
                    if (!SpotifyLocalAPI.IsSpotifyWebHelperRunning())
                        SpotifyLocalAPI.RunSpotifyWebHelper();

                }
                else if (q == DialogResult.No)
                {
                    Environment.Exit(0);
                }
            }

            _spotify = new SpotifyLocalAPI();

            if (_spotify.Connect())
            {
                Console.WriteLine("Connected!");
            }
            else
            {
                Console.WriteLine("Connection failed!");
            }

            KeepConsoleRunning();        
        }

Its a console application, so if I run _spotify.Connect(), I get this error:

Ein Ausnahmefehler des Typs "System.IO.FileLoadException" ist in SpotifyAPI.dll aufgetreten.

Zusätzliche Informationen: Die Datei oder Assembly "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)

I'ts german, cause you a german as well I think..

Push the latest version to nuget

I started writing an application for Spotify, but when I wanted to setup Implicit Grant using the local web server, I could not pass the port number to the HTTP server. I can't use port 80 for this app because my critical IIS service uses it. I glanced over the code and it seems like the Github copy allows passing in a port number for the HTTP server, this is not the version that is pushed to nuget. Can you please push the latest to version to nuget?

Thanks

VB.Net

Hi i tryed to use the api last night and if i want to connect to Spotify it always fails(the wihle is always trying)
Source :

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    If SpotifyAPI.SpotifyLocalAPI.SpotifyLocalAPIClass.IsSpotifyRunning = True Then
        MsgBox("Spotify Leuft :D")
    Else
        spotify.RunSpotify()
        Snooze(5000)
        MsgBox("Jetzt leuft Spotify :D")
    End If
    If SpotifyAPI.SpotifyLocalAPI.SpotifyLocalAPIClass.IsSpotifyWebHelperRunning = True Then
        MsgBox("Webhelper geht!")
    Else
        MsgBox("Webhelper Startet")
        spotify.RunSpotifyWebHelper()
        Snooze(5000)
    End If
    spotify.Connect()

    Dim retry As Boolean = True
    While retry = True
        If spotify.Connect = True Then
            retry = False
            MsgBox("jaaaaaaa")
        Else

            retry = True
        End If
    End While
    spotify.Update()
End Sub
Private Sub Snooze(ByVal seconds As Integer)
    For i As Integer = 0 To seconds * 100
        Application.DoEvents()
        System.Threading.Thread.Sleep(10)
    Next
End Sub

Private Sub ButtonBlue1_Click(sender As Object, e As EventArgs) Handles ButtonBlue1.Click
    If spotify.Connect = True Then
        TxtBox1.Text = mh.IsPlaying
        eh.ListenForEvents(True)

    Else
        MsgBox("am Arsch!")
    End If
End Sub

Private Sub ButtonBlue2_Click(sender As Object, e As EventArgs) Handles ButtonBlue2.Click
    mh.Pause()
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    spotify.Connect()
End Sub

Mute pauses Spotify when playing ad

When Spotify is playing advertisement, and SpotifyMusicHandler.Mute() function is called, Spotify will be paused until SpotifyMusicHandler.UnMute() is called.

It's more Spotify "issue" rather than this API, but I've added this anyway, so maybe someone will find a workaround ;)

Setting WebClient.Proxy to null stops the local api from working

In an environment where I have setup a proxy in my internet settings the local spotify api is not working.

It seems that the issue is in these two lines, where the WebClient.Proxy property is set specifically to null.

https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI/Local/RemoteHandler.cs#L65
https://github.com/JohnnyCrazy/SpotifyAPI-NET/blob/master/SpotifyAPI/Local/ExtendedWebClient.cs#L13

I am unsure why they are specifically set to null, but maybe you guys can tell me that.

I also would be happy to make a pull request to fix this by myself, but first I would like to discuss how this should be fixed (just to match your architectural expectations).

AddToQueue method plays the specific track directly

Hi,

when I call the method with a Spotify-Uri the actual track (currently playing in the application and stored in the queue) gets stopped and the specified track behind the uri starts playing (+ queue gets cleared). Is this the right behavior?

When I add a track to the queue in the Spotify application via context menu it is get set behind the current track and all "next titles" remains.

Best Regards

API blocking UI thread

After a connection, when moving the main window, it seems that the API is blocking the UI thread on and off continuously.

System.NullReferenceException after multiple times

Using the SpotifyAPI.Local

When doing _spotify.GetStatus() after series of time, like i would like to do in a timer.

Every 1 second or 2 seconds or so, the object is not null but the track seems to be null very often.

My purpose is to check spotify very often if there is a new song playing.

I'm binding the Artistname like so:

var o = _spotify.GetStatus();
label.text = o.Track.ArtistResource.Name;

It will spam with NullReferenceException when i try to work with a timer, so the artist and etc. will not update for a pretty long time.

TrackResource is null when ad is running

When an ad starts playing, the TrackResource in SpotifyLocalAPI.cs line 98 is null, thus crashing the application.

Also, in the previous version, there was the IsAdRunning() method. There's something similar in this version? or how can I check if there's an ad running?

Thanks!

Dangling threads when stopping SimpleHttpServer

Hi Spotify API people,

I'm automating the use of the Spotify API for collecting track data for our users. So we can collect data for several hours, we're using AuthorizationCodeAuth which supports token refreshing.

After collection, I noticed our exe doesn't terminate..

The problem is with the SimpleHttpServer.

Here's a simplified version of my collection process that highlights the problem..

// Play with http server
var s = new SimpleHttpServer(8000, AuthType.Authorization);
var httpThread = new Thread(s.Listen);
httpThread.Start();
C.WriteLine("HTTP Server started");
C.WriteLine("Sleeping for 30s...");
// NOTE: while sleeping, visit http://localhost:8000/?code=XXX&state=XSS in chrome

Thread.Sleep(30 * 1000);

C.WriteLine("Shutting down server");
s.Dispose();

After investigating, I noticed HttpProcessor.StreamReadLine is in an infinite loop. It is constantly reading nextChar of -1 forever and ever.

It appears to be chrome's request for favicon.ico, causing the StreamReadLine method to get stuck in an infinite loop.

After some googling, I noticed SimpleHttpServer is very similar to http://www.codeproject.com/Articles/137979/Simple-HTTP-Server-in-C

This is interesting, because someone reports a similar problem! http://www.codeproject.com/Messages/4951831/shutdown.aspx

So it looks like he's suggesting killing the HTTP processing thread.

Any ideas how we can do this?

I mean, it's easy enough to keep track of the thread, but what if they are multiple threads running concurrently, how do we keep track of open threads and abort them?

Or ideally, can we handle the favicon.ico problem?

Thanks

auth_OnResponseReceivedEvent not being called

I am trying to use the SpotifyWebAPIExample project. After running the project and logging in successfully, the auth_OnResponseReceivedEvent is not called. What am I doing wrong?

Not logged in

Is it possible to check if the user is signed in or not?

Unable to change volume

G'day again.

Whenever I reference setVolume a "Volume object creation failed" COMException is thrown. Music is playing, and other controls are fine. No stacktrace available appoligies.

Any ideas?

Request Cfid = Empty.String with allot of Antivirus software

It seems that with allot of Antivirus software the GetCfid()return a empty string when requesting.

This result in a being unable to connect to spotify.

This will be the error message: The server committed a protocol violation. Section=ResponseStatusLine

Another question about ads..

Its me again..
In the older versions, there was a mh.IsAdRunning() (MusicHandler)..
Where is it now in the version?

Enhancement: Build against .NET 4.6 and .NET Core

Microsoft is ending support for .net framework 4.5 in January.. I have no idea why.. I think they're trying to push all 4.5 apps to 4.6..

Since the only real hard dependency is json.net, maybe we could upgrade this library to support both .NET 4.6 and .NET Core so we can run this cross platform.

I'm looking forward to running this library on a linux server 😄

Thanks

Error whith 32 bit nirsoft dll

When trying to use the nirsoft dll under the build settings "Release" and "Any Cpu" you get an exception as soon as SpotifyApi gets loaded because it tries to load a 32 bit dll in a 64 bit process. Thus, you need to include the 64 bit version as well and add a check to determine wether the current process is 64 or 32 bit

GetTrack Not returning a value

I used the example of code given on your website, But it does not seem to be filling my fulltrack object with any data. Here's my code

SpotifyWebAPI _webAPI = new SpotifyWebAPI()
{
UseAuth = false,
};
FullTrack track = _webAPI.GetTrack("0eW4vkDVxqS4U60ExzsKhR");

New documentation-site

We got a new WIP documentation site.

It's available here: Spotify-API .NET Docs
They're built with mkdocs, the branch for the "raw" docs is docs
Travis-CI automatically builts them on push and pushes the new changes to the gh-pages-branch

It's pretty much empty by now, but I will fill it the next weeks.
If you have any ideas or suggestions, feel free to post them 👍

VB.NET UpdateTrack not declared.

Its just telling me that updatetrack is not declared what do i declare it as? & UpdatePlayingStatus is doing the same...

Imports SpotifyAPI
Imports SpotifyAPI.Local.SpotifyLocalAPI
Imports SpotifyAPI.Local.Models
Imports SpotifyAPI.Local.Enums
Imports Newtonsoft
Public Class Form1
Private ReadOnly _spotify As SpotifyAPI.Local.SpotifyLocalAPI
Private _currentTrack As Track
Dim SpotifyLocalAPI = New SpotifyAPI.Local.SpotifyLocalAPI
Dim spotify = New SpotifyAPI.Local.SpotifyLocalAPI

Public Sub Connect()
    Dim _spotify = New SpotifyAPI.Local.SpotifyLocalAPI
    If Not SpotifyLocalAPI.IsSpotifyRunning() Then
        MessageBox.Show("Spotify isn't running!")
        Return
    End If
    If Not SpotifyLocalAPI.IsSpotifyWebHelperRunning() Then
        MessageBox.Show("SpotifyWebHelper isn't running!")
        Return
    End If

    Dim successful As Boolean = _spotify.Connect()
    If successful Then
        MetroButton1.Text = "Connection to Spotify successful"
        MetroButton1.Enabled = False
        'UpdateInfos()
        _spotify.ListenForEvents = True
    Else
        Dim res As DialogResult = MessageBox.Show("Couldn't connect to the spotify client. Retry?", "Spotify", MessageBoxButtons.YesNo)
        If res = DialogResult.Yes Then
            Connect()
        End If
    End If
End Sub
Public Sub UpdateInfos()
    Dim status As StatusResponse = _spotify.GetStatus()
    If status Is Nothing Then
        Return
    End If

    'Basic Spotify Infos
    UpdatePlayingStatus(status.Playing)
    clientVersionLabel.Text = status.ClientVersion
    versionLabel.Text = status.Version.ToString()
    repeatShuffleLabel.Text = status.Repeat + " and " + status.Shuffle

    If status.Track IsNot Nothing Then
        'Update track infos
        UpdateTrack(status.Track)
    End If
End Sub

Private Sub MetroButton1_Click(sender As Object, e As EventArgs) Handles MetroButton1.Click
    Connect()
End Sub

End Class

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.