Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 6449fee9e9
Fetching contributors…

Cannot retrieve contributors at this time

executable file 33 lines (24 sloc) 0.848 kb
import lifestream
import dateutil.parser
import pytz
import feedparser
import datetime
import sys
if (len(sys.argv) < 2):
print "Usage: lastfm lastfmid"
dbcxn = lifestream.getDatabaseConnection()
cursor = lifestream.cursor(dbcxn)
id = sys.argv[1]
url = "" % id
fp = feedparser.parse(url)
type = "lastfm"
s_sql = u'replace into lifestream (`id`, `type`, `systemid`, `title`, `date_created`, `url` ) values (0, %s, %s, %s, %s, %s);'
for i in range(1,len(fp['entries'])):
o_item = fp['entries'][i]
id = o_item['guid']
title = o_item.title.encode("utf_8")
localdate = dateutil.parser.parse(o_item.updated)
updated = localdate.astimezone(pytz.utc).strftime("%Y-%m-%d %H:%M")
cursor.execute(s_sql, (type, id, title, updated, o_item['link']))
Jump to Line
Something went wrong with that request. Please try again.