Ejemplo n.º 1
0
        private async void AuthOnAuthReceived(object sender, AuthorizationCode payload)
        {
            AuthorizationCodeAuth auth = (AuthorizationCodeAuth)sender;

            auth.Stop();

            Token token = await auth.ExchangeCode(payload.Code);

            api = new SpotifyWebAPI
            {
                AccessToken = token.AccessToken,
                TokenType   = token.TokenType
            };

            songInfo = await CurrentPlayingsong(api);


            if (songInfo == "")
            {
                return;
            }

            HappiWebApi happiapi = new HappiWebApi(_HappiapiKey);

            GetLyrics(happiapi, songInfo);
        }
Ejemplo n.º 2
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.º 3
0
        public SearchLyrics(ConfigModel ConfigModel) : base(ConfigModel)
        {
            if (string.IsNullOrEmpty(_ApiKey))
            {
                _ApiKey = GetApiKey();
            }

            api = new HappiWebApi(_ApiKey);
        }
Ejemplo n.º 4
0
        private void CheckLyricsTick(object sender, EventArgs e)
        {
            if (api == null)
            {
                return;
            }

            var newsongInfo = CurrentPlayingsong(api).Result;

            if (songInfo == newsongInfo || newsongInfo == "")
            {
                return;
            }

            songInfo       = newsongInfo;
            txtLyrics.Text = "";
            this.Text      = songInfo;

            HappiWebApi happiapi = new HappiWebApi(_HappiapiKey);

            GetLyrics(happiapi, songInfo);
        }