Ejemplo n.º 1
0
        private async void GetLyrics(HappiWebApi api, string songInfo)

        {
            Response <List <SearchResult> > currentsong = await api.SearchItems(songInfo);

            if (currentsong.Error != null)
            {
                txtLyrics.Text = $"no lyrics found - {currentsong.Error.Message}";
                return;
            }
            if (!currentsong.Result.Any())
            {
                txtLyrics.Text = "no lyrics found";
                return;
            }
            var lyricUrl = currentsong.Result.FirstOrDefault().ApiLyrics;

            var lyrics = await api.GetLyric(lyricUrl.OriginalString);

            if (lyrics.Result == null)
            {
                txtLyrics.Text = $"no lyrics found - {lyrics.Error.Message}";
                return;
            }
            txtLyrics.Text = lyrics.Result.Lyrics;
        }
Ejemplo n.º 2
0
        public async override Task <ServiceResult <string> > DownloadLyrics(string url)
        {
            Uri uriResult;

            if (!Uri.TryCreate(url, UriKind.Absolute, out uriResult))
            {
                return(ServiceResult <string> .Failed("no lyrics found"));
            }


            var lyrics = await api.GetLyric(url);

            if (string.IsNullOrEmpty(lyrics?.Result?.Lyrics))
            {
                return(ServiceResult <string> .Failed("no lyrics found"));
            }
            return(ServiceResult <string> .Success(lyrics.Result.Lyrics));
        }