Exemple #1
0
        /// <summary>
        /// Returns the weekly artist chart for this group in the given
        /// <see cref="Lastfm.Services.WeeklyChartTimeSpan"/>.
        /// </summary>
        /// <param name="span">
        /// A <see cref="WeeklyChartTimeSpan"/>
        /// </param>
        /// <returns>
        /// A <see cref="WeeklyArtistChart"/>
        /// </returns>
        public WeeklyArtistChart GetWeeklyArtistChart(WeeklyChartTimeSpan span)
        {
            RequestParameters p = getParams();

            p["from"] = Utilities.DateTimeToUTCTimestamp(span.From).ToString();
            p["to"]   = Utilities.DateTimeToUTCTimestamp(span.To).ToString();

            XmlDocument doc = request("group.getWeeklyArtistChart", p);

            XmlNode n = doc.GetElementsByTagName("weeklyartistchart")[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);

            WeeklyArtistChart chart = new WeeklyArtistChart(new WeeklyChartTimeSpan(nfrom, nto));

            foreach (XmlNode node in doc.GetElementsByTagName("artist"))
            {
                int rank      = Int32.Parse(node.Attributes[0].InnerText);
                int playcount = Int32.Parse(extract(node, "playcount"));

                WeeklyArtistChartItem item =
                    new WeeklyArtistChartItem(new Artist(extract(node, "name"), Session),
                                              rank, playcount, new WeeklyChartTimeSpan(nfrom, nto));

                chart.Add(item);
            }

            return(chart);
        }
Exemple #2
0
        /// <summary>
        /// Returns a weekly artist chart of a specified week.
        /// </summary>
        /// <param name="span">A <see cref="WeeklyChartTimeSpan"/></param>
        /// <returns>A <see cref="WeeklyArtistChart"/></returns>
        public WeeklyArtistChart GetWeeklyArtistChart(WeeklyChartTimeSpan span)
        {
            var parameters = GetParams();

            parameters["from"] = Utilities.DateTimeToUTCTimestamp(span.From).ToString();
            parameters["to"]   = Utilities.DateTimeToUTCTimestamp(span.To).ToString();

            XmlDocument doc = Request("user.getWeeklyArtistChart", parameters);

            XmlNode n = doc.GetElementsByTagName("weeklyartistchart")[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 WeeklyArtistChart(new WeeklyChartTimeSpan(nfrom, nto));

            foreach (XmlNode node in doc.GetElementsByTagName("artist"))
            {
                var rank      = int.Parse(node.Attributes[0].InnerText);
                var playcount = int.Parse(Extract(node, "playcount"));

                var artist   = new Artist(Extract(node, "name"), Session);
                var timeSpan = new WeeklyChartTimeSpan(nfrom, nto);
                var item     = new WeeklyArtistChartItem(artist, rank, playcount, timeSpan);

                chart.Add(item);
            }

            return(chart);
        }
Exemple #3
0
        /// <summary>
        /// Returns the latest weekly artist chart.
        /// </summary>
        /// <returns>
        /// A <see cref="WeeklyArtistChart"/>
        /// </returns>
        public WeeklyArtistChart GetWeeklyArtistChart()
        {
            XmlDocument doc = request("tag.getWeeklyArtistChart");

            XmlNode n = doc.GetElementsByTagName("weeklyartistchart")[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);

            WeeklyArtistChart chart = new WeeklyArtistChart(new WeeklyChartTimeSpan(nfrom, nto));

            foreach (XmlNode node in doc.GetElementsByTagName("artist"))
            {
                int rank      = Int32.Parse(node.Attributes[0].InnerText);
                int playcount = Int32.Parse(extract(node, "playcount"));

                WeeklyArtistChartItem item =
                    new WeeklyArtistChartItem(new Artist(extract(node, "name"), Session),
                                              rank, playcount, new WeeklyChartTimeSpan(nfrom, nto));

                chart.Add(item);
            }

            return(chart);
        }
Exemple #4
0
        /// <summary>
        /// Returns the latest weekly artist chart.
        /// </summary>
        /// <returns>A <see cref="WeeklyArtistChart"/></returns>
        public WeeklyArtistChart GetWeeklyArtistChart()
        {
            XmlDocument doc = Request("tag.getWeeklyArtistChart");

            XmlNode n = doc.GetElementsByTagName("weeklyartistchart")[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 WeeklyArtistChart(new WeeklyChartTimeSpan(nfrom, nto));

            foreach (XmlNode node in doc.GetElementsByTagName("artist"))
            {
                var rank      = int.Parse(node.Attributes[0].InnerText);
                var playcount = int.Parse(Extract(node, "playcount"));

                var artist   = new Artist(Extract(node, "name"), Session);
                var timeSpan = new WeeklyChartTimeSpan(nfrom, nto);
                var item     = new WeeklyArtistChartItem(artist, rank, playcount, timeSpan);

                chart.Add(item);
            }

            return(chart);
        }