public async Task UpdatesNowPlaying()
        {
            var trackPlayed = DateTime.UtcNow.AddMinutes(-1);
            var testScrobble = new Scrobble(ARTIST_NAME, ALBUM_NAME, TRACK_NAME, trackPlayed)
            {
                Duration = new TimeSpan(0, 0, 3, 49, 200),
                AlbumArtist = ARTIST_NAME
            };

            var response = await Lastfm.Track.UpdateNowPlayingAsync(testScrobble);

            Assert.IsTrue(response.Success);

            var tracks = await Lastfm.User.GetRecentScrobbles(Lastfm.Auth.UserSession.Username, null, 1, 1);

            var expectedTrack = new LastTrack
            {
                Name = TRACK_NAME,
                ArtistName = ARTIST_NAME,
                AlbumName = ALBUM_NAME,
                Mbid = "1b9ee1d8-c5a7-44d9-813e-85beb0d59f1b",
                ArtistMbid = "b1570544-93ab-4b2b-8398-131735394202",
                Url = new Uri("http://www.last.fm/music/Crystal+Castles/_/Not+in+Love"),
                Images = new LastImageSet("http://userserve-ak.last.fm/serve/34s/61473043.png",
                    "http://userserve-ak.last.fm/serve/64s/61473043.png",
                    "http://userserve-ak.last.fm/serve/126/61473043.png",
                    "http://userserve-ak.last.fm/serve/300x300/61473043.png"),
                IsNowPlaying = true
            };

            var expectedJson = expectedTrack.TestSerialise();
            var actualJson = tracks.Content.FirstOrDefault().TestSerialise();

            Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
        }
Ejemplo n.º 2
0
 public Task<LastResponse> UpdateNowPlayingAsync(Scrobble scrobble)
 {
     var command = new UpdateNowPlayingCommand(Auth, scrobble)
     {
         HttpClient = HttpClient
     };
     return command.ExecuteAsync();
 }
Ejemplo n.º 3
0
 public Task<ScrobbleResponse> ScrobbleAsync(Scrobble scrobble)
 {
     var command = new ScrobbleCommand(Auth, scrobble)
     {
         HttpClient = HttpClient
     };
     return command.ExecuteAsync();
 }
Ejemplo n.º 4
0
        public TrackScrobbleCommandTests()
        {
            _scrobblePlayed = DateTimeOffset.UtcNow;
            _testScrobble = new Scrobble("Kate Nash", "Made of Bricks", "Foundations", _scrobblePlayed)
            {
                AlbumArtist = "Kate Nash"
            };

            _command = new ScrobbleCommand(MAuth.Object, _testScrobble);
        }
Ejemplo n.º 5
0
 public async void ScrobbleTrack(string artist, string album, string track)
 {
     var trackApi = new TrackApi(_auth);
     var scrobble = new Scrobble(artist, album, track, DateTimeOffset.Now);
     IScrobbler _scrobbler;
     _scrobbler = new Scrobbler(_auth);
     var response = await _scrobbler.ScrobbleAsync(scrobble);
     if (response.Success)
     {
         Debug.WriteLine("Scrobble success!");
     }
     else
     {
         Debug.WriteLine("Scrobble failed!");
     }
 }
        public async Task ScrobblesSingle()
        {
            var trackPlayed = DateTimeOffset.UtcNow.AddMinutes(-1).RoundToNearestSecond();
            var testScrobble = new Scrobble("Hot Chip", "The Warning", "Over and Over", trackPlayed)
            {
                AlbumArtist = ARTIST_NAME,
                ChosenByUser = false
            };

            var response = await Lastfm.Scrobbler.ScrobbleAsync(testScrobble);

            Assert.IsTrue(response.Success);
            
            var testGuid = Guid.Empty;
            var expectedTrack = new LastTrack
            {
                Name = TRACK_NAME,
                ArtistName = ARTIST_NAME,
                AlbumName = ALBUM_NAME,
                Mbid = testGuid.ToString("D"),
                ArtistMbid = testGuid.ToString("D"),
                Url = new Uri("http://www.last.fm/music/Hot+Chip/_/Over+and+Over"),
                Images = new LastImageSet("http://userserve-ak.last.fm/serve/34s/50921593.png",
                    "http://userserve-ak.last.fm/serve/64s/50921593.png",
                    "http://userserve-ak.last.fm/serve/126/50921593.png",
                    "http://userserve-ak.last.fm/serve/300x300/50921593.png")
            };
            var expectedJson = expectedTrack.TestSerialise();

            var tracks = await Lastfm.User.GetRecentScrobbles(Lastfm.Auth.UserSession.Username, null, 0, 1);
            Assert.IsTrue(tracks.Any());

            var actual = tracks.Content.First();
            
            TestHelper.AssertSerialiseEqual(trackPlayed, actual.TimePlayed);
            actual.TimePlayed = null;

            // MBIDs returned by last.fm change from time to time, so let's just test that they're there.
            Assert.IsTrue(Guid.Parse(actual.Mbid) != Guid.Empty);
            Assert.IsTrue(Guid.Parse(actual.ArtistMbid) != Guid.Empty);
            actual.Mbid = testGuid.ToString("D");
            actual.ArtistMbid = testGuid.ToString("D");

            var actualJson = actual.TestSerialise();

            Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
        }
Ejemplo n.º 7
0
        public async Task ScrobblesSingle()
        {
            var trackPlayed = DateTimeOffset.UtcNow.AddMinutes(-1).RoundToNearestSecond();
            var testScrobble = new Scrobble("Hot Chip", "The Warning", "Over and Over", trackPlayed)
            {
                AlbumArtist = ARTIST_NAME,
                ChosenByUser = false
            };

            var response = await Lastfm.Scrobbler.ScrobbleAsync(testScrobble);

            Assert.IsTrue(response.Success);
            
            var expectedTrack = new LastTrack
            {
                Name = TRACK_NAME,
                ArtistName = ARTIST_NAME,
                AlbumName = ALBUM_NAME
            };
            var expectedJson = expectedTrack.TestSerialise();

            var tracks = await Lastfm.User.GetRecentScrobbles(Lastfm.Auth.UserSession.Username, null, 1, 1);
            Assert.IsTrue(tracks.Any());

            var actual = tracks.Content.First();
            
            TestHelper.AssertSerialiseEqual(trackPlayed, actual.TimePlayed);
            actual.TimePlayed = null;

            // Some properties change from time to time; parsing is covered in unit tests
            actual.Mbid = null;
            actual.ArtistMbid = null;
            actual.Images = null;
            actual.Url = null;

            var actualJson = actual.TestSerialise();

            Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
        }
    /// <summary>
    /// Scrobbles the track with the given info.
    /// </summary>
    public override async Task Scrobble()
    {
      EnableControls = false;

      OnStatusUpdated("Trying to scrobble...");

      if (CurrentDateTime)
        TimePlayed = DateTime.Now;

      Scrobble s = new Scrobble(Artist, Album, Track, TimePlayed);
      var response = await MainViewModel.Scrobbler.ScrobbleAsync(s);
      if (response.Success)
        OnStatusUpdated("Successfully scrobbled!");
      else
        OnStatusUpdated("Error while scrobbling!");

      EnableControls = true;
    }
    /// <summary>
    /// Scrobbles the current song.
    /// </summary>
    /// <returns></returns>
    public override async Task Scrobble()
    {
      if (CanScrobble)
      {
        EnableControls = false;

        OnStatusUpdated("Trying to scrobble currently playing track...");

        Scrobble s = new Scrobble(CurrentArtistName, CurrentAlbumName, CurrentTrackName, DateTime.Now);
        var response = await MainViewModel.Scrobbler.ScrobbleAsync(s);
        if (response.Success)
        {
          OnStatusUpdated("Successfully scrobbled!");
          CurrentTrackScrobbled = true;
        }
        else
          OnStatusUpdated("Error while scrobbling!");

        EnableControls = true;
      }
    }
Ejemplo n.º 10
0
 public Task<ScrobbleResponse> ScrobbleAsync(Scrobble scrobble)
 {
     return ScrobbleAsync(new[] {scrobble});
 }