Пример #1
0
        public async Task <Result> LoveSong()
        {
            var lastFMService = new LastFMService();

            var songInfo = await GetNowPlaying();

            if (songInfo.Loved)
            {
                return new Result()
                       {
                           Ok        = true,
                           ErrorCode = 0,
                           Message   = "You already liked this song"
                       }
            }
            ;

            var status = await lastFMService.LoveSong(songInfo.Artist, songInfo.Song);

            ThumbUp();

            return(new Result
            {
                Ok = true,
                ErrorCode = 0,
                Message = $"You liked {songInfo.Song} song. Status: {status}"
            });
        }
Пример #2
0
        public async Task <SongResult> GetNowPlaying(bool lastFM)
        {
            ConnectIfNotConnected();

            var song   = GetCurrentSong();
            var status = GetStatus();

            using (var lastFMService = new LastFMService())
            {
                var result = new SongResult()
                {
                    Album           = song.Album,
                    AlbumUri        = null,
                    Artist          = song.Artist,
                    DurationSeconds = status.TimeTotal,
                    Loved           = false,
                    PlayedSeconds   = status.TimeElapsed,
                    Song            = song.Title,
                    Genre           = song.Genre
                };

                if (lastFM)
                {
                    result.Loved    = (await lastFMService.GetSongInfo(result.Artist, result.Song))?.IsLoved ?? false;
                    result.AlbumUri = (await lastFMService.GetAlbumInfo(result.Artist, result.Album))?.Images?.Large?.ToString();
                }

                return(result);
            }
        }
Пример #3
0
        public async Task <Result> LoveSong()
        {
            ConnectIfNotConnected();

            using (var lastFMService = new LastFMService())
            {
                var mpdInfo = await GetNowPlaying(false);

                var mpdSong = GetCurrentSong();

                if (mpdInfo.Loved)
                {
                    return new Result()
                           {
                               Ok        = true,
                               ErrorCode = 0,
                               Message   = "You already liked this song"
                           }
                }
                ;

                var status = await lastFMService.LoveSong(mpdInfo.Artist, mpdInfo.Song);

                SaveToFavoritesPlaylist(mpdSong);

                return(new Result
                {
                    Ok = true,
                    ErrorCode = 0,
                    Message = $"You liked {mpdInfo.Song} song. Status: {status}"
                });
            }
        }
Пример #4
0
        public async Task <PandoraResult> GetNowPlaying(bool lastFM)
        {
            ConnectIfNotConnected();

            var song   = GetCurrentSong();
            var status = GetStatus();

            var lastFMService = new LastFMService();

            var result = new PandoraResult
            {
                Album           = song.Album,
                AlbumUri        = null,
                Artist          = song.Artist,
                DurationSeconds = status.TimeTotal,
                Loved           = false,
                Song            = song.Title,
                Radio           = song.Genre
            };

            if (lastFM)
            {
                result.Loved    = (await lastFMService.GetSongInfo(result.Artist, result.Song))?.IsLoved ?? false;
                result.AlbumUri = (await lastFMService.GetAlbumInfo(result.Artist, result.Album))?.ImageUrl?.ToString();
            }

            return(result);
        }