static void Main(string[] args) { Console.WriteLine("### SpotifyWebAPI .NET Test App"); Console.WriteLine("Starting auth process..."); //Create the auth object auth = new ImplicitGrantAuth() { //Your client Id ClientId = "26d287105e31491889f3cd293d85bfea", //Set this to localhost if you want to use the built-in HTTP Server RedirectUri = "http://localhost", //How many permissions we need? Scope = Scope.USER_READ_PRIVATE | Scope.USER_READ_EMAIL | Scope.PLAYLIST_READ_PRIVATE | Scope.USER_LIBRARAY_READ | Scope.USER_LIBRARY_MODIFY | Scope.USER_READ_PRIVATE }; //Start the internal http server auth.StartHttpServer(); //When we got our response auth.OnResponseReceivedEvent += auth_OnResponseReceivedEvent; //Start auth.DoAuth(); }
private void authButton_Click(object sender, EventArgs e) { _auth.StartHttpServer(8000); _auth.DoAuth(); }
public SpotifyModel GetSpotifyModel() { _auth = new ImplicitGrantAuth { RedirectUri = "http://localhost:8000", ClientId = "26d287105e31491889f3cd293d85bfea", Scope = Scope.UserReadPrivate | Scope.UserReadEmail | Scope.PlaylistReadPrivate | Scope.UserLibrarayRead | Scope.UserReadPrivate | Scope.UserFollowRead | Scope.UserReadBirthdate, State = "XSS" }; _auth.OnResponseReceivedEvent += _auth_OnResponseReceivedEvent; _auth.StartHttpServer(8000); _auth.DoAuth(); SpotifyModel sm = new SpotifyModel(); _spotifyLocal = new SpotifyLocalAPI(); if (!SpotifyLocalAPI.IsSpotifyRunning()) { return sm; } if (!SpotifyLocalAPI.IsSpotifyWebHelperRunning()) { return sm; } bool successful = _spotifyLocal.Connect(); if (successful) { UpdateInfos(); _spotifyLocal.ListenForEvents = true; sm.IsPlaying = true; try { sm.SongTitle = _currentTrack.TrackResource.Name; sm.VotedItemsDictionary = GetDictionaryDetails(sm.SongTitle); sm.SongArtist = _currentTrack.ArtistResource.Name; Bitmap derp = new Bitmap(_currentTrack.GetAlbumArt(AlbumArtSize.Size320)); Byte[] imgFile; var stream = new MemoryStream(); derp.Save(stream, ImageFormat.Png); imgFile = stream.ToArray(); sm.SongAlbumArt = _currentTrack.GetAlbumArtUrl(AlbumArtSize.Size320); sm.IsPlaying = true; stream.Close(); sm.Tracks = GetPlaylists(); int index = 0; foreach (var track in sm.Tracks) { if (track.title.Equals(_currentTrack.TrackResource.Name)) { break; } index++; } if (index == 0) index++; sm.PreviousSongAlbumArt = sm.Tracks[index - 1].albumArt; sm.PreviousSongTitle = sm.Tracks[index - 1].title; sm.PreviousSongArtist = sm.Tracks[index - 1].artist; if (index + 1 >= sm.Tracks.Count) index = 0; else index++; sm.NextSongAlbumArt = sm.Tracks[index].albumArt; sm.NextSongTitle = sm.Tracks[index].title; sm.NextSongArtist = sm.Tracks[index].artist; _auth = null; _spotifyLocal = null; _spotify = null; } catch (Exception e) { } } if (Winner) { sm.Truncate(); Winner = false; } string ip = Request.UserHostAddress; sm.IsValidIP = sm.IsValidVote(ip); return sm; }