Permalink
Browse files

Added RSS feed creator (incomplete)

  • Loading branch information...
1 parent 6723909 commit 282631ccf8797fc3b177367942eab23eb6e82996 arjun@mojolab.org committed Mar 23, 2012
Showing with 54 additions and 0 deletions.
  1. +53 −0 tools/createrssfeed.py
  2. +1 −0 tools/lastrssedpost
View
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+import os,sys,time
+sys.path.append("/opt/swara/libs")
+from database import *
+from utilities import *
+import datetime, xmlrpclib
+import ConfigParser
+import ftplib
+import PyRSS2Gen
+config=ConfigParser.ConfigParser()
+
+db = Database()
+
+def getLastPushedPostID():
+ post=os.popen("cat lastrssedpost").read().strip()
+ return post
+
+def rss_item(post):
+ title = db.getTitleforPost('12345',post)
+ content = db.getContentforPost('12345',post) + "\n http://nbsvr1/audio/"+str(post)+".mp3"
+ #content = "<pre>[mp3-jplayer tracks='7355.mp3, url, FEED:http://10.16.16.14/swara/index.php?id=7355']"
+ link = "http://nbsvr1/swara/index.php?"+str(post)
+ time=db.getPostedTime('12345',post)
+ item="<item><title>"+title+"</title><description>"+content+"</description><link>"+link+"</link></item>"
+ return item
+if __name__=="__main__":
+ #Create Database object
+ postid=getLastPushedPostID()
+ posts=db.getUnpushedPostsInChannel(12345,postid)
+ if len(posts) == 0:
+ print "No unpushed posts"
+ exit()
+ os.system("cp /opt/swara/web/pyrss2gen.xml /opt/swara/web/swararss.xml")
+ xml = open("/opt/swara/web/swararss.xml","a")
+ for post in posts:
+ try:
+ xml.write("\n")
+ xml.write(rss_item(post))
+ xml.write("\n")
+ except:
+ print "Could not create RSS item %s" %post
+ continue
+ debugPrint("Final post = " + str(post))
+ os.system("echo %s > lastrssedpost" %(str(post)))
+ xml.write("</channel></rss>")
+ xml.close()
+
+
+
+
+
+
+
View
@@ -0,0 +1 @@
+7336

0 comments on commit 282631c

Please sign in to comment.