Esempio n. 1
0
        public bool ParseEvent(string EventUrl, List <EventInformation> EventList)
        {
            Match  match;
            string EventContents;

            EventContents = PageDownloader.GetPageContents(EventUrl);

            match = Regex.Match(EventContents, @"<script type=""application/ld\+json"">(.*?)</script>", RegexOptions.Singleline);
            if (match.Success)
            {
                // For some reason the match has the <script> / </script> tags in it so we strip those out.
                string json = match.Groups[0].Value.Substring(35);
                json = json.Remove(json.Length - 10);

                EventDataJson    twEventInfo = JsonConvert.DeserializeObject <EventDataJson>(json);
                EventInformation eventInfo   = new EventInformation()
                {
                    Title = twEventInfo.name, Location = twEventInfo.location.name, Description = EventUrl
                };
                eventInfo.SetStartDate(twEventInfo.startDate);
                EventList.Add(eventInfo);

                return(true);
            }

            Console.WriteLine("ERROR: Couldn't parse event at {0}", EventUrl);
            return(false);
        }
Esempio n. 2
0
        public bool ParseEvent(string EventURL, List <EventInformation> EventList)
        {
            string           EventContents;
            EventInformation EventInfo;
            Match            match;

            if (!IsFacebookUrl(EventURL))
            {
                return(false);
            }

            EventContents = PageDownloader.GetPageContents(EventURL);
            if (LoginRequired(EventContents))
            {
                Console.WriteLine("ERROR: {0} is a non-public event and requires login.", EventURL);
                return(false);
            }

            //
            // This is true if this is a multi-event event.
            //
            match = Regex.Match(EventContents, @"<a href=""/events/(\d+)/\?event_time_id=(\d+)");
            if (match.Success)
            {
                do
                {
                    string url;

                    url = String.Format("https://www.facebook.com/events/{0}/?event_time_id={1}", match.Groups[1].Value, match.Groups[2].Value);
                    if (!ParseEvent(url, EventList))
                    {
                        Console.WriteLine("Couldn't parse FB sub-event {0}", url);
                        return(false);
                    }

                    match = match.NextMatch();
                } while (match.Success);
            }
            else
            {
                if (ParseFacebookEventListing(EventURL, EventContents, out EventInfo))
                {
                    EventList.Add(EventInfo);
                }
            }

            return(true);
        }
Esempio n. 3
0
        public bool ParseEvent(string EventURL, List <EventInformation> EventList)
        {
            string EventContents;

            if (!IsAxsUrl(EventURL))
            {
                return(false);
            }

            EventContents = PageDownloader.GetPageContents(EventURL);

            EventInformation EventInfo = new EventInformation();

            EventInfo.SetStartDate(GetStartDate(EventContents));
            EventInfo.Title       = GetTitle(EventContents);
            EventInfo.Description = EventURL;
            EventInfo.Location    = GetLocation(EventContents);

            return(true);
        }
Esempio n. 4
0
        public bool ParseEvent(string EventURL, List <EventInformation> EventList)
        {
            string EventContents;
            Match  match;

            EventContents = PageDownloader.GetPageContents(EventURL);

            match = Regex.Match(EventContents, @"<div id=""maplocation"" style=""line-height:100%;"">(.*?) at (.*?), (.*?)<div id=""address"" style=""font-size:12px;margin-top:3px;"">(.*?)\(");
            // match = Regex.Match(EventContents, @"<script type=""application/ld\+json"">(.*?)</script>", RegexOptions.Singleline);
            if (match.Success)
            {
                string EventTitle;

                // TODO -- This is ugly but seems to mostly work. We still need a fuzzy/NLP date parser as DateTime.Parse is pretty dumb/rigid.
                DateTime StartTime = DateTime.Parse($"{match.Groups[1].Value} {DateTime.Now.Year} {match.Groups[2].Value}");

                Match match2 = Regex.Match(EventContents, @"<link rel=""alternate"" type=""application/rss\+xml"" title=""(.*?)""");
                if (match2.Success)
                {
                    EventTitle = match2.Groups[1].Value;
                }
                else
                {
                    EventTitle = "Error! Couldn't determine title!";
                }

                EventInformation eventInfo = new EventInformation()
                {
                    Title = EventTitle, Location = $"{match.Groups[3].Value} ({match.Groups[4].Value})", Description = EventURL
                };
                eventInfo.SetStartDate(StartTime.ToString());
                EventList.Add(eventInfo);

                return(true);
            }

            return(false);
        }