Simple Identi.ca to Jaiku Bridge
Well since I barely use my jaiku account, even when it has xmpp support. Probably is that I’m not really interested on the conversations there and no one uses jaiku channels. It would be a lot better if it used something like “track” the one you find in identispy for identi.ca, twitterspy for twitter and Jance for Pownce.
Anyway I decided that I wouldn’t bother setting yet another account on some random service to update identi.ca,twitter and jaiku at the same time so I decided to write something myself.
After very little effort I came out with this, it’s pretty basic and with ZERO error checking but it does what I want.
I used feedparser and simplejson python modules.
-
#!/usr/bin/env python
-
-
import simplejson
-
import urllib
-
import feedparser
-
import time
-
import re
-
-
identica_rss="http://identi.ca/IDENTICA_USER/rss"
-
user = ‘JAIKU_USER’
-
api_key =‘JAIKU_KEY’
-
-
class JaikuInterface:
-
method = ‘POST’
-
api_url = ‘http://api.jaiku.com/json’
-
def __init__(self,user,key):
-
self.user=user
-
self.api_key=key
-
def post(self,message):
-
body_dict = (
-
(‘user’,self.user),
-
(‘personal_key’,self.api_key),
-
(‘method’,‘presence.send’),
-
(‘message’,message)
-
)
-
body = urllib.urlencode(body_dict)
-
try:
-
f=urllib.urlopen(self.api_url,body)
-
ret = simplejson.loads(f.read())
-
f.close()
-
if ret[’status’]==u‘ok’:
-
return True
-
else:
-
return False
-
except:
-
return False
-
-
-
-
jaiku = JaikuInterface(user,key)
-
last_date = time.mktime(time.gmtime())
-
oldest = last_date
-
time_fmt= "%Y-%m-%dT%H:%M:%S+00:00"
-
striper = re.compile("^deepspawn: ")
-
stripuser = lambda(x): striper.sub("",x)
-
while True:
-
try:
-
identifeed=feedparser.parse(identica_rss)
-
for entry in identifeed.entries:
-
entry_date = time.strptime(entry.updated,time_fmt)
-
entry_date = time.mktime(entry_date)
-
if entry_date > last_date:
-
oldest = max(entry_date,oldest)
-
post = stripuser(entry.title)
-
jaiku.post(post)
-
last_date=oldest
-
except:
-
pass
-
time.sleep(5*60)
-
Well just replace IDENTICA_USER, JAIKU_USER and JAIKU_KEY with your values and that’s all.
It will poll every 5 minutes the rss and update jaiku with the new dents.
Well that’s all, it’s a small hack I hope someone find this interesting.







Add New Comment
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)