Example #1
0
        private async Task <ILavaTrack> SearchSpotify(SpotifyTrackInfo spotifyResult)
        {
            string       artistName   = $"{spotifyResult.Artists.FirstOrDefault()?.Name} - ";
            SearchResult searchResult = await this.LavaRest.SearchYouTubeAsync($"{artistName}{spotifyResult.Name}");

            return(searchResult.Tracks.FirstOrDefault());
        }
Example #2
0
        /// <summary>
        ///     Converts a SpotifyTrackInfo to a SpotifyTrack, decides by configuration or parameter if it should search for the
        ///     InnerTrack now, or LazyLoad (search for it later)
        /// </summary>
        /// <param name="trackInfo">Source SpotifyTrackInfo</param>
        /// <param name="lazyLoad">Optional parameter to specify if to lazy load or not, no matter what the configuration specifies</param>
        /// <returns>Converted SpotifyTrack</returns>
        public async Task <SpotifyTrack> CreateSpotifyTrackAsync(SpotifyTrackInfo trackInfo, bool?lazyLoad = null)
        {
            bool isLazyLoad = lazyLoad ?? this.Config.LazyLoad;

            return(isLazyLoad
                ? new SpotifyTrack(trackInfo, () => this.SearchSpotify(trackInfo))
                : new SpotifyTrack(trackInfo, await this.SearchSpotify(trackInfo)));
        }
Example #3
0
        public async Task <SpotifyTrack> GetTrackAsync(string id)
        {
            SpotifyTrackInfo trackInfo = new SpotifyTrackInfo(await this.RunConfig.Api.GetTrackAsync(id));

            return(await this.RunConfig.TrackConverter.CreateSpotifyTrackAsync(trackInfo));
        }