User:Birgit Bachler/td feedbook

From XPUB & Lens-Based wiki

bash zipbook.sh debook04 >> debook04.epub

mkdir $1/
cp -R epub-raw-files/* $1/
python feeder.py > $1/OEBPS/content.html
cd $1
zip -0Xq $1.epub mimetype
zip -Xr9Dq $1.epub *
lucidor $1.epub &


feeder.py

import feedparser

debug = feedparser.parse("http://feeds.feedburner.com/DebugAllInOne")
import pprint
#pprint.pprint(debug)
#pprint.pprint(debug.entries[0])
#print(debug.entries[0]["title"]) #print out the entry of most recent pos
print """<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>De:Book</title>
    <link type="text/css" rel="stylesheet" media="all" href="stylesheet.css" />
  </head>
  <body>
    <h1>De:Book</h1>
    <p> """


for i in debug.entries:
    print "<h2>"+i["title"].replace("&", "&amp;").encode("utf-8")+"</h2>"
    print "<p>"+i["summary"].replace("&", "&amp;").encode("utf-8")+"</p>"
    print "<p class='date'>"+i["date"].replace("&", "&amp;").encode("utf-8")+"</p>"
    print "<br></br>"

print """
</p>
  </body>
</html> """


stylesheet.css

body, p {
  font-family: sans-serif; 
  font-size: 12px;
  background-color: #BFBFBF;
}
h1{
  font-family: Georgia, serif;     
  font-size: 18px;
  font-weight:bold;
  color: #8159BE;
}
h2{
  font-family: Georgia, serif;     
  font-size: 16px;
  font-weight:bold;
  color: #4E3673;
}

.date {
  font-family: sans-serif; 
  font-size: 8px;
}


Attachments