#What 😭
1 messages · Page 1 of 1 (latest)
Post a complete URI query for a spotify track you are trying to get, e.g. the official api would be http://open.spotify.com/track/6rqhFgbbKwnb9MLmUQDhG6
What were you trying to query?
You said you were using a different API
What is the url?
Of the track?
The complete query url
im gonna just send all the code because i dont rly understand what ur asking for
IEnumerator download(string link)
{
status.text = "Attempting to download... (may take a while)";
WWWForm frm = new WWWForm();
frm.AddField("link", link);
using (UnityWebRequest www = UnityWebRequest.Post("https://api.spotify-downloader.com/", frm))
{
yield return www.SendWebRequest();
if(www.responseCode == 500)
{
status.text = "Invalid Link";
}
else if(www.responseCode == 200)
{
dynamic results = JObject.Parse(www.downloadHandler.text);
string title = "";
string artists = "";
Debug.Log(results);
if (link.StartsWith("https://open.spotify.com/track/"))
{
title = results."name";
artists = string.Join(", ", results.artists);
}
GameObject song = Instantiate(songholder);
TMP_Text[] texts = song.transform.Find("song info").GetComponentsInChildren<TMP_Text>();
texts[0].text = title;
texts[1].text = artists;
song.transform.SetParent(contentholder.transform);
status.text = "Succeeded!";
www.Dispose();
}
else
{
status.text = "Failed! Unknown error";
}
}
}
And link is in the form https://open.spotify.com/track/55823uSw3vF5fqtv6dDsoE?si=ed7c9216146c4c84?
That’s the song I’m using
But yes link is along those lines
Printing the dynamic shows all the content like title artists etc
So it’s retrieving fine
Hmm, i'll try fetching it myself, give me a second

This works fine for me:
WWWForm form = new WWWForm();
form.AddField("link", link);
using (UnityWebRequest www = UnityWebRequest.Post("https://api.spotify-downloader.com/", form))
{
yield return www.SendWebRequest();
dynamic result = JsonConvert.DeserializeObject(www.downloadHandler.text);
Debug.Log(result.name);
}
Why isn’t it working for me then 😭
Hm one sec
(wrapper dynamic-method) System.Object.CallSite.Target(System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object)
System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet] (System.Runtime.CompilerServices.CallSite site, T0 arg0) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
spotifyadder+<download>d__7.MoveNext () (at Assets/MUSICSCENE/spotifyadder.cs:55)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <ca42919df2b74e53b11002749c8755af>:0)
still getting this
when logging the dynamic it returns this

thats enough unity for today...
I always use JsonConvert 🤷
Or are you using the code I posted
I also recommend not using dynamic and instead parsing into a proper data layout (if possible)
Makes mistakes much less common
Later I’ll try using JSON convert and parsing it into a proper data layout
@potent flax could you provide an example of JsonConvert, im having trouble implmenting it in my script