Printing artists in array
This commit is contained in:
parent
1b711f4ab8
commit
869192da61
1 changed files with 8 additions and 6 deletions
|
@ -36,7 +36,7 @@ namespace HiddenUpdater
|
||||||
foreach (var track in tracks.Items.Select(tr => tr.Track))
|
foreach (var track in tracks.Items.Select(tr => tr.Track))
|
||||||
{
|
{
|
||||||
var obj = new JObject();
|
var obj = new JObject();
|
||||||
obj["name"] = track.Name;
|
obj["sname"] = track.Name;
|
||||||
/*obj["artists"] = new JArray(track.Artists.Select(artist => new JObject
|
/*obj["artists"] = new JArray(track.Artists.Select(artist => new JObject
|
||||||
{
|
{
|
||||||
{"name", artist.Name},
|
{"name", artist.Name},
|
||||||
|
@ -48,9 +48,9 @@ namespace HiddenUpdater
|
||||||
if (!artistJson.ContainsKey(artist.Name))
|
if (!artistJson.ContainsKey(artist.Name))
|
||||||
artistJson[artist.Name] = new JObject
|
artistJson[artist.Name] = new JObject
|
||||||
{
|
{
|
||||||
{"name", artist.Name},
|
{"sname", artist.Name},
|
||||||
{"url", artist.ExternalUrls["spotify"]},
|
{"surl", artist.ExternalUrls["spotify"]},
|
||||||
{"id", artist.Id}
|
{"sid", artist.Id}
|
||||||
};
|
};
|
||||||
artJson.Add(artist.Name);
|
artJson.Add(artist.Name);
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,8 @@ namespace HiddenUpdater
|
||||||
obj["artists"] = artJson;
|
obj["artists"] = artJson;
|
||||||
obj["popularity"] = track.Popularity;
|
obj["popularity"] = track.Popularity;
|
||||||
obj["durationMs"] = track.DurationMs;
|
obj["durationMs"] = track.DurationMs;
|
||||||
obj["url"] = track.ExternUrls["spotify"];
|
obj["surl"] = track.ExternUrls["spotify"];
|
||||||
|
obj["sid"] = track.Id;
|
||||||
|
|
||||||
playlistJson.Add(obj);
|
playlistJson.Add(obj);
|
||||||
C++;
|
C++;
|
||||||
|
@ -70,7 +71,7 @@ namespace HiddenUpdater
|
||||||
Console.WriteLine("Getting artists...");
|
Console.WriteLine("Getting artists...");
|
||||||
foreach (var kv in artistJson)
|
foreach (var kv in artistJson)
|
||||||
{
|
{
|
||||||
var artist = spotify.GetArtist((string) kv.Value["id"]);
|
var artist = spotify.GetArtist((string) kv.Value["sid"]);
|
||||||
var artJson = kv.Value;
|
var artJson = kv.Value;
|
||||||
artJson["followers"] = artist?.Followers?.Total;
|
artJson["followers"] = artist?.Followers?.Total;
|
||||||
artJson["popularity"] = artist?.Popularity;
|
artJson["popularity"] = artist?.Popularity;
|
||||||
|
@ -79,6 +80,7 @@ namespace HiddenUpdater
|
||||||
|
|
||||||
//Console.WriteLine(artistJson.ToString(Formatting.None));
|
//Console.WriteLine(artistJson.ToString(Formatting.None));
|
||||||
File.WriteAllText("songs.json", playlistJson.ToString());
|
File.WriteAllText("songs.json", playlistJson.ToString());
|
||||||
|
File.WriteAllText("artists.json", new JArray(artistJson.Children().Select(tk=>tk.Last)).ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue