/// <summary> /// Returns a weekly album chart of a specified week. /// </summary> /// <param name="span"> /// A <see cref="WeeklyChartTimeSpan"/> /// </param> /// <returns> /// A <see cref="WeeklyAlbumChart"/> /// </returns> public WeeklyAlbumChart GetWeeklyAlbumChart(WeeklyChartTimeSpan span) { RequestParameters p = getParams(); p["from"] = Utilities.DateTimeToUTCTimestamp(span.From).ToString(); p["to"] = Utilities.DateTimeToUTCTimestamp(span.To).ToString(); XmlDocument doc = request("user.getWeeklyAlbumChart", p); XmlNode n = doc.GetElementsByTagName("weeklyalbumchart")[0]; DateTime nfrom = Utilities.TimestampToDateTime(Int64.Parse(n.Attributes[1].InnerText), DateTimeKind.Utc); DateTime nto = Utilities.TimestampToDateTime(Int64.Parse(n.Attributes[2].InnerText), DateTimeKind.Utc); WeeklyAlbumChart chart = new WeeklyAlbumChart(new WeeklyChartTimeSpan(nfrom, nto)); foreach (XmlNode node in doc.GetElementsByTagName("album")) { int rank = Int32.Parse(node.Attributes[0].InnerText); int playcount = Int32.Parse(extract(node, "playcount")); WeeklyAlbumChartItem item = new WeeklyAlbumChartItem(new Album(extract(node, "artist"), extract(node, "name"), Session), rank, playcount, new WeeklyChartTimeSpan(nfrom, nto)); chart.Add(item); } return(chart); }
/// <summary> /// Returns the latest weekly album chart for this group. /// </summary> /// <returns> /// A <see cref="WeeklyAlbumChart"/> /// </returns> public WeeklyAlbumChart GetWeeklyAlbumChart() { XmlDocument doc = request("group.getWeeklyAlbumChart"); XmlNode n = doc.GetElementsByTagName("weeklyalbumchart")[0]; DateTime nfrom = Utilities.TimestampToDateTime(Int64.Parse(n.Attributes[1].InnerText), DateTimeKind.Utc); DateTime nto = Utilities.TimestampToDateTime(Int64.Parse(n.Attributes[2].InnerText), DateTimeKind.Utc); WeeklyAlbumChart chart = new WeeklyAlbumChart(new WeeklyChartTimeSpan(nfrom, nto)); foreach (XmlNode node in doc.GetElementsByTagName("album")) { int rank = Int32.Parse(node.Attributes[0].InnerText); int playcount = Int32.Parse(extract(node, "playcount")); WeeklyAlbumChartItem item = new WeeklyAlbumChartItem(new Album(extract(node, "artist"), extract(node, "name"), Session), rank, playcount, new WeeklyChartTimeSpan(nfrom, nto)); chart.Add(item); } return(chart); }