public void TestLookupTrack() { var result = new SpotifyMetadataApiClient().LookupTrack("spotify:track:6NmXV4o6bmp704aPGyTVVG"); result.Should().NotBeNull(); result.Album.Should().NotBeNull(); result.Album.ArtistId.Should().BeNull(); result.Album.Artist.Should().BeNull(); result.Album.Artists.Should().NotBeNull(); result.Album.Artists.Should().BeEmpty(); result.Album.Availability.Should().BeNull(); result.Album.ExternalIds.Should().NotBeNull(); result.Album.ExternalIds.Should().BeEmpty(); result.Album.Href.Should().Be("spotify:album:6K8NUknbPh5TGaKeZdDwSg"); result.Album.Name.Should().Be("Mann Mot Mann (Ep)"); result.Album.Popularity.Should().BeNull(); result.Album.Released.Should().Be("2002"); result.Artists.Should().NotBeNullOrEmpty(); result.Artists.First().Href.Should().Be("spotify:artist:1s1DnVoBDfp3jxjjew8cBR"); result.Artists.First().Name.Should().Be("Kaizers Orchestra"); result.Available.Should().BeTrue(); result.Href.Should().Be("spotify:track:6NmXV4o6bmp704aPGyTVVG"); result.Length.Should().Be((decimal)317.04); result.Name.Should().Be("B\u00f8n Fra Helvete (Live)"); result.Popularity.Should().NotBeNullOrEmpty(); result.DiscNumber.Should().BeNull(); result.TrackNumber.Should().Be("2"); result.Availability.Should().NotBeNull(); result.Availability.Territories.Should().NotBeNullOrWhiteSpace(); result.ExternalIds.Should().NotBeNullOrEmpty(); result.ExternalIds.First().Id.Should().Be("NOPVA0203020"); result.ExternalIds.First().Type.Should().Be("isrc"); }
public void TestSearchAlbums() { var result = new SpotifyMetadataApiClient().SearchAlbums("foo"); result.Should().NotBeNull(); result.Info.Should().NotBeNull(); result.Info.Limit.Should().Be(100); result.Info.NumResults.Should().BeGreaterOrEqualTo(30); result.Info.Offset.Should().Be(0); result.Info.Page.Should().Be(1); result.Info.Query.Should().Be("foo"); result.Info.Type.Should().Be("album"); result.Albums.Should().NotBeNullOrEmpty(); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").Should().NotBeNull(); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").Name.Should().Be("Greatest Hits"); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").Artist.Should().BeNull(); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").ArtistId.Should().BeNull(); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").Artists.Should().NotBeNullOrEmpty(); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").Availability.Should().NotBeNull(); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").Availability.Territories.Should().NotBeNullOrEmpty(); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").ExternalIds.Should().NotBeNullOrEmpty(); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").ExternalIds.First().Id.Should().NotBeNullOrEmpty(); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").ExternalIds.First().Type.Should().NotBeNullOrEmpty(); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").Released.Should().BeNull(); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").Href.Should().Be("spotify:album:1zCNrbPpz5OLSr6mSpPdKm"); result.Albums.Find(o => o.Href == "spotify:album:1zCNrbPpz5OLSr6mSpPdKm").Popularity.Should().NotBeNullOrEmpty(); }
public void SaveAlbum(Zirpl.Spotify.MetadataApi.Album album, Zirpl.Spotify.MetadataApi.Artist artist) { var result = new SpotifyMetadataApiClient().LookupAlbum(album.Href); MusicApp.Models.Album a = new Models.Album(); a.Name = result.Name; a.Href = album.Href; a.ArtistId = artist.Href; a.Popularity = album.Popularity; a.Artist = result.Artist; a.Released = result.Released; var songs = from s in db.Songs select s; songs = songs.Where(s => s.AlbumID.Contains(album.Href)); if (songs.Count() > 0) { var maxObject = songs.OrderByDescending(item => item.Length).First(); a.LengthLongest = maxObject.Length; a.NameLongest = maxObject.Name; } //if (ModelState.IsValid) if (result.Artist == artist.Name) { db.Albums.Add(a); } }
// GET: Artists/Create public ActionResult Save(Zirpl.Spotify.MetadataApi.Artist artist) { SaveArtist(artist); List<Zirpl.Spotify.MetadataApi.Track>tracks = new SpotifyMetadataApiClient().SearchTracks(artist.Name).Tracks; foreach (Zirpl.Spotify.MetadataApi.Track track in tracks) { SaveTrack(track, artist); } db.SaveChanges(); List<Zirpl.Spotify.MetadataApi.Album> albums = new List<Zirpl.Spotify.MetadataApi.Album>(); if (artist.Albums.Count == 0) albums = new SpotifyMetadataApiClient().SearchAlbums(artist.Name).Albums; else albums = artist.Albums; foreach (Zirpl.Spotify.MetadataApi.Album album in albums) { SaveAlbum(album, artist); } db.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Index(string searchString) { List<Zirpl.Spotify.MetadataApi.Artist> artists = new List<Zirpl.Spotify.MetadataApi.Artist>(); if (searchString != null) artists = new SpotifyMetadataApiClient().SearchArtists(searchString).Artists; return View(artists.ToList()); }
public void TestLookupArtist() { var result = new SpotifyMetadataApiClient().LookupArtist("spotify:artist:4YrKBkKSVeqDamzBPWVnSJ"); result.Should().NotBeNull(); result.Href.Should().Be("spotify:artist:4YrKBkKSVeqDamzBPWVnSJ"); result.Name.Should().Be("Basement Jaxx"); result.Albums.Should().NotBeNull(); result.Albums.Should().BeEmpty(); result.Popularity.Should().BeNull(); }
public void TestSearchTracks_Page2() { var result = new SpotifyMetadataApiClient().SearchTracks("foo", 400); result.Should().NotBeNull(); result.Info.Should().NotBeNull(); result.Info.Limit.Should().Be(100); result.Info.NumResults.Should().BeGreaterOrEqualTo(30); result.Info.Offset.Should().Be(39900); result.Info.Page.Should().Be(400); result.Info.Query.Should().Be("foo"); result.Info.Type.Should().Be("track"); result.Tracks.Should().NotBeNull(); result.Tracks.Should().BeEmpty(); }
public void TestLookupAlbum() { var result = new SpotifyMetadataApiClient().LookupAlbum("spotify:album:6G9fHYDCoyEErUkHrFYfs4"); result.Should().NotBeNull(); result.ArtistId.Should().Be("spotify:artist:4YrKBkKSVeqDamzBPWVnSJ"); result.Artist.Should().Be("Basement Jaxx"); result.Artists.Should().NotBeNull(); result.Artists.Should().BeEmpty(); result.Availability.Should().NotBeNull(); result.Availability.Territories.Should().NotBeNullOrWhiteSpace(); result.ExternalIds.Should().NotBeNullOrEmpty(); result.ExternalIds.First().Id.Should().NotBeNullOrEmpty(); result.ExternalIds.First().Type.Should().NotBeNullOrEmpty(); result.Href.Should().Be("spotify:album:6G9fHYDCoyEErUkHrFYfs4"); result.Name.Should().Be("Remedy"); result.Popularity.Should().BeNullOrEmpty(); result.Released.Should().Be("1999"); }
public void TestSearchArtists() { var result = new SpotifyMetadataApiClient().SearchArtists("foo"); result.Should().NotBeNull(); result.Info.Should().NotBeNull(); result.Info.Limit.Should().Be(100); result.Info.NumResults.Should().BeGreaterOrEqualTo(30); result.Info.Offset.Should().Be(0); result.Info.Page.Should().Be(1); result.Info.Query.Should().Be("foo"); result.Info.Type.Should().Be("artist"); result.Artists.Should().NotBeNullOrEmpty(); result.Artists.Find(o => o.Href == "spotify:artist:7jy3rLJdDQY21OgRLCZ9sD").Should().NotBeNull(); result.Artists.Find(o => o.Href == "spotify:artist:7jy3rLJdDQY21OgRLCZ9sD").Name.Should().Be("Foo Fighters"); result.Artists.Find(o => o.Href == "spotify:artist:7jy3rLJdDQY21OgRLCZ9sD").Albums.Should().NotBeNull(); result.Artists.Find(o => o.Href == "spotify:artist:7jy3rLJdDQY21OgRLCZ9sD").Albums.Should().BeEmpty(); result.Artists.Find(o => o.Href == "spotify:artist:7jy3rLJdDQY21OgRLCZ9sD").Href.Should().Be("spotify:artist:7jy3rLJdDQY21OgRLCZ9sD"); result.Artists.Find(o => o.Href == "spotify:artist:7jy3rLJdDQY21OgRLCZ9sD").Popularity.Should().NotBeNullOrEmpty(); }
public void TestSearchTracks() { var result = new SpotifyMetadataApiClient().SearchTracks("foo"); result.Should().NotBeNull(); result.Info.Should().NotBeNull(); result.Info.Limit.Should().Be(100); result.Info.NumResults.Should().BeGreaterOrEqualTo(30); result.Info.Offset.Should().Be(0); result.Info.Page.Should().Be(1); result.Info.Query.Should().Be("foo"); result.Info.Type.Should().Be("track"); result.Tracks.Should().NotBeNullOrEmpty(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Should().NotBeNull(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Name.Should().Be("Everlong"); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Album.Should().NotBeNull(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Album.Artist.Should().BeNull(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Album.ArtistId.Should().BeNull(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Album.Artists.Should().BeEmpty(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Album.Availability.Should().NotBeNull(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Album.Availability.Territories.Should().NotBeNullOrEmpty(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Album.ExternalIds.Should().BeEmpty(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Album.Href.Should().Be("spotify:album:1zCNrbPpz5OLSr6mSpPdKm"); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Album.Name.Should().Be("Greatest Hits"); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Album.Popularity.Should().BeNull(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Album.Released.Should().Be("2009"); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Artists.Should().NotBeNullOrEmpty(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Availability.Should().BeNull(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").ExternalIds.Should().NotBeNullOrEmpty(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").ExternalIds.First().Id.Should().NotBeNullOrEmpty(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").ExternalIds.First().Type.Should().NotBeNullOrEmpty(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Available.Should().NotHaveValue(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").DiscNumber.Should().BeNull(); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Length.Should().Be((decimal)249.986); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").TrackNumber.Should().Be("3"); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Href.Should().Be("spotify:track:07q6QTQXyPRCf7GbLakRPr"); result.Tracks.Find(o => o.Href == "spotify:track:07q6QTQXyPRCf7GbLakRPr").Popularity.Should().NotBeNullOrEmpty(); }
public void SaveTrack(Zirpl.Spotify.MetadataApi.Track track, Zirpl.Spotify.MetadataApi.Artist artist) { var result = new SpotifyMetadataApiClient().LookupTrack(track.Href); MusicApp.Models.Song s = new Models.Song(); s.Name = track.Name; s.Href = track.Href; s.Length = track.Length; s.Href = track.Href; s.ArtistId = result.Artists.First().Href; s.AlbumID = result.Album.Href; s.Popularity = track.Popularity; //if (ModelState.IsValid) { db.Songs.Add(s); } }