Example #1
0
        public Track Map(S.ITrack track, SpotifyMusicProvider musicProvider, string user, bool mapAlbum=false,bool mapArtists=false)
        {
            string trackLink = track.GetLinkString();
            var trackResult = new Track
            {
                Link = trackLink,
                Name = track.Name,
                IsAvailable = track.IsAvailable,
                Duration = track.Duration,
                DurationMilliseconds = (long)track.Duration.TotalMilliseconds,
                MusicProvider = musicProvider.Descriptor,
                ExternalLink = new Uri(musicProvider.ExternalLinkBaseUrl, "/track/" + trackLink)
            };

            if (mapAlbum && track.Album != null)
            {
                trackResult.Album = albumMapper.Map(track.Album, musicProvider);
            }
            if (mapArtists && track.Artists != null)
            {
                trackResult.Artists = track.Artists.Select(t => artistMapper.Map(t,musicProvider)).ToArray();
            }

            //We want to set whether the track is already queued 
            if(alreadyQueuedHelper!=null)
            {
                trackResult = alreadyQueuedHelper.ResetAlreadyQueued((trackResult), user);
            }
            return trackResult;
        }
Example #2
0
        public Artist Map(S.IArtist artist, SpotifyMusicProvider musicProvider)
        {
            string artistLink = artist.GetLinkString();
            var artistResult = new Artist
            {
                Link = artistLink,
                Name = artist.Name,
                PortraitId = artist.PortraitId,
                PortraitUrlLarge = ImageHelper.GetImageUrl(artist.PortraitId, 300),
                PortraitUrlMedium = ImageHelper.GetImageUrl(artist.PortraitId, 120),
                PortraitUrlSmall = ImageHelper.GetImageUrl(artist.PortraitId, 60),
                MusicProvider = musicProvider.Descriptor,
                ExternalLink = new Uri(musicProvider.ExternalLinkBaseUrl, "/artist/ " + artistLink)
            };

            return artistResult;

        }
Example #3
0
        public Album Map(S.IAlbum album, SpotifyMusicProvider musicProvider, bool mapArtist = false)
        {
            var albumLink = album.GetLinkString();
            var albumResult = new Album
            {
                Link = albumLink,
                Name = album.Name,
                Year = album.Year,
                ArtworkId = album.CoverId,
                ArtworkUrlLarge = ImageHelper.GetImageUrl(album.CoverId, 300),
                ArtworkUrlMedium = ImageHelper.GetImageUrl(album.CoverId, 120),
                ArtworkUrlSmall = ImageHelper.GetImageUrl(album.CoverId, 60),
                IsAvailable = album.IsAvailable,
                MusicProvider = musicProvider.Descriptor,
                ExternalLink = new Uri(musicProvider.ExternalLinkBaseUrl, "/album/" + albumLink)
            };
            if (mapArtist && album.Artist != null)
            {
                albumResult.Artist = artistMapper.Map(album.Artist, musicProvider);
            }
            return albumResult;

        }