Open GoogleCodeExporter opened 8 years ago
Thx for the info! I added a little something for this.
This snippet returns all URIs of a playlist as JSON.
First you need to add the HTML Agility Pack
(http://htmlagilitypack.codeplex.com/)
And of course: using HtmlAgilityPack;
/// <summary>
/// Get URIs for the songs of the playlist
/// </summary>
/// <param name="uri">The playlist URI</param>
/// <returns>JSON object with song URIs</returns>
public string getPlaylist(string uri)
{
try
{
string raw = new WebClient().DownloadString(string.Format("https://embed.spotify.com/?uri={0}", uri));
HtmlDocument document = new HtmlDocument();
document.LoadHtml(raw);
HtmlNodeCollection collection = document.DocumentNode.SelectNodes("//li[@data-track]");
List<string> songlinks = new List<string>();
foreach (HtmlNode link in collection)
{
songlinks.Add("spotify:track:" + link.Attributes["data-track"].Value);
}
return JsonConvert.SerializeObject(songlinks);
}
catch
{
return "";
}
}
@author: if you want you can add this code!
Original comment by Killm...@gmail.com
on 15 Jul 2013 at 10:48
Hi, I've been using this and it's pretty cool. Is there anyway to get the URI
of the current playlist? I've downloaded the HTML agility pack, and started
using it, but there's no way to get the current playlist URI.
Original comment by davegkra...@gmail.com
on 24 Jul 2013 at 4:43
Unfortunately it's not working properly anymore because the embedded playlists
are now limited to the first 200 songs only :(
Original comment by Jito...@gmail.com
on 20 Aug 2013 at 9:37
Original issue reported on code.google.com by
Jito...@gmail.com
on 17 Mar 2013 at 1:37