public MusicModule(SpotifyTrackConnection spotifyTrackConnection, YoutubeConnection youtubeConnection) : base("v1/music") { Get("audio-feature", async _ => await spotifyTrackConnection.GetAudioFeature()); Get("youtube/{songTitle}", async parameters => { return(Response.AsJson(new YoutubeDto { VideoId = await youtubeConnection.GetVideoIdOf(parameters.songTitle) })); }); }
public HomeModule(SpotifyConnection spotifyConnection, NapsterConnection napsterConnection, YoutubeConnection youtubeConnection) { Get("/", _ => "Hello World!"); Get("/ping", _ => { if (spotifyConnection.Ping()) { return(true); } return(false); }); Post("/connect", async _ => { SpotifySecrets spotifySecret = this.Bind <SpotifySecrets>(); NapsterSecrets napsterSecrets = this.Bind <NapsterSecrets>(); YoutubeSecrets youtubeSecrets = this.Bind <YoutubeSecrets>(); spotifyConnection.AddAndUseSecret(spotifySecret); youtubeConnection.AddAndUseSecret(youtubeSecrets); return(await spotifyConnection.Connect()); }); }
//--------------------------------------------------------------------- // // event // //--------------------------------------------------------------------- // null //--------------------------------------------------------------------- // // function // //--------------------------------------------------------------------- /// <summary> /// /// </summary> private void OnLogin() { string identifier = base.GetNamedDependencyObject <TextBox>("IdentifierBox").Text; // Dispatcher uiDispatcher = Dispatcher.CurrentDispatcher; // this.GoToConnectingState(); // Task.Run(async() => { Thread.Sleep(1800); // await YoutubeConnection.Open(identifier, "client_secret.json"); if (YoutubeConnection.IsOpen) { uiDispatcher.Invoke(() => { InternalEventAggregator.Current .GetEvent <SwitchContentEvent>() .Publish(ContentType.Check); }); } else { uiDispatcher.Invoke(() => { this.GoToFormState(); Dialog.ShowMessage("Message", "로그인 실패", MessageBoxButton.OK); }); } }); }