Beispiel #1
0
        public async Task <PlaylistAPI> CreatePlaylist(string city)
        {
            playlistAPI.Weather = await _weatherMapService.GetWeather(city);

            if (playlistAPI.Weather.Data != null)
            {
                playlistAPI.Spotify = await _spotifyService.GetPlaylist(ConvertTempToGenre(KelvinToCelsius(playlistAPI.Weather.Data.Main.Temp)));

                if (playlistAPI.Spotify.Data != null)
                {
                    playlistAPI.Spotify.Data.temperature = KelvinToCelsius(playlistAPI.Weather.Data.Main.Temp);
                }
            }

            return(playlistAPI);
        }
        public async Task <IEnumerable <CustomTrack> > Playlists(string id)
        {
            var token = await _spotifyAccountService.GetAccessToken();

            var playlist = await _spotifyService.GetPlaylist(id, token);

            return(playlist);
        }
Beispiel #3
0
        private async Task <Station> PlayNowPlaying(ITurnContext turnContext, string token, CancellationToken cancellationToken)
        {
            // no query so start / resume station
            // Play whatever the user is currently playing on Spotify

            var info          = RingoBotHelper.NormalizedConversationInfo(turnContext);
            var channelUserId = RingoBotHelper.ChannelUserId(turnContext);

            SpotifyApi.NetCore.CurrentPlaybackContext nowPlaying = await _spotifyService.GetUserNowPlaying(token);

            if (nowPlaying == null || !nowPlaying.IsPlaying || nowPlaying.Context == null)
            {
                if (nowPlaying.IsPlaying && nowPlaying.Context == null)
                {
                    await turnContext.SendActivityAsync(RingoBotMessages.NowPlayingNoContext(info), cancellationToken);
                }
                else if (nowPlaying.IsPlaying && !new[] { "playlist", "album" }.Contains(nowPlaying.Context.Type))
                {
                    await turnContext.SendActivityAsync(
                        RingoBotMessages.NowPlayingNotSupported(info, nowPlaying.Context.Type), cancellationToken);
                }
                else
                {
                    await turnContext.SendActivityAsync(RingoBotMessages.NotPlayingAnything(info), cancellationToken);
                }

                return(null);
            }

            await _spotifyService.TurnOffShuffleRepeat(token, nowPlaying);

            Station station = null;

            switch (nowPlaying.Context.Type)
            {
            case "playlist":
                var playlist = await _spotifyService.GetPlaylist(token, nowPlaying.Context.Uri);

                station = info.IsGroup
                        ? await _ringoService.CreateConversationStation(info, playlist : playlist)
                        : await _ringoService.CreateUserStation(info, playlist : playlist);

                break;

            case "album":
                var album = await _spotifyService.GetAlbum(token, nowPlaying.Context.Uri);

                station = info.IsGroup
                        ? await _ringoService.CreateConversationStation(info, album : album)
                        : await _ringoService.CreateUserStation(info, album : album);

                break;

            default:
                await turnContext.SendActivityAsync(
                    RingoBotMessages.NowPlayingNotSupported(info, nowPlaying.Context.Type), cancellationToken);

                break;
            }

            return(station);
        }