Networking

How to fix the meetup.com broken exported calendars.

I’m a big fan of meetup.com, but they’re so tragically unhip when it comes to mashups/integration/web 2.0.  One of my biggest gripes until about 6 months ago was that they had no facility (besides API) for exporting a calendar of meetups to my calendar app (I use Google Calendar), or any other calendar app for that matter.

They introduced an export feature recently, but it’s pretty useless.  Here’s why: they offer two calendars

  • [Calendar A] contains all upcoming items in all your meetup groups
  • [Calendar B] contains upcoming items which you have RSVP’d with “yes” or “maybe”.

That’s it.  The calendars exported don’t even contain links that allow you to RSVP from directly inside your calendar — you have click through to the meetup.com site, log in, then RSVP.  Ugh.

 

Come on, product guys.  What’s really called for is 4 separate calendars.

  • [Calendar "yes"] All groups, “yes” events
  • [Calendar "maybe"] All groups, “maybe” events
  • [Calendar "no"] All groups, “no” events
  • [Calendar "none"] All groups, events to which I have not yet submitted an RSVP.

I was finally just pissed off enough about the status quo that I fixed it for myself, and below I share the code.  You can try it out here: http://spicylogic.com/allenday/cgi-bin/mu.cgi?key=<your_api_key>&cal=<calendar> 

where <your_api_key> can be found here and <calendar> is one of “yes”, “no”, “none”, “maybe”.

Okay, here’s the code.  Install it on your own machine if possible, my ISP will appreciate it.  If you find fuckups, let me know and I’ll update the post.

#!/usr/bin/perl
use strict;
use CGI qw(:standard);
use Date::Manip qw(ParseDate ParseDateString ParseDateDelta DateCalc UnixDate);
use Date::Parse;
use HTML::Entities;
use LWP::Simple qw(get);
use XML::DOM;
 
use constant URL_EVENTS =&gt; 'http://api.meetup.com/events?key=%s&amp;member_id=%d&amp;format=xml';
 
print header(q(text/calendar));
 
my $parser = new XML::DOM::Parser ();
 
my $mode = param( 'cal' );
my $key  = param( 'key' );
my $user = param( 'user' );
 
if ( ! $mode || ! $key || ! $user ) {
  die
}
 
my $events_url = sprintf( URL_EVENTS, $key, $user );
#warn $events_url;
my $events_txt = get( $events_url );
#warn $events_txt;
my $events_dom = $parser-&gt;parse( $events_txt );
#warn $events_dom;
 
print qq(BEGIN:VCALENDAR\nPRODID:-//Meetup Inc//RemoteApi//EN\nVERSION:2.0\nMETHOD:PUBLISH\nCALSCALE:GREGORIAN\nX-ORIGINAL-URL:http://www.meetup.com/\nX-WR-CALNAME:mu $mode\n);
 
my $events = $events_dom-&gt;getElementsByTagName( 'item' );
for ( my $i = 0 ; $i &lt; $events-&gt;getLength() ; $i++ ) {
  my $event = $events-&gt;item( $i );
  my $n_id    = $event-&gt;getElementsByTagName( 'id'             )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_rsvp  = $event-&gt;getElementsByTagName( 'myrsvp'         )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_addr0 = $event-&gt;getElementsByTagName( 'venue_name'     )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_addr1 = $event-&gt;getElementsByTagName( 'venue_address1' )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_addr2 = $event-&gt;getElementsByTagName( 'venue_address2' )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_addr3 = $event-&gt;getElementsByTagName( 'venue_address3' )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_addr4 = $event-&gt;getElementsByTagName( 'venue_city'     )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_addr5 = $event-&gt;getElementsByTagName( 'venue_state'    )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_addr6 = $event-&gt;getElementsByTagName( 'venue_zip'      )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_desc  = $event-&gt;getElementsByTagName( 'description'    )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_link  = $event-&gt;getElementsByTagName( 'event_url'      )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_name  = $event-&gt;getElementsByTagName( 'name'           )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_lat   = $event-&gt;getElementsByTagName( 'venue_lat'      )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_lon   = $event-&gt;getElementsByTagName( 'venue_lon'      )-&gt;item( 0 )-&gt;getFirstChild();
  my $n_start_time  = $event-&gt;getElementsByTagName( 'time'           )-&gt;item( 0 )-&gt;getFirstChild();
 
  my $start_time;
  my $end_time;
 
  #my $dummy_time = "20000101T000000Z";
  my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time());
  my $dummy_time = sprintf( q(%04d%02d%02dT%02d%02d%02dZ), $year + 1900, $mon + 1, $mday, $hour, $min, $sec );
 
  if ( $n_start_time ) {
    my ($ss,$mm,$hh,$day,$month,$year,$zone);
 
    ($ss,$mm,$hh,$day,$month,$year,$zone) = strptime( $n_start_time-&gt;toString() );
    $start_time = sprintf( q(%04d%02d%02dT%02d%02d%02dZ), $year + 1900, $month + 1, $day, $hh, $mm, $ss );
 
    my $eday = $day;
    if ( $hh == 23 ) {
      $eday = $day + 1;
    }
    my $ehh = ($hh + 1) % 24;
    $end_time   = sprintf( q(%04d%02d%02dT%02d%02d%02dZ), $year + 1900, $month + 1, $eday, $ehh, $mm, $ss );
  }
  else {
    $start_time = '';
    $end_time = '';
  }
 
  if ( $mode eq $n_rsvp-&gt;toString() ) {
    my $id   = $n_id-&gt;toString();
    my $name = $n_name ? $n_name-&gt;toString() : "";
    my $desc = $n_desc ? $n_desc-&gt;toString() : "";
    my $addr = ( $n_addr0 ? $n_addr0-&gt;toString().', ' : "" )
             . ( $n_addr1 ? $n_addr1-&gt;toString().', ' : "" )
             . ( $n_addr2 ? $n_addr2-&gt;toString().', ' : "" )
             . ( $n_addr3 ? $n_addr3-&gt;toString().', ' : "" )
             . ( $n_addr4 ? $n_addr4-&gt;toString().', ' : "" )
             . ( $n_addr5 ? $n_addr5-&gt;toString().', ' : "" )
             . ( $n_addr6 ? $n_addr6-&gt;toString() : "" );
    #$desc =~ s/(.)/(ord($1) &gt; 127) ? "" : $1/egs;
 
    $name = HTML::Entities::decode_entities( $name );
    $desc = HTML::Entities::decode_entities( $desc );
    $addr = HTML::Entities::decode_entities( $addr );
    $name =~ s/,/\\,/g;
    $desc =~ s/,/\\,/g;
    $addr =~ s/,/\\,/g;
 
    $desc =~ s#
#\\n#gs;
    $desc .= "\\n\\n\\nGoing?\\n\\n";
    foreach my $response ( qw( yes no maybe ) ) {
      $desc .= uc($response).qq(: http://api.meetup.com/rsvp?event_id=$id&amp;key=$key&amp;rsvp=$response\\n);
    }
 
    my $geo = $n_lat &amp;&amp; $n_lon ? "GEO:" . $n_lat-&gt;toString() . ";" . $n_lon-&gt;toString() . "\n" : undef;
 
    #print sprintf( qq(BEGIN:VEVENT\nSUMMARY:%s\nDESCRIPTION:%s\nLAST-MODIFIED:%s\nUID:%s\nCLASS:%s\nCREATED:%s\nDTSTAMP:%s\nDTSTART:%s\nDTEND:%s\nLOCATION:%s\n\nURL:%s\nEND:VEVENT\n),
    print sprintf( qq(BEGIN:VEVENT\nSUMMARY:%s\nDESCRIPTION:%s\nLAST-MODIFIED:%s\nUID:%s\nCLASS:%s\nCREATED:%s\nDTSTAMP:%s\nDTSTART:%s\nDTEND:%s\n%sLOCATION:%s\nURL:%s\nEND:VEVENT\n),
      $name,
      $desc,
      $start_time,
      "event_$id\@meetup.com",
      "PUBLIC",
      $dummy_time,
      $dummy_time,
      $start_time,
      $end_time,
      $geo,
      $addr,
      $n_link ? $n_link-&gt;toString() : "",
    );
  }
}
 
print qq(END:VCALENDAR\n);

Administration
Life
Networking
Perl
Software

Comments (1)

Permalink

a small world / celebrity encounter

1. Noticed a new Tesla Motors showroom in Los Angeles at Sepulveda/405 on Santa Monica Blvd last night on my drive to my guitar lesson. Made a mental note to stop by and check it out, looks like they have some museum-style exhibits –fuel cell cutaways, etc of the car.

2. Was talking it up to some friends/coworkers earlier today.

3. Was planning to go to the Hadoop Meetup tonight at Mahalo, but skipped it and worked late.

4. Saw an orange Lotus pass me on the way home… but wait… it has a TESLA logo! I pursued, thinking it was kind of late for a test drive.

5. Pulled up at a red light to listen to the silence / congratulate the driver on his nice ride. Honked my horn.

6. Driver rolls down the window and turns to me, and it’s none other than the CEO of Mahalo, Jason Calacanis!

Life
Networking
Random musings

Comments (0)

Permalink

Upcoming AI / Machine Learning Conferences

A (partial) list I found today. Doesn’t include NIPS, so I’m not sure how exhaustive it is, but it has a bunch I haven’t seen before.

http://www.kmining.com/info_conferences.html

Analytics
Informatics
Mathematics
Networking
Science
Software
Statistics

Comments (0)

Permalink

Los Angeles SoC(i)al Tech Scene

This post has moved

Business
Computing
Networking

Comments (0)

Permalink