コード例 #1
0
ファイル: SpotifyService.cs プロジェクト: mikeruhl/Cronos
 public async Task <FullArtist> GetArtistById(string id)
 {
     if (_memoryCache.TryGetValue(id, out FullArtist artist))
     {
         return(await Task.Run(() => artist));
     }
     return(await _fluentSpotifyClient.Artist(id).GetAsync());
 }
コード例 #2
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}");
            }
        }
コード例 #3
0
        public async Task <FluentSpotifyApi.Model.FullArtist> GetArtist(string id)
        {
            var data = await _fluentSpotifyClient.Artist(id).GetAsync();

            return(data);
        }