Esempio n. 1
0
        public async Task <string> UnspotifyUri(string uri)
        {
            var uriType = _spotifyUriParser.GetUriType(uri);

            switch (uriType)
            {
            case SpotifyUriTypes.Track:
                var trackId = _spotifyUriParser.ParseTrackUri(uri);
                var track   = await _fluentSpotifyClient.Track(trackId).GetAsync();

                return(GenerateMarkdown(track));

            case SpotifyUriTypes.Album:
                var albumId = _spotifyUriParser.ParseAlbumUri(uri);
                var album   = await _fluentSpotifyClient.Album(albumId).GetAsync();

                return(GenerateMarkdown(album));

            case SpotifyUriTypes.Artist:
                var artistId = _spotifyUriParser.ParseArtistUri(uri);
                var artist   = await _fluentSpotifyClient.Artist(artistId).GetAsync();

                return(GenerateMarkdown(artist));

            case SpotifyUriTypes.Playlist:
                var playlistUriParts = _spotifyUriParser.ParsePlaylistUri(uri);
                var tracks           = await _fluentSpotifyClient.User(playlistUriParts.UserId).Playlist(playlistUriParts.PlaylistId).Tracks().GetAsync();

                return(GenerateMarkdown(tracks.Items));

            default:
                throw new ArgumentOutOfRangeException(nameof(uriType), $"Unknown {nameof(uriType)}: {uriType} got from {uri}");
            }
        }
        public async Task <List <FluentSpotifyApi.Model.SimpleTrack> > GetTracks(string id, int limit = 50)
        {
            var data = await _fluentSpotifyClient.Album(id).Tracks.GetAsync();

            return(data.Items.Take(limit).ToList());
        }