Ejemplo n.º 1
0
    public void GetRecommendations()
    {
        Debug.Log("GetRecommendations called");
        if (activeSeeds.Count > 0)
        {
            List <string> artistIds = new List <string>();
            List <string> trackIds  = new List <string>();

            foreach (var seed in activeSeeds)
            {
                PlaylistScript playlistScript = seed.GetComponent <VinylScript>().playlistScript;
                if (playlistScript.trackType == PlaylistScript.TrackType.artist)
                {
                    artistIds.Add(playlistScript.artistId);
                }
                else if (playlistScript.trackType == PlaylistScript.TrackType.playlist)
                {
                    FullPlaylist fullPlaylist = spotifyManagerScript.GetPlaylist(playlistScript.ownerId, playlistScript.playlistId);
                    artistIds.Add(fullPlaylist.Tracks.Items[0].Track.Artists[0].Id);
                }
                else if (playlistScript.trackType == PlaylistScript.TrackType.track)
                {
                    trackIds.Add(playlistScript.trackId);
                }
                else if (playlistScript.trackType == PlaylistScript.TrackType.album)
                {
                    FullAlbum fullAlbum = spotifyManagerScript.GetAlbum(playlistScript.albumId);
                    artistIds.Add(fullAlbum.Artists[0].Id);
                }
                else
                {
                    Debug.LogError("Unsupported track type");
                }
            }

            if (artistIds.Count != 0)
            {
                StartCoroutine(userRecommendations.LoadUserRecommendationsWithArtist(artistIds));
            }
            else if (trackIds.Count != 0)
            {
                StartCoroutine(userRecommendations.LoadUserRecommendationsWithTrack(trackIds));
            }
            else
            {
                Debug.LogError("Seed Id list is empty");
            }
        }
    }
Ejemplo n.º 2
0
    public IEnumerator Test_Spotify_GetAlbum()
    {
        Spotify spotify = new Spotify();

        spotify.TestSetup(); #if UNITY_IPHONE


        //Big Fish Theory
        string albumId = "1qnEwPuG3l4PqRu8h3ULH7";
        FullAlbum fullAlbum = spotify.GetAlbum(albumId);

        yield return(null);

        Debug.Log(fullAlbum.Name);

        Assert.IsFalse(fullAlbum.HasError());
    }