Skip to content

Instantly share code, notes, and snippets.

@Chris2048
Created April 7, 2013 16:34
Show Gist options
  • Save Chris2048/5331201 to your computer and use it in GitHub Desktop.
Save Chris2048/5331201 to your computer and use it in GitHub Desktop.
meetup.com personal rss to pal calendar format
#!env python2.7
import feedparser
from datetime import datetime, timedelta
d = feedparser.parse("http://www.meetup.com/events/atom/MEETUP_RSS_URL/all")['entries']
def getDate(content):
from bs4 import BeautifulSoup
soup = BeautifulSoup(content)
for p in soup.find_all('p'):
if p.text.endswith('PM') or p.text.endswith('AM'):
return p.text
print "MU meetup"
today = datetime.now()
for i in d:
d_date = datetime.strptime(getDate(i.content[0]['value']), "%A, %B %d at %I:%M %p").replace(year=today.year)
if (today - d_date) > timedelta(days=240):
new_year = today.year + 1 if today > d_date else today.year - 1
d_date = d_date.replace(year=new_year)
print ' '.join([d_date.strftime('%Y%m%d %H:%M'), i.title.encode("utf8", "ignore")])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment