Пример #1
0
        public Track GetTrack()
        {
            if (!Track.IsNormal())
            {
                return(Track);
            }

            var api        = new LastFMAPI();
            var trackExtra = api.GetTagInfo(Track);

            if (trackExtra != null && trackExtra.Album != null)
            {
                Track = MapLastFMTrackToTrack(trackExtra);
            }
            else
            {
                var retryWithTrack = Track;
                retryWithTrack.Title = Regex.Replace(retryWithTrack.Title, @" \(.*?\)| \- .*", "");
                trackExtra           = api.GetTagInfo(retryWithTrack);
                if (trackExtra != null)
                {
                    Track = MapLastFMTrackToTrack(trackExtra);
                }
            }

            return(Track);
        }
Пример #2
0
        private void GetTagInfo_ReturnsLastFMTrack()
        {
            var spotifyTrack = new Track()
            {
                Title         = "Song Title",
                Artist        = "Artist Name",
                Ad            = false,
                Playing       = true,
                TitleExtended = "Live"
            };

            var api = new LastFMAPI();

            var lastFMTrack = api.GetTagInfo(spotifyTrack);

            Assert.NotNull(lastFMTrack);
            Assert.Equal(lastFMTrack, api.TrackInfo);
        }
Пример #3
0
        public Track GetTrack()
        {
            var api        = new LastFMAPI();
            var trackExtra = api.GetTagInfo(Track);

            if (trackExtra != null)
            {
                Track.Album            = trackExtra.Album?.AlbumTitle;
                Track.AlbumPosition    = trackExtra.Album?.TrackPosition;
                Track.Genres           = trackExtra.Toptags?.Tag?.Select(x => x.Name).ToArray();
                Track.Length           = trackExtra.Duration / 1000;
                Track.ArtExtraLargeUrl = trackExtra.Album?.ExtraLargeCoverUrl;
                Track.ArtLargeUrl      = trackExtra.Album?.LargeCoverUrl;
                Track.ArtMediumUrl     = trackExtra.Album?.MediumCoverUrl;
                Track.ArtSmallUrl      = trackExtra.Album?.SmallCoverUrl;
            }

            return(Track);
        }