예제 #1
0
        /// <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];

            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);
        }
예제 #2
0
        /// <summary>
        /// Returns the weekly track chart for this group in the given <see cref="UB.LastFM.Services.WeeklyChartTimeSpan"/>.
        /// </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("group.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);
        }