Beispiel #1
0
        /// <summary>
        /// Dependency: https://github.com/filipkristo/LastfmWSClient.git
        /// </summary>
        /// <param name="song"></param>
        /// <returns></returns>
        public string StartScrobbleBash(SongDetails song)
        {
            const string script = "./scrobble";

            var result = BashHelper.ExecBashScript(script, song.Artist, song.Song, song.Album, Environment.NewLine);

            return(string.IsNullOrWhiteSpace(result.Error) ? $"StartScrobbleBash - OK: {result.Message}" : $"StartScrobbleBash - FAIL: {result.Error}");
        }
Beispiel #2
0
        public async Task <string> UpdateNowPlaying(SongDetails song)
        {
            if (!client.Auth.Authenticated)
            {
                await Authenticate(client);
            }

            var scrobble = new Scrobble(song.Artist, song.Album, song.Song, DateTime.UtcNow);
            var response = await client.Track.UpdateNowPlayingAsync(scrobble);

            return(response.Status.ToString());
        }
Beispiel #3
0
        public async Task <string> UpdateNowPlaying(SongDetails song)
        {
            var payload       = JsonConvert.SerializeObject(song);
            var stringContent = new StringContent(payload, Encoding.UTF8, "application/json");

            var response = await _httpClient.PostAsync("apiservice/api/LastFm/UpdateNowPlaying", stringContent).ConfigureAwait(false);

            var json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            if (!response.IsSuccessStatusCode)
            {
                throw new ApplicationException(json);
            }

            return(JsonConvert.DeserializeObject <string>(json));
        }