public void UpcomingCanCallApi()
 {
     string method = "event.search";
     var collector = new Collector(test_calinfo, settings);
     var xdoc = collector.CallUpcomingApi(method, test_upcoming_args);
     var stat = from element in xdoc.Descendants("rsp")
                select element.Attribute("stat").Value;
     Assert.That(stat.First().ToString() == "ok");
 }
Exemple #2
0
        public static List<TaggableSource> GetUpcomingVenues(Calinfo calinfo, Dictionary<string, string> settings)
        {
            var collector = new Collector(calinfo, settings);

            var args = collector.MakeUpcomingApiArgs(Collector.UpcomingSearchStyle.latlon);
            var method = "event.search";
            var xdoc = collector.CallUpcomingApi(method, args);
            int page_count = 1;
            var result_count = Collector.GetUpcomingResultCount(xdoc);

            page_count = (result_count / 100 == 0) ? 1 : result_count / 100;

            var events = collector.UpcomingIterator(page_count, "event.search");

            var venues = new List<TaggableSource>();
            var name_and_pk = "upcomingsources";

            Parallel.ForEach(source: events, body: (xelt) =>
            {
                var city = xelt.Attribute("venue_city");
                if (city.Value.ToLower() != calinfo.City)
                    return;
                var id = xelt.Attribute("venue_id").Value;
                var state = xelt.Attribute("venue_state_code");

                var name = xelt.Attribute("venue_name");
                // http://upcoming.yahoo.com/venue/863238/NH/Keene/The-Colonial-Theatre/
                var home_url = string.Format("http://upcoming.yahoo.com/venue/{0}/{1}/{2}/{3}/",
                    id,
                    state.Value,
                    city.Value,
                    name.Value.Replace(" ", "-")
                    );
                var ical_url = "http://upcoming.yahoo.com/calendar/v2/venue/" + id;
                var taggable = new TaggableSource(name.Value, calinfo.id, home_url, ical_url, city.Value);
                venues.Add(taggable);
                RememberTaggable(name_and_pk, id, taggable);
            });
            return venues;
        }