Exemplo 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;
        }
Exemplo n.º 2
0
        public async override Task <ServiceResult <IEnumerable <BaseLyricsSearchModel> > > SearchItem(string q, int limit = 20)
        {
            var result = await api.SearchItems(q, limit);

            if (!result.Success || result.Error != null)
            {
                return(ServiceResult <IEnumerable <BaseLyricsSearchModel> > .Failed(result.Error?.Message));
            }
            if (result.Result.Count() == 0)
            {
                return(ServiceResult <IEnumerable <BaseLyricsSearchModel> > .Failed("No Lyrics found"));
            }

            return(ServiceResult <IEnumerable <BaseLyricsSearchModel> > .Success(result.Result));
        }