/// <summary> /// Returns the latest weekly track chart for this group. /// </summary> /// <returns> /// A <see cref="WeeklyTrackChart"/> /// </returns> public WeeklyTrackChart GetWeeklyTrackChart() { XmlDocument doc = request("group.getWeeklyTrackChart"); XmlNode n = doc.GetElementsByTagName("weeklytrackchart")[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); WeeklyTrackChart chart = new WeeklyTrackChart(new WeeklyChartTimeSpan(nfrom, nto)); foreach (XmlNode node in doc.GetElementsByTagName("track")) { int rank = Int32.Parse(node.Attributes[0].InnerText); int playcount = Int32.Parse(extract(node, "playcount")); WeeklyTrackChartItem item = new WeeklyTrackChartItem(new Track(extract(node, "artist"), extract(node, "name"), Session), rank, playcount, new WeeklyChartTimeSpan(nfrom, nto)); chart.Add(item); } return(chart); }
/// <summary> /// Returns a weekly chart specified by a certain week. /// </summary> /// <param name="span"> /// A <see cref="WeeklyChartTimeSpan"/> /// </param> /// <returns> /// A <see cref="WeeklyTrackChart"/> /// </returns> public WeeklyTrackChart GetWeeklyTrackChart(WeeklyChartTimeSpan span) { RequestParameters p = getParams(); p["from"] = Utilities.DateTimeToUTCTimestamp(span.From).ToString(); p["to"] = Utilities.DateTimeToUTCTimestamp(span.To).ToString(); XmlDocument doc = request("user.getWeeklyTrackChart", p); XmlNode n = doc.GetElementsByTagName("weeklytrackchart")[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); WeeklyTrackChart chart = new WeeklyTrackChart(new WeeklyChartTimeSpan(nfrom, nto)); foreach (XmlNode node in doc.GetElementsByTagName("track")) { int rank = Int32.Parse(node.Attributes[0].InnerText); int playcount = Int32.Parse(extract(node, "playcount")); WeeklyTrackChartItem item = new WeeklyTrackChartItem(new Track(extract(node, "artist"), extract(node, "name"), Session), rank, playcount, new WeeklyChartTimeSpan(nfrom, nto)); chart.Add(item); } return(chart); }
/// <summary> /// Returns the latest weekly track chart. /// </summary> /// <returns>A <see cref="WeeklyTrackChart"/></returns> public WeeklyTrackChart GetWeeklyTrackChart() { XmlDocument doc = Request("user.getWeeklyTrackChart"); XmlNode n = doc.GetElementsByTagName("weeklytrackchart")[0]; var nfrom = Utilities.TimestampToDateTime(long.Parse(n.Attributes[1].InnerText), DateTimeKind.Utc); var nto = Utilities.TimestampToDateTime(long.Parse(n.Attributes[2].InnerText), DateTimeKind.Utc); var chart = new WeeklyTrackChart(new WeeklyChartTimeSpan(nfrom, nto)); foreach (XmlNode node in doc.GetElementsByTagName("track")) { var rank = int.Parse(node.Attributes[0].InnerText); var playcount = int.Parse(Extract(node, "playcount")); var track = new Track(Extract(node, "artist"), Extract(node, "name"), Session); var timeSpan = new WeeklyChartTimeSpan(nfrom, nto); var item = new WeeklyTrackChartItem(track, rank, playcount, timeSpan); chart.Add(item); } return(chart); }
/// <summary> /// Returns the weekly track chart for this group in the given <see cref="WeeklyChartTimeSpan"/>. /// </summary> /// <param name="span">A <see cref="WeeklyChartTimeSpan"/></param> /// <returns>A <see cref="WeeklyTrackChart"/></returns> public WeeklyTrackChart GetWeeklyTrackChart(WeeklyChartTimeSpan span) { var parameters = GetParams(); parameters["from"] = Utilities.DateTimeToUTCTimestamp(span.From).ToString(); parameters["to"] = Utilities.DateTimeToUTCTimestamp(span.To).ToString(); XmlDocument doc = Request("group.getWeeklyTrackChart", parameters); XmlNode n = doc.GetElementsByTagName("weeklytrackchart")[0]; var nfrom = Utilities.TimestampToDateTime(long.Parse(n.Attributes[1].InnerText), DateTimeKind.Utc); var nto = Utilities.TimestampToDateTime(long.Parse(n.Attributes[2].InnerText), DateTimeKind.Utc); var chart = new WeeklyTrackChart(new WeeklyChartTimeSpan(nfrom, nto)); foreach (XmlNode node in doc.GetElementsByTagName("track")) { var rank = int.Parse(node.Attributes[0].InnerText); var playcount = int.Parse(Extract(node, "playcount")); var track = new Track(Extract(node, "artist"), Extract(node, "name"), Session); var timeSpan = new WeeklyChartTimeSpan(nfrom, nto); var item = new WeeklyTrackChartItem(track, rank, playcount, timeSpan); chart.Add(item); } return(chart); }